1

好的,我想做的是从现有视频文件中检索帧,对帧进行一些工作,然后将其保存到新文件中,

实际发生的是它写入一些帧然后崩溃,因为代码非常快,如果我不输入 cvWaitKey(),我会得到与使用 AVFoundation 库编写视频帧而不使用时相同的错误

AVAssetWriterInput.readyForMoreMediaData

OpenCV 视频编写器是使用 AVFoundation 类实现的,但我们无法访问

AVAssetWriterInput.readyForMoreMediaData

还是我错过了什么?

这是类似于我正在尝试做的代码,

while (grabResult&&frameResult) {

        grabResult = cvGrabFrame(capture);          // capture a frame
        if(grabResult){
            img = cvRetrieveFrame(capture, 0);  // retrieve the captured frame
            cvFlip(img,NULL,0);                 // edit img
            frameResult = cvWriteFrame(writer,img);      // add the frame to the file
            cvWaitKey(-1); or anything that helps to finish adding the previous frame
        }
    }

我正在尝试在我的 iPhone/iPad 应用程序中使用 OpenCV(不显示)转换视频文件,除了 cvWaitKey() 函数之外一切正常,我收到此错误:

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvWaitKey,

如果没有此功能,将丢弃帧,因为无法知道视频编写器是否已准备好,是否有替代我的问题的方法?

我正在使用 OpenCV 2.4.2,并且在最新的 OpenCV 预编译版本中出现同样的错误。

4

2 回答 2

0

我对iOS开发一无所知,但是您是否尝试过调用C++接口方法waitKey()

于 2012-08-26T21:36:13.807 回答
0

重绘UIImageView

[[NSRunLoop currentRunLoop]runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.0f]];

其次是你的imshowcvShowImage

于 2016-06-07T12:08:49.770 回答