Skip to content

tj3utu009/CamToPhoneUSB

 
 

Repository files navigation

CamToPhoneUSB

Proof of concept

Description

CamToPhoneUSB is an app that tethers a camera to a phone or tablet over USB OTG. After you grant USB permission and connect a supported body in tether or PC Remote mode, it talks to the camera over PTP using libgphoto2. When you take a shot, the app detects new files on the camera, downloads them, and saves them on the device (under PICTURES/USB_IMAGES/). Compatibility varies by camera and mode.

What it does

  1. Connect a supported camera to an Android phone or tablet via USB OTG
  2. Grant USB permission in the app
  3. When you shoot, the app listens for new files over PTP (via libgphoto2)
  4. Downloads images and saves them under PICTURES/USB_IMAGES/

Tested in development with Sony bodies (e.g. Sony in PC Remote mode). Vendor IDs for Sony, Canon, Fujifilm, Panasonic, Nikon, Olympus, Pentax/Ricoh, and Leica are added, but compatibility varies, as it's not tested.

Requirements

  • Android 10+ (API 29+)
  • USB OTG cable or adapter
  • Camera in a USB tether / PC Remote / similar mode (camera-dependent)

Build

The app depends on prebuilt native libraries (libgphoto2 and friends). Build those first on WSL, then build the APK on Windows.

1. Build libgphoto2 for Android (WSL)

WSL cannot use the Windows NDK toolchain directly. The script uses your Linux NDK if available, or downloads the Linux NDK on first run.

Install build tools once:

sudo apt install -y git autoconf automake libtool make pkg-config texinfo help2man unzip curl autopoint

Point out your Windows NDK path (or set ANDROID_NDK_HOME to a Linux NDK), then run:

export ANDROID_NDK_HOME=/mnt/c/Users/YOU/AppData/Local/Android/Sdk/ndk/28.0.13004108
cd /mnt/c/path/to/CamToPhoneUSB
./scripts/build_libgphoto2_android.sh

What the script does:

  • Cross-compiles libtool, libusb, and libgphoto2 (default v2.5.33) for arm64-v8a and armeabi-v7a
  • Applies scripts/patches/libgphoto2-android-usb-open.patch for Android USB file-descriptor support
  • Copies .so files and headers into app/src/main/jniLibs/<abi>/

Intermediate build files go to ~/.gphoto2-android-build when the repo is on /mnt/c (faster than building on the Windows filesystem).

More detail: docs/LIBGPHOTO2_ANDROID.md

2. Build the APK (Windows)

.\gradlew.bat :app:assembleDebug

Output: app/build/outputs/apk/debug/app-debug.apk

Third-party libraries

Camera support comes from dynamically linked native libraries built from upstream sources:

Component License Source
libgphoto2 LGPL-2.1+ Built by scripts/build_libgphoto2_android.sh
libusb LGPL-2.1+ Same script
libltdl (GNU libtool) LGPL-2.1+ Same script

If you ship an APK that includes these .so files, LGPL requires that users can replace them (dynamic linking satisfies this) and that license notices are available. Upstream license texts: libgphoto2 COPYING, libusb COPYING. Any local changes to libgphoto2 are in scripts/patches/.

Not in scope

  • Live view
  • Remote camera settings
  • Wi‑Fi PTP/IP
  • Polished UX or broad device QA

About

CamToPhoneUSB is an app that tethers a camera to a phone or tablet over USB OTG. After you grant USB permission and connect a supported body in tether or PC Remote mode, it talks to the camera over PTP using libgphoto2. When you take a shot, the app detects new files on the camera, downloads them, and saves them on the device.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Kotlin 54.8%
  • C 33.6%
  • Shell 10.0%
  • CMake 1.6%