Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4762

Camera board • Real-Time Motion Extraction Post Processing Script

$
0
0
Wanna share something cool today. I've created a post-processing scripts that generates motion extraction footage in real-time.
This is inspired from Posy's Motion Extraction video (https://www.youtube.com/watch?v=NSS6yAMZF78)

Here's the result of the real-time motion extraction footage captured in Raspberry Pi 3B+ with Camera Module 3: https://www.youtube.com/watch?v=0aFgArVnlPs

Guide on installing rpicam-apps with custom post-processing script
  1. Clone my forked rpicam-apps with motion-extraction branch: https://github.com/shouta569/rpicam-app ... extraction
  2. Follow this link guide on building custom rpicam-apps
    https://www.raspberrypi.com/documentati ... picam-apps
    Note: I highly recommend "-Denable_libav=enabled" as using libav codec to create mp4 or avi video files that provide much smoother video playback
Guide on using motion extraction post-processing script
Create a .json file that contains motion-extraction stage. Here's an example:

Code:

{    "motion_extraction" : {    "prerecord_frames": 90,        "frame_offset": 1,        "fixed_frame": false,        "scale": 1.0,        "skip_uv_diff": false    }}
Parameters for motion-extraction stage:
  • prerecord_frames (int) - Set number of frames of normal footage captured before transition to motion extraction footage. If the value is more than 0, there will be about 20 frames of fade effect added in the transition (Default: 0)
  • frame_offset (int) - Set number of frame offset when comparing with current frame for motion extraction. This value is ignored if fixed_frame = true (Default: 1)
  • fixed_frame (bool) - If true, then only the first frame (the frame just before transitioning to motion extraction footage) will only be used to compare with current frame
  • scale (float) - Multiply the difference between 2 frames (Default: 1.0)
  • skip_uv_diff (bool) - If true, only output the difference of Y (luma) components of 2 frames. The difference between U and Y (chroma) components will not be calculated.
Then run rpicam-vid with --post-process-file argument:

Code:

rpicam-vid --post-process-file <json file>
Note that this post-processing script only works on rpicam-vid command.

Enjoy~~

Statistics: Posted by ongeelim — Sat Jan 18, 2025 7:16 pm



Viewing all articles
Browse latest Browse all 4762

Trending Articles