Looking to use an android phone as a camera (via USB)


I've been trying to use an old android phone (Xiaomi Mi3) as a camera for Octoprint. I used the directions provided by https://github.com/foosel/OctoPrint/wiki/Using-an-Android-phone-as-a-webcam

However, the IP Webcam app keeps crashing and is not stable on my phones (tried 2 - an LG-G2 and the Xiaomi Mi3). I was thinking if it would be possible to:

  1. Connect the phone to a raspberry pi using USB (I'm powering / charging my phone through the RasPi USB)
  2. Get image from the camera using ADB.

I'm not sure if this would work, or even how I would make it work. I think such a setup would have the following advantages:

  1. The phone camera will not be on at all times. Agreed, you will not be able to get a video stream in this case, however, I am more interested in creating time-lapses using octolapse. I believe this will also ensure that the phone does not overheat
  2. You would be able to switch on the camera only when needed
  3. You will not need a third-party app

Any help would be appreciated.


The idea is quite slick :+1:

Commands which should achieve what you want:

adb shell "am start -a android.media.action.IMAGE_CAPTURE"
adb shell "input keyevent KEYCODE_FOCUS"
adb shell "input keyevent KEYCODE_CAMERA"

To download the images from your phone use adb pull.