I'm trying to make an android app that preview a stream from an external USB camera.
I can see the camera using UsbManager but for some reason, the CameraX doesn't list it in the connected camera list.
Does anyone have an idea how to fix this?
Also, I've downloaded for my android device some random app that allows streaming from a USB camera and it worked so I don't think it is a problem that the camera isn't compatible to work with an android device or something like that.
afaik CameraX doesn't support UVC cameras yet/still and Android doesn't provide a driver... for Android system UVC camera is just "some USB" device (as you noticed - handled by UsbManager) and you need to provide a driver by self...
so you can use some other libraries for getting UVC video, probably currently best is AndroidUSBCamera by jiangdongguo
Related
Requirement:-
I have to make a android accessibility service application which take camera frames through any USB Camera Device.
Camera should be always turn on.
Try to use camera2 Api to connect with external camera device but I don't get reference.
https://source.android.com/docs/core/camera/external-usb-cameras
I followed this article but I am not able to find location of file where to edit these settings.
Now I am trying to edit
https://github.com/saki4510t/UVCCamera
This code?
But still I am not success.
will any one guide me to how to do that?
thanks
I'm trying to preview an external ZED stereo camera that's connected to an android phone using the Camera2 api.
https://www.stereolabs.com/zed/
This camera is UVC compliant and I have been able to preview it when I connected it to an android oreo 8.0 vm running on virtual box.
I'm using the code in google's sample project https://github.com/googlesamples/android-Camera2Basic. The CameraManager class provides a getCameraIdList() which is supposed to return the ids of all the cameras connected to the device, like the front facing, back facing or external facing (in this case it should have been my ZED cam or any other external webcam) camera.
When i run the sample on virtual box the external camera seems to be detected as a back facing camera.
CameraCharacteristics characteristics
= manager.getCameraCharacteristics(cameraId);
Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
String[] cameras = new String[] {"FRONT", "BACK", "EXTERNAL"};
Log.v(TAG, "Camera faces " + cameras[facing]);
The external ZED cam always shows as a back facing camera. When i try to run the apk on an android phone with the ZED cam connected to the USB C interface, It simply does not detect the web cam at all.
In fact I ran the app USB Device Info on the phone when the cam was connected and it showed up as a video device
I then ran the app Camera2 Api Probe which probes for cameras and all their supported characteristics using the camera2 api on the phone and it only listed the front and back facing cams that are part of my phone. It didn't list the external camera.
I tried this with a Samsung A7 (2017), a One Plus and an Honor all running andoird Oreo 8.0. None of then could list the external facing camera but all of them showed the usb device as connected and a video device with the name ZED.
I have no idea why they don't show up. How do i get external cameras to list using the camera2 api?
I initially tried projects that use JNI bindings to native code that uses libuvc like this one . But the frame rates seem to be too slow. But right now I'm focused on getting the preview using the camera2 api.
FYI: I suspected that the camera might not be receiving enough power. So i connected the camera using a Trancend USB 3.0 hub with an external power supply that can power connected usb devices. The results were the same.
Just to be clear, when using the vbox emulator the external device is listed as a back facing camera. When using Genymotion I have to use it's camera widget to set the connected ZED cam to either the back or front facing camera and then it lists.
Okay, I just got a new Moto z2 play and decided to try and learn the Android Camera2 api using it... The phone is not rooted, and the stock camera app has the option to record slow motion videos and have manual focus during photos... But when I probe the CameraCharacteristics using the Camera2 api, it shows me a LEGACY hardware level device, with no support for high fps recording nor manual sensor control... I've read in the internet that build.prop can be edited so that the device reports the full supported capabilities... But to my understanding, if those capabilities were not supported by default, it wouldn't be possible for stock camera app to show them, right...? So, what's going on? Is there some caveat I'm missing?
The stock camera app likely has custom interfaces to use those features, built on top of the legacy camera HAL.
Unfortunately, the standard camera2 API cannot run on top of the legacy HAL besides in LEGACY mode, because there's no way to automatically hook into custom OEM additions to the legacy HAL.
So there's likely nothing you can do here to enable these features in your own app; Motorola would have to update their entire camera stack to expose a modern camera HAL for camera2 to work better.
I am creating an application that connects to the phone camera from native code.
This works great on my phone.
The problem is that when i try to do the same thing with android emulator, there is
no "/dev/video" to connect to (i know the camera is connected because i am able to open it
using the camera app).
Does anyone know if there is another way i can connect to the camera from native code?
/dev/video0 is, in terms of Android, an implementation detail, and not guaranteed to be present on any device or emulator.
Emulator support for camera is very limited, see for example Android webcam enable in emulator
There is no official native camera API on Android, so there's no guaranteed to work way of doing this.
For maximum compatibility, use the Java API and send the image data to native code for processing, if necessary.
Can I emulate camera flash with Android emulator? I wasn't able to find anything flash-related in the settings.
Flash is manipulated via camera object by setting flash mode before taking picture
or preview. Emulator will allow you to do this. But I found flash behaviour extremely inconsistent across different devices.
Real camera applications use undocumented native apis which are specific for phone and camera models.