2012-08-25 29 views
1

OK功能,我所试图做的是从现存的视频文件的框架,做在框架上的一些工作,然后将其保存到一个新的文件,替代cvWaitKey()在iOS中

究竟是什么碰巧的是,它写一些帧,然后崩溃的代码是相当快的,如果 我不把cvWaitKey()我得到了同样的错误,而无需使用

AVAssetWriterInput.readyForMoreMediaData 

写作与AVFoundation库中的视频帧当我得到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 
     } 
    } 

I am trying to convert a video file using OpenCV (without displaying) in my iPhone/iPad app, everything works except cvWaitKey() function and I get this error:

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, 

Without this function frames are dropped as there's no way to know if the video writer is ready, is there an alternative to my problem?

I am using OpenCV 2.4.2 and I get same error with the latest precompiled version of OpenCV.

回答

0

我不知道iOS开发任何东西,但你尝试调用C++接口方法waitKey()

0

重绘UIImageView

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

后跟您imshowcvShowImage