0

我正在为初学者构建一个带有 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。我错过了什么?

4

1 回答 1

1

问题是我的错...窗口标识符设置错误。它应该是“example3”而不是“movieWindow”。

于 2013-09-18T11:40:59.273 回答