No version for distro humble showing jazzy. Known supported distros are highlighted in the buttons above.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
jazzy

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version 3.1.0
Last Updated 2026-11-23
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.0

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
jazzy

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version 3.1.0
Last Updated 2026-11-23
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.0

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
kilted

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version 3.1.0
Last Updated 2026-11-23
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.0

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
lyrical

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version 3.1.0
Last Updated 2026-11-23
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.0

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
No version for distro rolling showing jazzy. Known supported distros are highlighted in the buttons above.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
jazzy

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version 3.1.0
Last Updated 2026-11-23
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.0

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
No version for distro github showing jazzy. Known supported distros are highlighted in the buttons above.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
jazzy

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version 3.1.0
Last Updated 2026-11-23
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.0

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
No version for distro galactic showing jazzy. Known supported distros are highlighted in the buttons above.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
jazzy

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version 3.1.0
Last Updated 2026-11-23
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.0

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
No version for distro iron showing jazzy. Known supported distros are highlighted in the buttons above.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
jazzy

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version 3.1.0
Last Updated 2026-11-23
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.0

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
melodic

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version indigo
Last Updated 2026-11-30
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.1

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.
Repo symbol

opencv_apps repository

opencv_apps

ROS Distro
noetic

Repository Summary

Description
Checkout URI https://github.com/ros-perception/opencv_apps.git
VCS Type git
VCS Version indigo
Last Updated 2026-11-30
Dev Status UNKNOWN
Released RELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
opencv_apps 3.1.1

README

opencv_apps

ci doc License

jazzy kilted lyrical noetic ROS One

opencv_apps: the input image, edge_detection, dnn_image_classification, dnn_pose_estimation, dnn_tracking, fback_flow and detection_3d

opencv_apps provides the ROS nodes that run the functions of OpenCV: image processing, features, contours, optical flows, tracking, detection and recognition, and the deep learning models of cv::dnn. Each node subscribes an image topic, and publishes its results as messages and as an image, so you can use the functions of OpenCV just by running a launch file. The same source supports both ROS 1 and ROS 2.

sudo apt install ros-$ROS_DISTRO-opencv-apps ros-$ROS_DISTRO-image-publisher
# ROS 2, terminal 1: publish the USB camera as image (0: the number of the camera, /dev/video0)
ros2 run image_publisher image_publisher_node 0 --ros-args -r image_raw:=image
# ROS 2, terminal 2: the face detection on it
ros2 launch opencv_apps face_detection.launch.xml image:=image
# ROS 1 (ROS One), terminal 1: publish the USB camera as camera/image_raw (0: /dev/video0)
rosrun image_publisher image_publisher 0 __name:=camera
# ROS 1 (ROS One), terminal 2: the face detection on it
roslaunch opencv_apps face_detection.launch image:=camera/image_raw use_opencv4:=true

Documentation: https://ros-perception.github.io/opencv_apps/ (the topics, the parameters and the usage of the nodes)

Run the dnn nodes on the GPU (CUDA, ROS 2)

The OpenCV of the distributions has no CUDA, so the launch files of the dnn nodes (dnn_*.launch.xml) run the node in a docker image of OpenCV with CUDA with use_cuda:=true (by scripts/run_in_docker, with the GPUs, the network and the shared memory of the host, so the other nodes on the host communicate with it as usual). The images are on the GitHub Container Registry, and pulled at the first use (about 10 GB); the host needs the NVIDIA driver and the NVIDIA Container Toolkit:

# OpenCV 4.12 with CUDA 12.8 (ghcr.io/ros-perception/opencv_apps:cuda, the default of cuda_image)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true
# OpenCV 5.1 with CUDA 13.3; its new engine runs a model on CUDA only if all its layers have CUDA, otherwise on the
# CPU (e.g. YOLOX-S, YuNet and SFace of opencv_zoo with OpenCV 5.1)
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true \
  cuda_image:=ghcr.io/ros-perception/opencv_apps:opencv5-cuda
# or build the image (about an hour), in opencv_apps, with CUDA_ARCH_BIN of your GPU, e.g. 8.9 of RTX 40 series
docker build -f docker/cuda/Dockerfile --build-arg CUDA_ARCH_BIN=8.9 -t opencv_apps:cuda .
ros2 launch opencv_apps dnn_object_detection.launch.xml image:=/camera/image_raw use_cuda:=true cuda_image:=opencv_apps:cuda

The rates of all the models on the CPU and in both images are in the documentation. The rate of ~/detections of dnn_object_detection (YOLOX-S, 640x640) for the images of 640x480 at 100 Hz, on AMD Ryzen 9 7950X (16 cores) and NVIDIA GeForce RTX 4090:

  OpenCV backend Hz
ROS 2 jazzy (apt) 4.6 CPU 13.3
opencv_apps:cuda 4.12 CUDA 55.0
opencv_apps:cuda 4.12 CPU (backend:=cpu) 13.4
opencv_apps:opencv5-cuda 5.1 CPU (falls back from CUDA) 36.0

What opencv_apps can do

The nodes are grouped by what they find, e.g. what the whole image shows (image classification), the bounding boxes of the objects (object detection) or the regions of the pixels (segmentation). The nodes of a group publish the same kind of results, mostly the same type of message on the same topic, so that one can replace another, e.g. face_detection by dnn_face_detection. Each group lists the nodes by the distributions that they run on, and each tile shows the main output of the node.

Image filters

Filter and transform the images: edges (also by DexiNed), histogram equalization, morphology, image pyramids, smoothing, thresholds, the Fourier transform, and the super resolution and the inpainting by a DNN. Output: the processed image in ~/image.

ROS 1: noetic and later, ROS 2: jazzy and later

adding_images
adding_images
~/image
discrete_fourier_transform
discrete_fourier_transform
~/image
edge_detection
edge_detection
~/image
pyramids
pyramids
~/image
smoothing
smoothing
~/image
threshold
threshold
~/image

ROS 1: ROS One and later, ROS 2: jazzy and later

equalize_histogram
equalize_histogram
~/image
morphology
morphology
~/image

File truncated at 100 lines see the full file

CONTRIBUTING

Contributing to opencv_apps

opencv_apps wraps OpenCV samples (from opencv/samples/cpp, samples/tapi, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent.

Checklist for a new node <name> (class <Name>Nodelet)

Use threshold as the template; see also camshift (trackbars/mouse) and face_recognition (services).

  1. Nodelet src/nodelet/<name>_nodelet.cpp, written in the ROS2 API on opencv_apps::Nodelet (include/opencv_apps/nodelet.h):
    • parameters: declare_parameter(name, default, paramDescriptor(desc, min, max)), updated in a parametersCallback registered with add_on_set_parameters_callback;
    • I/O: subscribeImage / subscribeCamera in subscribe(), advertiseImage / advertise for outputs;
    • end with RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::<Name>Nodelet).
    • On ROS1 the same file compiles through ros1/include/opencv_apps/ros1_compat.h, which also serves the declared parameters as dynamic_reconfigure (startReconfigureServer, ~set_parameters). A cfg/*.cfg is therefore not needed for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the paramDescriptor).
    • Guard OpenCV API differences with CV_MAJOR_VERSION / CV_MINOR_VERSION (OpenCV 3.x/4.x are in CI).
  2. CMakeLists.txt, both sections (keep changes scoped to the new node; do not restructure other targets):
    • ROS2: <name>:<Name>Nodelet in _nodelets and src/nodelet/<name>_nodelet.cpp in _nodelet_cppfiles;
    • ROS1: opencv_apps_add_nodelet(<name> src/nodelet/<name>_nodelet.cpp).
    • opencv_contrib modules: gate both with if(TARGET opencv_xxx) (see opencv_optflow / simple_flow), and the tests too.
  3. nodelet_plugins.xml: <class name="opencv_apps/<name>" type="opencv_apps::<Name>Nodelet" ...>.
  4. New messages: msg/<Type>.msg (globbed on ROS2; add it to ROS1 add_message_files) and a shim ros1/include/opencv_apps/msg/<snake_type>.hpp like msg/circle.hpp.
  5. Launch: launch/<name>.launch (ROS1) and launch/<name>.launch.xml (ROS2) with the same arguments.
  6. Tests (required):
    • ROS1: test/test-<name>.test (rostest + hztest), registered in test/CMakeLists.txt with add_rostest(test-<name>.test ARGS gui:=false);
    • ROS2: test/ros2/test_<name>.py (launch_testing, globbed automatically) using camera(), include(), description() and TopicsTest from test/ros2/opencv_apps_test.py.
  7. README.md: add the node to the list.

Build and test

# ROS1
catkin_make
catkin_make run_tests   # all tests; results in build/test_results/opencv_apps/
# one test (catkin-generated target name, list them with `make -C build help | grep run_tests`):
catkin_make run_tests_opencv_apps_rostest_test-<name>__gui_false.test

# ROS2
colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON
colcon test --packages-select opencv_apps --ctest-args -R <name>
colcon test-result --verbose

CI (.github/workflows/ci.yml, .travis.sh) also runs clang-format, catkin_lint and clang-tidy; to check locally:

clang-format -i -style=file src/nodelet/<name>_nodelet.cpp   # repository .clang-format
ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict .   # use the catkin_lint version pinned in ci.yml
# clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then
run-clang-tidy -p <build dir containing compile_commands.json>

Pull requests

Each PR must include:

  • the test(s) above, passing on ROS1 and ROS2;
  • a demo video (GIF or mp4) of the node output (e.g. /<name>/image) in the PR description.
# Contributing to opencv_apps opencv_apps wraps OpenCV samples (from `opencv/samples/cpp`, `samples/tapi`, tutorials, or elsewhere) as ROS nodes. One source file builds on both ROS1 (catkin) and ROS2 (colcon/ament). Please keep each node small and focused on one OpenCV feature, and follow the layout below so the repository stays consistent. ## Checklist for a new node `` (class `Nodelet`) Use `threshold` as the template; see also `camshift` (trackbars/mouse) and `face_recognition` (services). 1. **Nodelet** `src/nodelet/_nodelet.cpp`, written in the ROS2 API on `opencv_apps::Nodelet` (`include/opencv_apps/nodelet.h`): - parameters: `declare_parameter(name, default, paramDescriptor(desc, min, max))`, updated in a `parametersCallback` registered with `add_on_set_parameters_callback`; - I/O: `subscribeImage` / `subscribeCamera` in `subscribe()`, `advertiseImage` / `advertise` for outputs; - end with `RCLCPP_COMPONENTS_REGISTER_NODE(opencv_apps::Nodelet)`. - On ROS1 the same file compiles through `ros1/include/opencv_apps/ros1_compat.h`, which also serves the declared parameters as dynamic_reconfigure (`startReconfigureServer`, `~set_parameters`). A `cfg/*.cfg` is therefore **not needed** for new nodes; existing nodes keep theirs only for compatibility (if you add one, its defaults/ranges must match the `paramDescriptor`). - Guard OpenCV API differences with `CV_MAJOR_VERSION` / `CV_MINOR_VERSION` (OpenCV 3.x/4.x are in CI). 2. **CMakeLists.txt**, both sections (keep changes scoped to the new node; do not restructure other targets): - ROS2: `:Nodelet` in `_nodelets` and `src/nodelet/_nodelet.cpp` in `_nodelet_cppfiles`; - ROS1: `opencv_apps_add_nodelet( src/nodelet/_nodelet.cpp)`. - opencv_contrib modules: gate both with `if(TARGET opencv_xxx)` (see `opencv_optflow` / `simple_flow`), and the tests too. 3. **nodelet_plugins.xml**: ``. 4. **New messages**: `msg/.msg` (globbed on ROS2; add it to ROS1 `add_message_files`) and a shim `ros1/include/opencv_apps/msg/.hpp` like `msg/circle.hpp`. 5. **Launch**: `launch/.launch` (ROS1) and `launch/.launch.xml` (ROS2) with the same arguments. 6. **Tests** (required): - ROS1: `test/test-.test` (rostest + `hztest`), registered in `test/CMakeLists.txt` with `add_rostest(test-.test ARGS gui:=false)`; - ROS2: `test/ros2/test_.py` (launch_testing, globbed automatically) using `camera()`, `include()`, `description()` and `TopicsTest` from `test/ros2/opencv_apps_test.py`. 7. **README.md**: add the node to the list. ## Build and test ```bash # ROS1 catkin_make catkin_make run_tests # all tests; results in build/test_results/opencv_apps/ # one test (catkin-generated target name, list them with `make -C build help | grep run_tests`): catkin_make run_tests_opencv_apps_rostest_test-__gui_false.test # ROS2 colcon build --packages-select opencv_apps --cmake-args -DBUILD_TESTING=ON colcon test --packages-select opencv_apps --ctest-args -R colcon test-result --verbose ``` CI (`.github/workflows/ci.yml`, `.travis.sh`) also runs clang-format, catkin_lint and clang-tidy; to check locally: ```bash clang-format -i -style=file src/nodelet/_nodelet.cpp # repository .clang-format ROS_DISTRO=melodic ROS_VERSION=1 catkin_lint --resolve-env --strict . # use the catkin_lint version pinned in ci.yml # clang-tidy (repository .clang-tidy): build with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, then run-clang-tidy -p ``` ## Pull requests Each PR must include: - the test(s) above, passing on ROS1 and ROS2; - a **demo video** (GIF or mp4) of the node output (e.g. `//image`) in the PR description.