This repository provides two plugins for MADS:
- image_source: grabs frames from the first available camera via OpenCV and publishes each frame as a JPEG-encoded blob.
- image_sink: receives an image blob and stores it as a
.jpgfile in the current working directory.
Required MADS version: 2.4.3.
OpenCV is used to access the camera and encode frames. A system-installed
OpenCV is preferred; if none is found, it is fetched and built (core,
imgproc, imgcodecs, videoio only) via CMake FetchContent, which can take a
while the first time.
Currently, the supported platforms are:
- Linux
- MacOS
- Windows
Linux and MacOS:
cmake -Bbuild -DCMAKE_INSTALL_PREFIX="$(mads -p)"
cmake --build build -j4
sudo cmake --install buildWindows:
cmake -Bbuild -DCMAKE_INSTALL_PREFIX="$(mads -p)"
cmake --build build --config Release
cmake --install build --config Release[image_source]
# Capture resolution: a preset (QVGA, VGA, SVGA, HD, FULLHD) or an explicit
# "WIDTHxHEIGHT" spec, e.g. "1024x768". The camera may not support the exact
# resolution requested; the actually captured size is reported in the
# published "width"/"height" fields.
resolution = VGA
# Capture mode: "RGB" for color frames, "BW" for grayscale.
mode = BWEach published message carries width, height, mode, and format
("jpg") fields, plus the raw JPEG bytes as the message blob.
[image_sink]
# Base name for saved images; each is written as "<basename>_NNN.jpg" with
# an incrementing, zero-padded counter. On startup, the counter resumes
# after the highest-numbered file already present, so restarts never
# overwrite earlier captures.
basename = capture
# Stops after grabbing 5 frames (default=5)
# Set to 0 for unlimited, but watch for disk space usage!
count = 5 All settings are optional; if omitted, the default values are used.
On MacOS, each plugin is also compiled as a standalone executable
(image_source / image_sink); on Linux and Windows, a matching
*_main executable is built alongside the loadable .plugin/.dll.
Running it exercises the plugin outside of a MADS agent:
image_sourceopens the default camera, captures one VGA/BW frame, prints the resulting JSON metadata, and writes it tocapture_test.jpgin the current directory.image_sinkwrites a minimal placeholder JPEG blob tocapture_000.jpg(or the next free index), demonstrating the save path without requiring a camera.