openCV를 arm보드에 크로스컴파일 해서 캠 사용해보신분 있나요?
아래 방법대로 했구요
1. OpenCV 1.0 download & 압축 해제
[root@localhost OpenCV]# wget http://downloads.sourceforge.net/opencvlibrary/opencv-1.0.0.tar.gz
[root@localhost OpenCV]# tar xvfz opencv-1.0.0.tar.gz
2. CrossCompile 을 하기 위하여 configure 설정
[root@localhost opencv-1.0.0]# ./configure CXX=/usr/local/arm-linux-4.1.1/bin/arm-linux-g++ --host=arm-linux --target=arm-linux --without-gtk --without-gthread --without-libjpeg --without-zlib --without-libpng --without-libtiff --without-libjasper --without-ffmpeg --without-raw1394 --without-v4l2 --without-python --prefix=/Project/OpenCV/usr
CXX=/usr/local/arm-linux-4.1.1/bin/arm-linux-g++ -> Arm Compiler 의 위치를 지정
--host=arm-linux --target=arm-linux ->Target Board 의 시스템을 지정
--without-gtk --without-gthread --without-libjpeg --without-zlib --without-libpng --without-libtiff --without-libjasper --without-ffmpeg --without-raw1394 --without-v4l2 --without-python -> 위의 라이브러리들을 컴파일시에 포함하지 않도록
--prefix=/Project/OpenCV/usr -> make install 을 입력하였을 경우 설치될 경로를 지정한다. prefix 옵션을 주지 않아도 되지만 그러면 파일복사와 심볼릭 링크를 만들어 주어야 하므로 왠만하면 써 주자~
3. /etc/ld.so.conf 에 prefix 에 준 경로를 포함해 준다
/Project/OpenCV/usr/ 추가
[root@localhost opencv-1.0.0]# ldconfig -v
4. 환경 변수에 아래의 내용을 추가
export LD_LIBRARY_PATH = /Project/OpenCV/usr/lib
export PKG_CONFIG_PATH =/Project/OpenCV/usr/lib/pkgconfig
5. Include 와 Library 의 경로 확인
[root@localhost opencv-1.0.0]# pkg-config --libs opencv
-L/Project/OpenCV/usr/lib -lcxcore -lcv -lhighgui -lcvaux
[root@localhost opencv-1.0.0]# pkg-config --cflags opencv
-l /Project/OpenCV/usr/opencv/include/opencv
6. 예제 코드를 컴파일 해본다
[root@localhost opencv-1.0.0]# arm-linux-gcc -I/Project/OpenCV/arm/include/opencv -L/Project/OpenCV/arm/lib -lcxcore -lcv -lhighgui -lcvaux -lml ex1.c -o ex1
예제 소스는
#include "cv.h"
#include "highgui.h"
#include
// A Simple Camera Capture Framework
int main() {
CvCapture* capture = cvCaptureFromCAM(0);
if( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
printf("ddd\n");
// Create a window in which the captured images will be presented
cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
// Show the image captured from the camera in the window and repeat
while( 1 ) {
// Get one frame
IplImage* frame = cvQueryFrame( capture );
if( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
cvShowImage( "mywindow", frame );
// Do not release the frame!
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
if( (cvWaitKey(10) & 255) == 27 ) break;
}
// Release the capture device housekeeping
cvReleaseCapture( &capture );
cvDestroyWindow( "mywindow" );
return 0;
}
컴파일은 잘 되는데 보드에서 실행을 하면
HIGHGUI ERROR: V4L: device /dev/video0: Unable to query number of channels
이런 메시지가 뜨면서 캠은 안됩니다
왜이런지 모르겠네요요
댓글 달기