我正在尝试使用此示例代码来读取视频文件,但每次编译时都会出现这些错误。
以下是代码:
#include "cv.h"
#include "highgui.h"
int main(int argc, char** argv)
{
CvCapture* capture=0;
IplImage* frame=0;
capture = cvCaptureFromAVI("~/Documents/OpenCV/OpenCV-2.4.2/samples/c/tree.avi"); // read AVI video
if( !capture )
throw "Error when reading steam_avi";
cvNamedWindow( "w", 1);
for( ; ; )
{
/* int cvGrabFrame (CvCapture* capture);
IplImage* cvRetrieveFrame (CvCapture* capture)*/
frame = cvQueryFrame( capture );
if(!frame)
break;
cvShowImage("w", frame);
}
cvWaitKey(0); // key press to close window
cvDestroyWindow("w");
cvReleaseCapture(&capture);
以下是我编写的内容:
g++ CaptureVideo.cpp -o CaptureVideo \-I /usr/local/include/opencv -L /usr/local/lib \-lm -lcv -lhighgui -lcvaux
我正在使用Ubuntu 12.04。编译时我得到这些错误
"/usr/bin/ld: cannot find -lcv"
"/usr/bin/ld: cannot find -lhighgui"
"/usr/bin/ld: cannot find -lcvaux"
"collect2: ld returned 1 exit status"