无法在 android 上使用 Videocapture() 读取视频文件 [英] Can't read a video file using Videocapture() on android

查看:119
本文介绍了无法在 android 上使用 Videocapture() 读取视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 android 新手,对在 android 中使用 opencv 不太了解.我想从存储中读取视频并提取帧,但无法读取视频.我使用了视频捕捉,但它总是显示失败.这是我正在使用的代码片段.视频文件路径为/storage/emulated/0/Android/data/demoVid/Demo.avi.文件大小为 250MB

I'm new to android and don't have much knowledge about using opencv in android. I want to read a video from storage and extract the frames but I can't read the video. I used videocapture but it is always showing failed. Here is the code snippet I'm using. The video file path is /storage/emulated/0/Android/data/demoVid/Demo.avi. The file size is 250MB

        VideoCapture cap = new VideoCapture();
//        cap.open(vpath.toString());
        cap.open(imFile);
        Mat frame = new Mat();
        int framecount = 0;

        if(cap.isOpened()){
            Log.d("VideoCapture","Videocapture successful");
        }
        else
        {
            Log.d("VideoCapture","Videocapture failed");
        }

推荐答案

所以基本上我只是想使用 opencv 的 videocapture 在 android 中读取视频文件.我使用的是 opencv 3.4.10 版,它给出了找不到文件的错误.我尝试更改路径并检查路径是否正确定义,但仍然无法读取文件.在浪费了很多时间之后,我升级到了 opencv 4.5.0 版(升级以获得 sift 功能)并且我的问题在相同的代码上得到了解决.所以也许一些旧版本的 opencv 不支持视频捕捉.另外我想提一下,我从视频捕获中读取的帧需要很多时间,因此我无法获得实时体验.

So basically I just wanted to read a video file in android using videocapture of opencv. I was using opencv version 3.4.10 which was giving error of file not found. I tried to change paths and checked if the path was properly defined but still couldn't read the file. After wasting a lot of time on it I upgraded to opencv version 4.5.0 (upgraded to get sift features) and my issue was resolved for the same code. So maybe some older versions opencv don't support videocapture. Also I would like to mention that the frames I read from the videocapture take a lot of time due to which I wasn't able to get a real-time experience.

这篇关于无法在 android 上使用 Videocapture() 读取视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆