Skip to content

Conversation

@ddd999
Copy link

@ddd999 ddd999 commented Jun 10, 2025

This draft PR is a work in progress to address feature request #167 and continues where PR #229 left off. It's incomplete and some parts are likely still broken. Adding the PR now for visibility into the proposed changes and to solicit feedback if there is any.

This reorganizes the camera system into three distinct modes:

  • live streaming (i.e., what exists now)
  • still photo capture (saved locally on the companion computer)
  • local video recording (saved locally on the CC)

It adds a Python helper script to detect all of the camera devices available for still/video capture (get_camera_caps.py), and a backend/server script (photomode.py) that listens for a SIGUSR1 from Rpanion to trigger it to either take a still photo, or to toggle video recording on and off.

By default, photomode.py will use the first available camera supported by Picamera2(). If that's not available, or if a V4l2 device path is specified, it will use V4L2 instead.

To do list (for this PR):

  • Testing and bug fixes as required to make sure all of the above works correctly
  • Confirm that camera service still responds correctly to MAVLink commands
  • Add/update unit tests

To do list for future PR(s):

@stephendade
Copy link
Owner

Great! I'll take a look later in the week

@ddd999 ddd999 force-pushed the photovideo branch 3 times, most recently from aa95364 to 8f97180 Compare June 14, 2025 22:30
- Enables local still image and video recording by re-organizing the camera subsystem into three distinct modes: streaming video (default), still photo capture, and video capture
- Adds Python helper scripts to detect and control cameras for local still/video capture
- Now sends a VideoStreamInformation packet whenever video streaming is started
- Captures a photo or starts/stops video recording either when the button is pressed on the web UI, or when a MavLink MAV_CMD_DO_DIGICAM_CONTROL message is received
- Unit testing and linting fixes
@stephendade
Copy link
Owner

I've had a look through - looks good.

A few issues I came across during testing (on my laptop. Will try a Rpi tomorrow):

  • GUI: Connection strings for video stream are missing in RTSP mode
  • Still Photo mode: bugs out on "No module named 'picamera2'" for photomode.py
  • Camera RTSP address not being sent to MP. Appears cam_definition_uri or CAMERA_INFORMATION is blank. Same for model_name and vendor_name. Resolution is being sent through through
  • Still Photo mode: bugs out on "An error occurred creating directory: [Errno 13] Permission denied: '/home/pi'"

@stephendade
Copy link
Owner

stephendade commented Jun 17, 2025

Testing on the RPI

  • Need to document that python3-opencv package is required
  • Video recording mode on CSI camera. Can't start a new recording. I get:
    [API /togglevideorecording] Received request. Server state: vManager.active=false, vManager.cameraMode=video [API /togglevideorecording] Condition NOT met. Sending 400.

EDIT:
Tested taking still images from MP and worked quite well!

@ddd999
Copy link
Author

ddd999 commented Jun 17, 2025

Thanks for reviewing/testing.

I also found that in streaming mode, streaming mode stopped in the UI, but the video stream didn't actually stop.

This might be a peculiarity (or intentional behaviour?) of Mission Planner: MP only recognizes the stream the first time the VideoStreamInformation message is sent. If you stop the stream, then restart it with the same device, it doesn't recognize the stream again unless you close and restart MP. Could also be related to the aforementioned issue.

Guess there are a few things to work on still!

@stephendade
Copy link
Owner

Yeah, could be an MP-specific thing.

Happy with the overall work on the PR. Keen to get it merged in once we've ironed out the final issues.

@stephendade stephendade force-pushed the master branch 15 times, most recently from 3ce7964 to c083bb7 Compare June 24, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants