Post-processing with OpenCV
These stages require an OpenCV installation. You might need to rebuild rpicam-apps with OpenCV support.
|
sobel_cv stage
This stage applies a Sobel filter to an image to emphasise edges.
You can configure this stage with the following parameters:
|
Kernel size of the Sobel filter |
Default sobel_cv.json file:
{
"sobel_cv" : {
"ksize": 5
}
}
Example:
face_detect_cv stage
This stage uses the OpenCV Haar classifier to detect faces in an image. It returns face location metadata under the key face_detect.results and optionally draws the locations on the image.
You can configure this stage with the following parameters:
|
Name of the file where the Haar cascade can be found |
|
Determines range of scales at which the image is searched for faces |
|
Minimum number of overlapping neighbours required to count as a face |
|
Minimum face size |
|
Maximum face size |
|
How many frames to wait before trying to re-run the face detector |
|
Whether to draw face locations on the returned image |
The face_detect_cv stage runs only during preview and video capture. It ignores still image capture. It runs on the low resolution stream with a resolution between 320×240 and 640×480 pixels.
Default face_detect_cv.json file:
{
"face_detect_cv" : {
"cascade_name" : "/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml",
"scaling_factor" : 1.1,
"min_neighbors" : 2,
"min_size" : 32,
"max_size" : 256,
"refresh_rate" : 1,
"draw_features" : 1
}
}
Example:
annotate_cv stage
This stage writes text into the top corner of images using the same % substitutions as the info-text option.
Interprets info-text directives first, then passes any remaining tokens to strftime.
For example, to achieve a datetime stamp on the video, pass %F %T %z:
-
%Fdisplays the ISO-8601 date (2023-03-07) -
%Tdisplays 24h local time (for example, "09:57:12") -
%zdisplays the timezone relative to UTC (for example, "-0800")
This stage does not output any metadata, but it writes metadata found in annotate.text in place of anything in the JSON configuration file. This allows other post-processing stages to write text onto images.
You can configure this stage with the following parameters:
|
The text string to be written |
|
Foreground colour |
|
Background colour |
|
A number proportional to the size of the text |
|
A number that determines the thickness of the text |
|
The amount of alpha to apply when overwriting background pixels |
Default annotate_cv.json file:
{
"annotate_cv" : {
"text" : "Frame %frame exp %exp ag %ag dg %dg",
"fg" : 255,
"bg" : 0,
"scale" : 1.0,
"thickness" : 2,
"alpha" : 0.3
}
}
Example: