You are not logged in.
Pages: 1
Ok, i did a
pacman -S opencv
and got a test code from the net:
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
// A Simple Camera Capture Framework
int main() {
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
if( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
// 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;
}
but get the following message
aris@arch:~$ gcc test.c
test.c:1:16: fatal error: cv.h: No such file or directory
compilation terminated.
i think i have to link the files but -lopencv does not work. Any suggestions?
Offline
gcc test.c `pkg-config --libs --cflags opencv`
Note that ` is not single quotes.
You could also use this instead.
gcc test.c -I/usr/include/opencv -lml -lcvaux -lhighgui -lcv -lcxcore
Last edited by bharani (2010-06-30 12:40:22)
Tamil is my mother tongue.
Offline
thx man it worked.
Now for the arcane knowledge part:
-i(capital) specifies the include dir
and then u link each lib by it's own?
for the first case?
what is the pkg-config?
thanks again
for the first suggestion i get
aris@arch:~$ gcc test.c "pkg-config --libs --cflags opencv"
gcc: pkg-config --libs --cflags opencv: No such file or directory
Last edited by arkara (2010-06-30 13:01:11)
Offline
for the first suggestion i get
aris@arch:~$ gcc test.c "pkg-config --libs --cflags opencv" gcc: pkg-config --libs --cflags opencv: No such file or directory
` symbol is grave accent. Not double quotes.(Below ~ symbol).
Tamil is my mother tongue.
Offline
I am trying some similar code, I did pacman -S opencv, and then I am trying to compile a hello world in cpp named helloOcv.cxx (I had left it as cxx from when I was going to use cmake). I try entering:
g++ -I /usr/include/opencv/ -lcv -lhighgui
unfortunately I get:
/usr/bin/ld: cannot find -lcv
/usr/bin/ld: cannot find -lhighgui
collect2: ld returned 1 exit status
The opencv file is in usr/include/opencv and I can see the .h files located there. Any idea why this is not referencing?
Edit: Using gcc ./helloOcv.c -I/usr/include/opencv -lcv -lhighgui gives the same response, though if I change a function call, it points me to the source code, i suspect this is failing to link the OpenCV binaries
Last edited by mpetersen3 (2012-01-29 17:15:16)
Offline
That's exactly why there is pkgconfig I believe: Those linker flags seem to be assigned very randomly depending on the version or the distribution.
On archlinux and opencv from repository you can only use those:
~ % pkg-config --libs --cflags opencv
-I/usr/include/opencv -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
(or if you don't care and it's not seriously packaged software, simply all of them)
Last edited by Cdh (2012-01-29 21:48:22)
฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz
Offline
Pages: 1