我正在尝试在Xcode中运行以下程序;
#include <stdio.h>
#include <stdlib.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
int TrackbarInitValue = 0;
int TrackbarStopValue;
CvCapture *capture = NULL;
IplImage *frame;
void onTrackbarSlide(int position)
{
cvSetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES, position);
// cvShowImage("Trackbar", frame);
}
int main(int argc, char **argv)
{
cvNamedWindow("Trackbar", CV_WINDOW_AUTOSIZE);
if(argc < 2)
{
printf("Please specify the video name n");
exit(0);
}
capture = cvCreateFileCapture(argv[1]);
TrackbarStopValue = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
if(TrackbarStopValue != 0)
{
cvCreateTrackbar("Position", "Trackbar", &TrackbarInitValue, TrackbarStopValue, onTrackbarSlide);
}
while(1)
{
frame = cvQueryFrame(capture);
if(!frame) break;
int pos = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES);
cvSetTrackbarPos("Position", "Trackbar", pos);
cvShowImage("Trackbar", frame);
char c = cvWaitKey(33);
if( c == 27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Trackbar");
return 0;
}
当我尝试构建时,我会收到以下错误;
Ld build/Debug/TrackBarPlayer normal x86_64
cd "/Users/facebooth/C++ practice/OpenCV Practice/TrackBarPlayer"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/g++-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk "-L/Users/facebooth/C++ practice/OpenCV Practice/TrackBarPlayer/build/Debug" -L/opt/local/lib "-F/Users/facebooth/C++ practice/OpenCV Practice/TrackBarPlayer/build/Debug" -filelist "/Users/facebooth/C++ practice/OpenCV Practice/TrackBarPlayer/build/TrackBarPlayer.build/Debug/TrackBarPlayer.build/Objects-normal/x86_64/TrackBarPlayer.LinkFileList" -mmacosx-version-min=10.6 -o "/Users/facebooth/C++ practice/OpenCV Practice/TrackBarPlayer/build/Debug/TrackBarPlayer"
Undefined symbols:
"_cvCreateFileCapture", referenced from:
_main in main.o
"_cvSetCaptureProperty", referenced from:
onTrackbarSlide(int) in main.o
"_cvNamedWindow", referenced from:
_main in main.o
"_cvSetTrackbarPos", referenced from:
_main in main.o
"_cvCreateTrackbar", referenced from:
_main in main.o
"_cvShowImage", referenced from:
_main in main.o
"_cvQueryFrame", referenced from:
_main in main.o
"_cvDestroyWindow", referenced from:
_main in main.o
"_cvReleaseCapture", referenced from:
_main in main.o
"_cvWaitKey", referenced from:
_main in main.o
"_cvGetCaptureProperty", referenced from:
_main in main.o
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
我是一个完整的编程新手,经过几个小时的谷歌搜索,我发现的只是一个链接问题。如果有人能给我一些如何解决它的指导,或者这些错误实际上是什么,那将非常感激。
答案 0 :(得分:-1)
链接libopencv_videoio.3.2.6.dylib