iOS上的OpenCV – VideoCapture属性始终返回1
我一直在尝试构建一个简单的OpenCV(iOS)应用程序,该应用程序从包中加载video并查询其帧数,持续时间等,然后它将尝试从中获取单个帧。 不幸的是,当我使用VideoCapture
类时,所有属性都返回值1.然后我尝试导航到frame #100
但这也不起作用。 我这样做是错误的吗?
cv::VideoCapture capture([[movieURL path] UTF8String]); if (!capture.isOpened()) { Log(@"Could not open the video:%@", [movieURL path]); } double rate = capture.get(CV_CAP_PROP_FPS); cv::Mat frame; //current video frame //Delay between each frame in ms //corresponds to video frame rate int delay = 1000/rate; long numOfFrames = static_cast(capture.get(CV_CAP_PROP_FRAME_COUNT)); Log(@"Video Frame rate:%f, delay:%d, numOfFrames:%ld", rate, delay, numOfFrames); double position = 100.0; capture.set(CV_CAP_PROP_POS_FRAMES, position); long frameNum = static_cast(capture.get(CV_CAP_PROP_POS_MSEC)); Log(@"Moved to Frame 100. Getting frame number:%ld", frameNum);