Raspivid camera trigger and raspistill

Hello everyone and developers

2 questions.

First to Ivan and the team. Since the Navio works with raspberry pi. Would it not be worthwhile letting the Navio2 have access to the raspicam in order to use it with the ardupilot camera trigger function?

Secondly. Does any one know how to take a photo of the raspivid video stream while the stream is running?

Hi

It is not possible to launch raspistill while raspivid is running.

But there is a recipe in picamera docs for capturing images whilst recording video.
Thus you need to write python script to configure camera and record video with snapshots.

In addition I suggest to start gstreamer process like this:

import subprocess

gstreamer = subprocess.Popen([
    'gst-launch-1.0', '-v',
    'fdsrc',
    '!', 'h264parse',
    '!', 'rtph264pay', 'config-interval=10', 'pt=96',
    '!', 'udpsink', 'host=IP_ADDRESS', 'port=9000'
    ], stdin=subprocess.PIPE)

Then init camera and record video to gstreamer’s stdin:


camera = picamera.PiCamera(resolution=(1280, 720), framerate=15)
camera.hflip = True

camera.start_recording(gstreamer.stdin, format='h264', bitrate=1000000)

After that you can insert your code for image capturing.
Take into account that you need to close gstreamer by yourself:

camera.stop_recording()
gstreamer.stdin.close()
gstreamer.wait()

To capture image by camera trigger event you should use MAVProxy and DroneKit.

Passing mavlink messages to python script should be done with Mavproxy.
Run it on Raspberry with the following startup options:
--master ground_station_ip:14550 --out 127.0.0.1:14550 --out 127.0.0.1:14850

Here 127.0.0.1:1455 is local port of ardupilot, 127.0.0.1:14850 - local port for passthrough messages to the script.

Import dronekit module to your script and create vehicle object connected to 0.0.0.0:14850.
Then add on_message() decorator to create callback for camera trigger event.
The shutter triggered by MAV_CMD_DO_DIGICAM_CONTROL mavlink message, so you need to listen for this command and make image capture in callback.

2 Likes

Thank you Ivan. Now I have to decode all the Latin that you jsut wrote there :-).

Can i do this in the systemd file where I start the raspivid process ?

Yes, you can run mavproxy and your snapshotting script using systemd services.
Video streaming starts with camera.start_recording() method I mentioned above, so running raspivid is not needed.

Here is one more detail that I forgot to mention!

Change IP in /etc/default/adrucopter to local: TELEM1="-A udp:0.0.0.0:14550" to make ardupilot receive data from mavproxy you configured earlier, not from ground station.

Yes it is already like that.

Thank you for the help Ivan as usual.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.