OpenCV videoCapture为iOS应用程序文档目录中的文件提供了错误的属性

本·卡彭特

我正在开发一个录制视频的iOS应用,然后对该视频进行一些处理以创建另一个视频文件。我从videoCapture中得到了非常奇怪的行为。它的行为就像文件已打开,但是get()调用似乎针对我关心的所有属性返回1(而且我知道它们不是1)。我的代码如下所示:

VideoCapture cap(fileIn); // open the video file for reading

if ( !cap.isOpened() )  // if not success, exit program
  {
    cout << "Cannot open the video file" << endl;
    return -1;
  }
  else{
    cout << "File Open " << fileIn << endl;
  }

  double dFps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
  cout << "Frames per second = " << dFps << endl;

  double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
  double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
  cout << "Frame Size = " << dWidth << "x" << dHeight << endl;

  Size frameSize(static_cast<int>(dWidth), static_cast<int>(dHeight));

  double dFrameCount = cap.get(CV_CAP_PROP_FRAME_COUNT);
  cout << "Frame count = " << dFrameCount << endl;

  VideoWriter oVideoWriter (fileOut, CV_FOURCC('m','p', '4', 'v'), dFps, frameSize, true); //initialize the VideoWriter object

  if ( !oVideoWriter.isOpened() ) //if not initialize the VideoWriter successfully, exit the program
  {
    cout << "ERROR: Failed to write the video" << endl;
    return -1;
  }
  else{
    cout << "Output file open." << endl;
  }

控制台输出为:

File Open /var/mobile/Containers/Data/Application/7CEE8B87-BD50-4172-8F62-A74AD7F3C45A/Documents/15318B74-07D9-43EE-932F-224EDCA9CDA7.mov
Frames per second = 1
Frame Size = 1x1
Frame count = 1
Output file open.

我尝试将文件路径更改为无效文件,以防根本找不到该文件,但这使我“无法打开视频文件”。任何想法,将不胜感激。我认为这可能是权限问题,因为当我尝试使用此代码访问相机胶卷中的视频时看到了类似的行为,但是此文件位于我应用程序的文档目录中,因此我应该具有完全访问权限。

本·卡彭特

看来,至少在过去两年中这一直是一个问题(iOS上的OpenCV-VideoCapture属性始终返回1),而iOS版本的videocapture根本无法打开文件。

我找到了另一种方法(使用苹果api打开视频,然后将每个帧转换为opencv Mat),但总的来说,似乎opencv的iOS端口还很不完善,几乎完全没有记载。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

OpenCV iOS中的VideoCapture与OpenCV C ++

来自分类Dev

应用程序文档目录中的空文件

来自分类Dev

with()语句从opencv中的VideoCapture读取?

来自分类Dev

VideoCapture对象在OpenCV中的状态

来自分类Dev

在OpenCV中替代VideoCapture :: set

来自分类Dev

Opencv videoCapture()中的Gstreamer管道

来自分类Dev

OpenCV VideoCapture 问题

来自分类Dev

xCode:从应用程序文档目录中检索图像

来自分类Dev

在OpenCV中应用遮罩

来自分类Dev

Python / OpenCV应用程序锁定问题

来自分类Dev

播放iOS中从应用程序文档文件夹下载的Widevine Classic文件?

来自分类Dev

jhipster应用程序文件在错误的目录中生成

来自分类Dev

可可应用程序(OS X App)中的OpenCV

来自分类Dev

可可应用程序(OS X App)中的OpenCV

来自分类Dev

OpenCV 文档检测修复

来自分类Dev

OpenCV 3.0 VideoCapture无法在Java中打开视频文件

来自分类Dev

如何:带文件的Android OpenCV VideoCapture

来自分类Dev

如何:带文件的Android OpenCV VideoCapture

来自分类Dev

如何从OpenCV中的目录顺序读取文件?

来自分类Dev

在spyder中访问OpenCV文档

来自分类Dev

使用OpenCv应用灰度

来自分类Dev

为 iOS 构建 OpenCV 失败

来自分类Dev

在Python中从VideoCapture opencv获取特定帧

来自分类Dev

在OpenCV中,什么是VideoCapture析构函数

来自分类Dev

OpenCV SURF类错误

来自分类Dev

OpenCV错误使用逆

来自分类Dev

OpenCV复制断言错误

来自分类Dev

OpenCV相机显示错误

来自分类Dev

自制+ opencv + libpng错误