External Camera API

7,198 views
Skip to first unread message

Pavel Hud

unread,
Sep 7, 2016, 11:43:31 AM9/7/16
to android-platform
Hi,

I'm looking for the best way to record video using external UVC camera.

I've found 3 solutions:
1) libuvc 
2) video 4 linux
3) External Camera API described here 

I don't like too much 1st and 2nd options:
a) I tested camerafi based on libuvc and app is so unstable, on some devices it doesn't work at all.
b) video 4 linux could require root privileges
c) In both cases it's impossible to use android camera api

External Camera API is most promising option. Due to 

External camera (e.g. USB hot-plug camera) support. The API updates specify that
the camera static info is only available when camera is connected and ready to
use for external hot-plug cameras. Calls to get static info will be invalid
calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks
will only count on device status change callbacks to manage the available external
camera list.

It's possible to communicate with usb camera using camera API. According to sources api available for CAMERA_MODULE_API_VERSION_2_4.
But:
I) I'm not familiar with camera module version system
||) Don't know if external camera support is mandatory for vendors

So my questions are:
1) What is the minimal api level that supports External Camera API?
2) Do all the devices starting from this api level support External Camera API?

Thanks,
Pavel.

saranya gopal

unread,
Sep 7, 2016, 6:53:39 PM9/7/16
to android-...@googlegroups.com

Hi,

I went through android compatibility definition documents and external camera is first mentioned in lollipop CDD.  LENS_FACING_EXTERNAL as a value to LENS_FACING camera characteristic has been added in API level 23. But it is not mandatory for all devices that support API level 23+ to support external cameras. You can check if external camera is supported by querying for camera characteristics and checking for LENS_FACING property of each camera supported in the android device. If any of it equals LENS_FACING_EXTERNAL, then external camera is supported in that device.

Thanks,
Saranya


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platform+unsubscribe@googlegroups.com.
To post to this group, send email to android-platform@googlegroups.com.
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.

Pavel Hud

unread,
Sep 8, 2016, 10:41:22 AM9/8/16
to android-platform

Is there any way to predict if device has such support before buying phone? For example I found https://android.googlesource.com/platform/hardware/qcom/camera/+/android-7.0.0_r4/usbcamcore/inc/, qcom  = qualcomm. Could I expect usb camera support from phones bases on qualcomm SoC?
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.

Philippe Cohen

unread,
Sep 20, 2016, 9:58:51 AM9/20/16
to android-platform
Thanks @Pavel for asking this question, I am also interested into developing an app using external camera.
Hi @Saranya - Did you mean CAMERA_FACING_EXTERNAL ? I did not found any reference to a LENS_FACING_EXTERNAL.

Moreover, I've found in https://android.googlesource.com/platform/hardware/libhardware/+/master/modules/usbcamera/Camera.cpp that the CAMERA_FACING_EXTERNAL is yet to be implemented, as written in the comment in line 144
// TODO: update to CAMERA_FACING_EXTERNAL once the HAL API changes are merged.

so I wonder where exactly this external camera functionality is implemented.

I am confused by what is written in https://source.android.com/devices/camera/versioning.html#module_version. Which version of Android OS does/will implement the Camera module version 2.4. How can developer use the Camera2 API to access usb (UVC) camera? I am really not thrilled to go on the other options @Pavel mentionned. 

Note that in my case I can select the device and can also install Nougat and even root the device is really necessary. Just want to stick to a stable and clean API w/o relying on legacy and unmaintained native code.

Thanks - Philippe 

Pavel Hud

unread,
Sep 21, 2016, 1:24:28 AM9/21/16
to android-platform
Hi!

Also there is a little conversation here https://plus.google.com/+PavelHud/posts/Z37yYqieuhh

blindfold

unread,
Sep 21, 2016, 9:57:09 AM9/21/16
to android-platform
In my experience, none of the hacky ways that exist to tap into or add UVC camera support to Android apps work across all Android devices. It remains hit-and-miss. It is vital that Google adds UVC camera support to a next Android version, much like some vendors (e.g. of Android TV sticks) include their own native UVC camera support under the same existing Android APIs that normally govern built-in cameras. I find it strange that Google is so late with this, because it is important for wearable / augmented reality solutions with dumb camera glasses connected to a smartphone for the heavy-duty processing and for holding the battery weight.

Regards,

Peter


The vOICe for Android
http://www.seeingwithsound.com/android.htm
https://play.google.com/store/apps/details?id=vOICe.vOICe

Lynne Grewe

unread,
Mar 12, 2018, 6:45:15 PM3/12/18
to android-platform
Philippe,

Tried to contact you on another post --- we are a university research group and want to develop android app that grabs video/image frames from USB UVC external video capture card (that gets analog video from RF transmission) --so is the same problem.  Have you had any luck?   Would you mind sharing?
'

Thank you,

Lynne 

Philippe Cohen

unread,
Mar 14, 2018, 9:36:16 AM3/14/18
to android-...@googlegroups.com
Hello Lyne - Sorry for the late reply, I am visiting customers abroad and less on my computer.

I am not working anymore on this project but I will share with you my unsuccessful findings.

1. I never found a way to capture an external camera stream even if there are signs in the source code that someone started to work on that.
2. I’ve switched over to a Sony camera that is delivering the stream to the android device with direct wifi. It worked ok up to the very limited resolution. Per their documentations, some models of the sony wifi cam were capable to stream via wifi higher resolution but never found the way to obtain it.

Following these two failures, I had stop to work on this project and lost the customer that ordered it. I will be glad to help more but not sure I can. Do not hesitate to ask more questions if you think I can…

Good luck on your research - Philippe 

--
You received this message because you are subscribed to a topic in the Google Groups "android-platform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-platform/rqj2SKG7Cx4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-platfo...@googlegroups.com.

Lynne Grewe

unread,
Mar 15, 2018, 10:56:25 AM3/15/18
to android-...@googlegroups.com
Thank you for the response.    The new Android P explicitly advertises supporting this for "devices that support it".  I have been told by Google Store (who knows how reliable this is as I had to go through 4 customer service people before the first claimed to understand the question) that Pixel and Pixel 2 support it and you can install P now on them.  I am trying to get a confirmation from the Android P developer forum (but, no luck yet) before spending the money (we are university research and this project is not funded --so that means my faculty salary).

Wish it was easier to get this information.  I am somewhat surprised with all the drones out-there and custom drones that there are not published solutions out there.

Thanks again,

Lynne

To unsubscribe from this group and all its topics, send an email to android-platform+unsubscribe@googlegroups.com.
To post to this group, send email to android-platform@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "android-platform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-platform/rqj2SKG7Cx4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-platform+unsubscribe@googlegroups.com.
To post to this group, send email to android-platform@googlegroups.com.

satur9nine

unread,
May 31, 2018, 5:54:32 PM5/31/18
to android-platform
Have you tried the https://github.com/saki4510t/UVCCamera project? I was able to get video off a USB camera with this app. Unfortunately this app will not magically make the USB camera show up via the Android APIs. I am investigating how to get the a USB camera HAL up and running.

ali.m...@shield.ai

unread,
Feb 25, 2019, 10:04:42 AM2/25/19
to android-platform
@satur9nine
Did you ever succeed in getting access to usb cameras using the Camera2 api?

-ali

satur9nine

unread,
Mar 21, 2019, 11:21:54 AM3/21/19
to android-platform
Yes I did. It's not clear if you are asking this as an app developer or as a platform developer. I posted comments in https://groups.google.com/forum/#!topic/android-platform/Qx1P0I17uzs describing the modifications I made to our platform build to expose the usb camera through the camera hal which will make it available to apps using the Camera2 APIs.


I had to tweak the setUpCameraOutputs method to choose the external camera, see:

Reply all
Reply to author
Forward
0 new messages