-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
How can javacv open the camera in Android? #1692
Comments
There are currently no "AndroidFrameGrabber", but we can already capture video from Java in that case, for example: |
It looks like FFmpeg supports the Android Camera API now: So this kind of code should work: FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("");
grabber.setFormat("android_camera");
grabber.start(); Please let me know if that doesn't work though! Thanks |
@saudet It is giving the exception, Here is the screenshot |
What is the content of the exception? And what does FFmpeg prints out to the log? |
I/System.out: org.bytedeco.javacv.FFmpegFrameGrabber$Exception: av_find_input_format() error: Could not find input format "android_camera". (For more details, make sure FFmpegLogCallback.set() has been called.) |
Could you also provide the information that you get when FFmpegLogCallback.set() has been called? |
I see what the problem is. The Android Camera API that OpenCV and FFmpeg support was introduced first in Android 7.0. Since about 90% of users have Android 7.0 or newer these days, I guess it makes sense to upgrade the minimum requirements. I've done that in commit bytedeco/javacpp-presets@cd28830, so it should now work with both FFmpegFrameGrabber and OpenCVFrameGrabber, which just uses VideoCapture. Please give it a try with the snapshots: http://bytedeco.org/builds/ |
I have extracted jar files, do we have to keep include folder which contains .hpp files? Should I send mail you the whole code with file structure? |
What do you mean? JAR files for snapshots are the same as for releases. Do the same thing as you're used to do. |
I mean, there are jar file files like ffmpeg, openblas, opencv, javacv and javacpp, I have copied in lib folder where as jar files containing .so files of android platform, I have extracted .so files and copied inside jniLibs folder. |
I am sharing my android code folder https://drive.google.com/drive/folders/1N3zgCLJD3DOjV_lW_V8COuxMdgahmPc4?usp=sharing. Please do check |
If you're looking for a working sample project, you can use this one here:
https://github.com/bytedeco/sample-projects/tree/master/JavaCV-android-example
|
@saudet I have already seen this example in which deprecated android.hardware.camera is used. My ques is why can't we use VideoCapture on camera if bytedeco ffmpeg supports android. Please help me out it would be great help. Bytedeco projects really works on desktop amazingly and the project is really really amazing. |
Yes, VideoCapture should also work now with the snapshots. Please let me
know if it doesn't work though.
|
VideoCapture.open function always returns false |
Ok, please try FFmpegFrameGrabber instead. It's usually better than OpenCV for video capture anyway. |
Tried but failed |
What is the error message that you get in the log?
|
I am getting exception |
What is the message of that exception?
|
This should be working now with JavaCV 1.5.7, but please let me know if you're still not able to get this working. Thanks! |
Note: There is a known bug in JavaCV 1.5.7 that prevents this from working smoothly, see issue #1756. We can work around it by calling |
hello, I'm an Android Developer, I'm going to use javacv for live broadcast processing, How can javacv open the camera in Android?
In opencv for Android, it is implements camerabridgeviewbase.cvcameraviewlistener2
The text was updated successfully, but these errors were encountered: