Android Device External Multiple USB Web Cameras(English Version)

android device external multiple usb web cameras design

I translate the article android设备外接多个usb摄像头(Chinese version) into English because a few days ago I found lots of people access this article. I think more people will like it.

Background

The car repairer uses a mini USB camera as an endoscope to repair the car. The endoscope used by the doctor to view the internal organs of the patient. The key is off the Toilet, looking for a waterproof USB camera with a hook (joking), and so on.

Some time ago, I specially studied android devices to connect multiple USB cameras because I was obsessed with doing another thing, at my spare time from searching relative materials, supporting conditions to purchase hardware (camera, smart machine), and finally implementing external connection USB cameras based on an open-source code on GitHub.

The purpose of this article

This article implemented using Xiaomi tablet to connect multiple usb cameras. Xiaomi tablet is a android device like ipad. A application show all usb camera's record at the same time.

  1. Recording, convenient search in the future.
  2. Sharing, convenient more people search.

The requirements

android smartphones
support OTGOTG
support UVC protocol
usb camera
support UVC protocol (most USB camera support UVC)
usb 3+ hub
support OTG
type c convet to usb
support OTG

Devices that I brought

  • A Xiaomi pad (¥999.00)
  • A UGREEN CR109(USB3.0 hub with power, ¥65.00)
  • 4 Aoni G10 USB camera (¥264.00)
  • A UGREEN 30176(Type-c convert to usb port, ¥25.9)

Total money: ¥1353.9

The result

Notice

  1. It's bettter USB hub with power, maybe android device has insufficient power.

Image cannot be displayed

You need release resource that you applied when you deubug.


activity_main.xml

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="50dp"
        android:id="@+id/release"
        android:text="release all cameras"/>
</LinearLayout>

MainActivity.java

protected void onCreate(final Bundle savedInstanceState) {
     // ......
     releaseBtn = (Button)findViewById(R.id.release);
     releaseBtn.setOnClickListener(mReleaseOnClickListener);
     // ......
}
private final OnClickListener mReleaseOnClickListener = new OnClickListener() {
   @Override
   public void onClick(final View view) {
      if (DEBUG) {Log.v(TAG, "camera numbers-->" + mCameras.size());}
      for (final CameraRec rec: mCameras.values()) {
         if (DEBUG) {Log.v(TAG,  "release camera-->" + rec.mCamera.toString()+);}
         rec.release();
      }
   }
};

How do you know whether your android device support UVC protocol

adb shell
cd sys/bus/usb/drivers
ls

If the result show uvcvideo, it means this support UVC protocol.

Android device broadband is not enough

[11019*stream.c:1589: uvc_stream_start_bandwidth]:fail

The maximum that Xiaomi pad can support 2 USB cameras because of bandwidth. If you are interested you could think about through the computer.

If you are interested in this article, please email me. frankshaohua@gmail.com


This article is original, licensed under a Creative Commons Attribution 4.0 International license