Skip to content

Video: Add local still image and video recording#295

Open
ddd999 wants to merge 1 commit intostephendade:masterfrom
ddd999:photovideo
Open

Video: Add local still image and video recording#295
ddd999 wants to merge 1 commit intostephendade:masterfrom
ddd999:photovideo

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 (photovideo.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, photovideo.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 4 times, most recently from 1eed373 to 2459aac Compare June 14, 2025 22:39
@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
@ddd999 ddd999 force-pushed the photovideo branch 2 times, most recently from 9dbb182 to fdc1d50 Compare January 11, 2026 05:18
@ddd999 ddd999 force-pushed the photovideo branch 3 times, most recently from d582479 to b8b47dd Compare January 23, 2026 05:08
@ddd999 ddd999 force-pushed the photovideo branch 16 times, most recently from e7bb842 to 9c0208e Compare January 26, 2026 04:28
@ddd999
Copy link
Author

ddd999 commented Jan 26, 2026

Great! I think something went a bit wrong with your rebasing - there's a number of not-applicable or odd whitespace changes.

VSCode auto-formatting strikes again, sorry about that. I think it's fixed now.

@stephendade
Copy link
Owner

Looking better. There's still some changes in package-lock.json that should be removed, as your PR didn't add/remove any npm packages. The ./src/video.jsx file needs to be cleaned up a bit more too.

@ddd999 ddd999 force-pushed the photovideo branch 5 times, most recently from c6a09c7 to d39b375 Compare January 28, 2026 06:16
@stephendade
Copy link
Owner

The merge issues look resolved now, so I'll run some tests on the PR early next week.

@ddd999
Copy link
Author

ddd999 commented Jan 31, 2026

The merge issues look resolved now, so I'll run some tests on the PR early next week.

Thanks, I was going to double check the code before replying as I thought there were still some unnecessary formatting changes in src/video.jsx but if you're good with the current state I'll let it be for now.

I've tested on my Pi Zero 2W with the CSI camera and with a USB web cam and both seemed to work as expected.

Copy link
Owner

@stephendade stephendade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good!

A few small things to change:

  • Web GUI: Under photo mode, a CSI camera comes up as "Unnamed CSI camera" instead of it's actual model
  • Web GUI: Add a confirmation message when picture taken with "Take Photo" Same with stop video.
  • Web GUI: Add photo&video folder to "Flight Logs" page for easy download. Add a note to Photo&Video page about this
  • Add ./media folder to .gitignore

onChange={this.handleCameraModeChange}
checked={isStreaming}
/>
<Form.Check
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disable Photo/Video GUI elements if not running in RPi and picamera2 not installed

- 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
- Geotagging: Writes GPS position information (if available) to EXIF metadata of photos-
- Adds media file management to the flight log browser page
@ddd999
Copy link
Author

ddd999 commented Feb 10, 2026

  • Web GUI: Under photo mode, a CSI camera comes up as "Unnamed CSI camera" instead of it's actual model Fixed, get_camera_caps.py now uses libcamera to get the actual device names
  • Web GUI: Add a confirmation message when picture taken with "Take Photo" Same with stop video. Added notifications that show the filename as well as if video recording is in progress
  • Web GUI: Add photo&video folder to "Flight Logs" page for easy download. Add a note to Photo&Video page about this Added
  • Add ./media folder to .gitignore Done

Still need to add this:

  • Disable Photo/Video GUI elements if not running in RPi and picamera2 not installed
    and look into/update the tests that are failing

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