How to realize external USB camera with Android
This article mainly explains "how to achieve an external USB camera in Android". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve an external USB camera in Android".
Realize
The system must support android.hardware.usb.host
Declaration that host needs to be added under / system/etc/permissions
In addition, the UVC device kernel for Kernel must be enabled.
+ CONFIG_USB_VIDEO_CLASS=y
+ CONFIG_MEDIA_USB_SUPPORT=y
To enable the external camera provider in the appropriate device breakdown version to add the necessary SELinux permissions, external camera configuration, and external camera provider dependencies, complete the following steps:
Add external camera profile and external camera library to device.mk.
+ PRODUCT_PACKAGES + = android.hardware.camera.provider@2.4-impl
+ PRODUCT_PACKAGES + = android.hardware.camera.provider@2.4-external-service
+ PRODUCT_COPY_FILES + =
+ device/manufacturerX/productY/external_camera_config.xml:$ (TARGET_COPY_OUT_VENDOR) / etc/external_camera_config.xml
Add the external camera provider name to the device Treble HAL inventory.
Android.hardware.camera.provider
Passthrough
2.4
ICameraProvider
Legacy/0
+ external/0
(optional) if the device is running in Treble pass-through mode, update sepolicy so that cameraserver can access the UVC camera.
+ # for external camera
+ allow cameraserver device:dir r_dir_perms
+ allow cameraserver video_device:dir r_dir_perms
+ allow cameraserver video_device:chr_file rw_file_perms
Example of external_camera_config.xml
0 1
You can customize the external camera provider by modifying the external_camera_config.xml file. Specifically, the customer can customize the following parameters:
Exclude video nodes for internal cameras
Supported picture size and frame rate limit
Number of Inflight buffers (tradeoff between stutter and memory)
In addition to these parameters, you can add your own parameters or develop your own configuration.
Thank you for your reading. the above is the content of "how to achieve an external USB camera in Android". After the study of this article, I believe you have a deeper understanding of how to implement an external USB camera in Android, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!