gpt4 book ai didi

ios - iOS中cvWaitKey()函数的替代方法

转载 作者:行者123 更新时间:2023-12-02 16:42:35 25 4
gpt4 key购买 nike

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

实际发生的情况是它写了一些帧,然后由于代码非常快而崩溃,
如果我不放cvWaitKey(),则在没有使用AVFoundation Library编写视频帧时会遇到相同的错误

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
}
}

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.

最佳答案

重新绘制UIImageView:

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

后跟您的 imshowcvShowImage

关于ios - iOS中cvWaitKey()函数的替代方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12125950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com