글
1. OpenCV 패키지 다운로드
- http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.7/
(현재시점 2.4.7)
2. 필요한 파일들을 받는다.
# apt-get install libssl-dev openssl
# apt-get install pkg-config
# apt-get install libgtk2.0-0
# apt-get install libgtk2.0-dev
# apt-get install libavformat-dev libswscale-dev
# apt-get install libjpeg-dev
# apt-get install cmake
# apt-get update
# apt-get install gcc-4.3
# apt-get install build-essential
3. OpenCV 압축파일을 해제한다.
# tar xzvf opencv-2.4.7.tar.gz // 압축을 푼다.
# cd opencv-2.4.7
# mkdir release
# cd release
4. 중간 파일 빌드 (다시 컴파일 할 경우 여기부터)
# cmake -D CMAKE_BUILD_TYPE=release -D CMAKE_INSTALL_PREFIX=/root/lib -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ../
or
# cmake . -DUSE_SSE=ON -DUSE_SSE2=ON
5. 최종 바이너리 빌드
# make
# make install
# ldconfig
6. sample code - mywebcam.c
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
#include <objdetect/objdetect.hpp>
#include <highgui/highgui.hpp>
#include <imgproc/imgproc.hpp>
char key;
int main()
{
CvCapture *capture = cvCaptureFromCAM(CV_CAP_ANY);
//capture.set(CV_CAP_PROP_FRAME_WIDTH, 400);
//capture.set(CV_CAP_PROP_FRAME_HEIGHT, 300);
cvNamedWindow("CAM",1);
cvResizeWindow("CAM", 400, 300);
while(1)
{
IplImage *image = cvQueryFrame(capture);
cvShowImage("CAM", image);
key = cvWaitKey(10);
// ESC - break;
if(key >= 27 ) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("CAM");
return 0;
}
7. make file - mywebcam.mak (mywebcam.mak)
#
# http://www.gnu.org/software/make/manual/make.html
#
CC:=gcc
INCDIR:= -I/root/lib/include -I/root/lib/include/opencv -I/root/lib/include/opencv2
LIBDIR:= -L/root/lib/lib
CFLAGS:=-Wall #-ggdb
LDFLAGS:= -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
EXE:= mywebcam.out
#
# This is here to prevent Make from deleting secondary files.
#
.SECONDARY:
#
# $< is the first dependency in the dependency list
# $@ is the target name
#
all: dirs $(addprefix bin/, $(EXE)) tags
dirs:
mkdir -p obj
mkdir -p bin
tags: *.c
bin/%.out: obj/%.o
$(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) $(LDFLAGS) -o $@ $<
obj/%.o : %.c
$(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) $(INCLUDES) -c -o $@ $<
clean:
rm -f obj/*
rm -f bin/*
8. make & execution
# make -f mywebcam.mak
# ./bin/mywebcam.out
'Biz > Multimedia' 카테고리의 다른 글
android app with ffmpeg (0) | 2014.02.03 |
---|---|
How to build Mediainfo open source in VS2010 (0) | 2013.12.07 |
Visual Studio Build error - opencv_core247d.lib (0) | 2013.11.14 |
OpenCV & VS2010 (0) | 2013.11.14 |
ffmpeg compile in Ubuntu (0) | 2013.10.14 |
RECENT COMMENT