Skip to content

Support network cameras such as Android DroidCam via --device - #90

Open
gunicsba wants to merge 1 commit into
TheMariday:mainfrom
gunicsba:droidcam-network-camera
Open

gunicsba wants to merge 1 commit into
TheMariday:mainfrom
gunicsba:droidcam-network-camera

Conversation

@gunicsba

Copy link
Copy Markdown

--device now also takes the address of a network camera, so an Android phone running DroidCam can be used without installing a PC client:

marimapper_check_camera --device 192.168.1.20:4747

What changes

  • --device accepts a camera index (as before), host[:port][/path], or a full http:// / rtsp:// URL.
    • A bare host or host:port is treated as DroidCam: the port defaults to 4747 and the stream is http://<host>:<port>/video. A path can be added to override that.
    • Anything that is neither an index nor an address is rejected by argparse with a clear message.
  • Network streams are opened with the FFmpeg backend, with a 5 second open/read timeout and a one-frame buffer. Without the timeout an unreachable address blocks for a long time. The OpenCV build is checked for FFmpeg, and CAP_ANY is used if it is missing.
  • Camera itself still accepts whatever it accepted before (indexes, file paths, image sequences), so nothing about the existing code paths changes. The address parsing lives in the argparse type.
  • Exposure, focus and gain can't be set over a network stream. The existing "failed to set exposure" warning already covers this, and I added one line pointing at the camera app's own settings. The README says the same.

Testing

  • Added unit tests for the address forms (and for rejecting bad input), an end-to-end test that reads frames from a local MJPEG server behaving like the DroidCam app, and a test that an unreachable address raises RuntimeError. All 20 tests in test_camera.py pass, including the existing ones.
  • flake8 . is clean, and black --check is clean on the files I touched. The newest black also wants to reformat four other files, which I left alone.
  • Tried on a real phone (DroidCam on Android over WiFi): the stream connects in about half a second at 1280x720, 30 fps, and marimapper_check_camera --device <phone ip>:4747 detects an LED held up to the camera.

Notes

  • The /video path and the default port come from how DroidCam is used with OpenCV in practice; I couldn't find an official DroidCam page for them.
  • Because exposure can't be controlled, the room has to be dark enough on its own (or the exposure lowered in the camera app) for LED detection to work. Software darkening, like the dark frame subtraction in Dark frame subtraction #63, would help network cameras too, but that's a separate change.

🤖 Generated with Claude Code

--device now also accepts the address of a network camera, so an Android phone
running DroidCam can be used without a PC client:

    marimapper_check_camera --device 192.168.1.20:4747

A bare host or host:port is treated as DroidCam (default port 4747, stream path
/video); a path can be added, and full http:// or rtsp:// URLs are passed through.
Plain camera indexes work exactly as before.

Network streams are opened with the FFmpeg backend with a 5 second open/read
timeout (an unreachable address used to block for far longer) and a one frame
buffer. Exposure and focus can't be set over a network stream; the existing
"failed to set exposure" warning covers that.

Tests parse the address forms and read frames from a local MJPEG server that
behaves like the DroidCam app.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gunicsba
gunicsba marked this pull request as ready for review October 19, 2026 10:08
@TheMariday TheMariday added the new feature New feature or request that isn't a backend or export format label Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request that isn't a backend or export format

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants