我正在为初学者构建一个带有 openCV 书的应用程序。这是main.m
文件的代码:
#include <iostream>
#include <opencv2/opencv.hpp>
int g_slider_position = 0;
CvCapture *g_capture = NULL;
void onTrackBarSlide(int pos){
cvSetCaptureProperty(g_capture,CV_CAP_PROP_POS_FRAMES,pos);
}
int main(int argc, const char * argv[])
{
cvNamedWindow("example3",CV_WINDOW_AUTOSIZE);
g_capture = cvCreateFileCapture("/Users/orazran/Desktop/android/sdk/extras/android/support/samples/Support 4Demos/res/raw/videoviewdemo.mp4");
int frames = (int) cvGetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_COUNT);
printf("%d",frames);
if (frames != 0) {
cvCreateTrackbar("trackBar", "example3", &g_slider_position,frames,onTrackBarSlide);
}
IplImage *frame;
while (1) {
frame = cvQueryFrame(g_capture);
if (!frame) break;
cvShowImage("movieWindow", frame);
char c = cvWaitKey(33);
if (c == 27) break;
}
cvReleaseCapture(&g_capture);
cvDestroyWindow("movieWindow");
}
电影播放得很好,但我看不到 trackBar。我错过了什么?