Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencv_videostab.IFrameSource needs opencv_videoio.VideoCapture #277

Closed
androiddevaccnt7 opened this issue Nov 15, 2015 · 6 comments
Closed

Comments

@androiddevaccnt7
Copy link

Is this supported on the Android platform?

I'm trying to use VideoFileSource in opencv_videostab, but it is unable to open a file.

E/AndroidRuntime: java.lang.RuntimeException: /home/saudet/projects/bytedeco/javacpp-presets/opencv/cppbuild/android-arm/opencv-3.0.0/modules/videostab/src/frame_source.cpp:71: error: (0) can't open file: /storage/emulated/0/Download/file_sample.mp4 in function virtual void cv::videostab::{anonymous}::VideoFileSourceImpl::reset()

I've done some research and found some discussion that opencv may not have the backend required for this without FFmpeg. But I already have FFmpeg in my project. Is there any way to make this work?

@saudet
Copy link
Member

saudet commented Nov 16, 2015

You could rebuild OpenCV with support for FFmpeg, but it doesn't usually work very well anyway. Anything wrong with FFmpegFrameGrabber?

@androiddevaccnt7
Copy link
Author

hey saudet - thanks for the reply and all the great work here.

The videostab Stabilizers require an opencv_videostab.IFrameSource. The only one of these built-in - VideoFileSource - uses VideoCapture.

FrameGrabber gets me the frames, but not in a way I can use with video_stab. I'm beginning to think my best approach may be to add and rebuild with a new IFrameSource which can be created from a list of existing frames.

Does that seem like a reasonable approach? I can't see anyway the videostab module can be used out of the box without VideoCapture support.

saudet added a commit to bytedeco/javacpp-presets that referenced this issue Nov 16, 2015
@saudet
Copy link
Member

saudet commented Nov 16, 2015

We can implement our own IFrameSource in Java, but to do so, it would have to be "virtualized"... something I neglected to do. I've done so in the commit above. Enjoy! :)

@saudet saudet changed the title opencv_videoio.VideoCapture and Android opencv_videostab.IFrameSource needs opencv_videoio.VideoCapture Nov 16, 2015
@androiddevaccnt7
Copy link
Author

Thanks @saudet, that should open up this api for me. I had a problem compiling the latest snapshot including that change (), but could compile the 1.1 release without issue. I attempted to apply only the commit linked above and rebuild, when I ran into the following errors during the step "Compiling ..../libjniopencv_videostab.so":

/home/javacpp-presets-1.1/opencv/target/classes/org/bytedeco/javacpp/jniopencv_videostab.cpp: In function '_jobject* Java_org_bytedeco_javacpp_opencv_1videostab_00024IFrameSource_nextFrame(JNIEnv, jobject)':
/home/javacpp-presets-1.1/opencv/target/classes/org/bytedeco/javacpp/jniopencv_videostab.cpp:8374:20: error: expected type-specifier before 'JavaCPP__0003a_0003acv_0003a_0003aMat'
rptr = new JavaCPP__0003a_0003acv_0003a_0003aMat((dynamic_cast<JavaCPP__0003a_0003acv_0003a_0003avideostab_0003a_0003aIFrameSource>(ptr) != NULL ? ((JavaCPP__0003a_0003acv_0003a_0003avideostab_0003a_0003aIFrameSource)ptr)->super_nextFrame() : ptr->nextFrame()));
^
/home/javacpp-presets-1.1/opencv/target/classes/org/bytedeco/javacpp/jniopencv_videostab.cpp:8382:15: error: 'JavaCPP__0003a_0003acv_0003a_0003aMat' was not declared in this scope
((JavaCPP__0003a_0003acv_0003a_0003aMat))rptr->obj = env->NewWeakGlobalRef(rarg);
^
/home/javacpp-presets-1.1/opencv/target/classes/org/bytedeco/javacpp/jniopencv_videostab.cpp:8382:53: error: expected primary-expression before ')' token
((JavaCPP__0003a_0003acv_0003a_0003aMat*))rptr->obj = env->NewWeakGlobalRef(rarg);

Seems to be related to the above change, trying to figure out whats wrong see if I maybe need an additional commit since 1.1.

@saudet
Copy link
Member

saudet commented Nov 19, 2015

Yes, there was a bug in JavaCPP. Be sure to get the latest changes for that module as well.

@saudet
Copy link
Member

saudet commented May 19, 2016

The changes are in JavaCV 1.2. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants