[英]Android : How can I open a file using OpenCV C++ ?
I have a video file saved on my Android device. 我的Android设备上保存了一个视频文件。
Using a getPath()
function I got "sdcard/video_app/sample_video.mp4". 使用getPath()
函数我得到了“sdcard / video_app / sample_video.mp4”。
I'm now trying to use this video file in my OpenCV C++ code (I'm using NDK and JNI) with this : 我现在正试图在我的OpenCV C ++代码中使用这个视频文件(我正在使用NDK和JNI):
String filename = "sdcard/video_app/sample_video.mp4";
VideoCapture capture(filename);
Mat img;
capture >> img;
imwrite("sdcard/video_app/test.jpg", img);
I added : 我补充说:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Nothing is happening. 什么都没发生。 What am I doing wrong ? 我究竟做错了什么 ?
You can try, 你可以试试,
VideoCapture capture=new VideoCapture();
capture.open("sdcard/video_app/sample_video.mp4");
Mat frames = new Mat();
// to read each frame and to save in Mat class
for(;;)
{
capture.read(frames);
imwrite("sdcard/video_app/test.jpg",frame);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.