Use UVCCamera Library for Android

  1. Clone UVCCamera library. Make modifications if necessary.
  2. Run Gradle assembleRelease tasks to build libuvccamera-release.aar and usbCameraCommon-release.aar
  3. Clone libcommon. Make modifications if necessary.
  4. Run Grade assembleRelease task to build common-release.aar
  5. In Android app project, create directory libs under directory app.
  6. Add libuvccamera-release.aar, usbCameraCommon-release.aar and common-release.aar to libs.
  7. In build.gradel, add the following to dependences:
          implementation files('libs/androidLibrary-release.aar')
        implementation files('libs/common-release.aar')
        implementation files('libs/libuvccamera-release.aar')
        implementation files('libs/usbCameraCommon-release.aar')
        implementation files('libs/ZistosUSBCamera-release.aar')
  8. Add the following to the activity using USB camera in AndroidManifest.xml:
               <intent-filter>

                    <!-- for USB devices -->
                    <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
                </intent-filter>

                <meta-data
                    android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
                    android:resource="@xml/usb_camera_device_filter" />
  9. Add file usb_camera_device_filter.xml under directory xml
  10. Add android.permission.CAMERA related code in AndroidManifest.xml and java file.

This article was updated on 19:50:48 2024-12-29