├── .github
└── workflows
│ └── basic-build-ci.yaml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── camera_calibration
├── CHANGELOG.rst
├── button.jpg
├── doc
│ ├── api.rst
│ ├── components.rst
│ ├── conf.py
│ ├── images
│ │ ├── cal0006.png
│ │ ├── cal0007.png
│ │ ├── cal0008.png
│ │ ├── cal0009.png
│ │ ├── cal0011.png
│ │ ├── cal0012.png
│ │ ├── check-108.png
│ │ ├── mono_0.png
│ │ ├── mono_1.png
│ │ ├── mono_2.png
│ │ ├── stereo_0.png
│ │ ├── stereo_1.png
│ │ ├── stereo_2.png
│ │ ├── stereo_3.png
│ │ └── stereo_4.png
│ ├── index.rst
│ ├── tutorial_mono.rst
│ └── tutorial_stereo.rst
├── mainpage.dox
├── package.xml
├── pytest.ini
├── resource
│ └── camera_calibration
├── rosdoc2.yaml
├── setup.cfg
├── setup.py
├── src
│ └── camera_calibration
│ │ ├── __init__.py
│ │ ├── calibrator.py
│ │ ├── camera_calibrator.py
│ │ ├── camera_checker.py
│ │ ├── mono_calibrator.py
│ │ ├── nodes
│ │ ├── __init__.py
│ │ ├── cameracalibrator.py
│ │ ├── cameracheck.py
│ │ └── tarfile_calibration.py
│ │ └── stereo_calibrator.py
└── test
│ ├── test_directed.py
│ └── test_multiple_boards.py
├── depth_image_proc
├── CHANGELOG.rst
├── CMakeLists.txt
├── doc
│ ├── components.rst
│ ├── conf.py
│ ├── images
│ │ ├── depth.png
│ │ ├── depth_reg.png
│ │ ├── disparity.png
│ │ ├── rgb.jpg
│ │ ├── rviz_xyz.png
│ │ └── rviz_xyzrgb.png
│ ├── index.rst
│ └── tutorials.rst
├── include
│ └── depth_image_proc
│ │ ├── conversions.hpp
│ │ ├── depth_traits.hpp
│ │ ├── point_cloud_xyz.hpp
│ │ ├── point_cloud_xyz_radial.hpp
│ │ ├── point_cloud_xyzi.hpp
│ │ ├── point_cloud_xyzi_radial.hpp
│ │ ├── point_cloud_xyzrgb.hpp
│ │ ├── point_cloud_xyzrgb_radial.hpp
│ │ └── visibility.h
├── launch
│ ├── convert_metric.launch.py
│ ├── crop_foremost.launch.py
│ ├── disparity.launch.py
│ ├── point_cloud_xyz.launch.py
│ ├── point_cloud_xyz_radial.launch.py
│ ├── point_cloud_xyzi.launch.py
│ ├── point_cloud_xyzi_radial.launch.py
│ ├── point_cloud_xyzrgb.launch.py
│ ├── point_cloud_xyzrgb_radial.launch.py
│ ├── register.launch.py
│ └── rviz
│ │ ├── convert_metric.rviz
│ │ ├── crop_formost.rviz
│ │ ├── disparity.rviz
│ │ ├── point_cloud_xyz.rviz
│ │ ├── point_cloud_xyz_radial.rviz
│ │ ├── point_cloud_xyzi.rviz
│ │ ├── point_cloud_xyzrgb.rviz
│ │ └── register.rviz
├── package.xml
└── src
│ ├── conversions.cpp
│ ├── convert_metric.cpp
│ ├── crop_foremost.cpp
│ ├── disparity.cpp
│ ├── point_cloud_xyz.cpp
│ ├── point_cloud_xyz_radial.cpp
│ ├── point_cloud_xyzi.cpp
│ ├── point_cloud_xyzi_radial.cpp
│ ├── point_cloud_xyzrgb.cpp
│ ├── point_cloud_xyzrgb_radial.cpp
│ └── register.cpp
├── image_pipeline
├── CHANGELOG.rst
├── CMakeLists.txt
├── doc
│ ├── camera_info.rst
│ ├── changelog.rst
│ ├── conf.py
│ ├── images
│ │ ├── CameraCoords.png
│ │ └── CameraInfo.png
│ ├── index.rst
│ └── tutorials.rst
├── package.xml
└── rosdoc2.yaml
├── image_proc
├── CHANGELOG.rst
├── CMakeLists.txt
├── doc
│ ├── components.rst
│ ├── conf.py
│ ├── images
│ │ ├── left_raw.png
│ │ └── left_rect_color.png
│ ├── index.rst
│ └── tutorials.rst
├── include
│ └── image_proc
│ │ ├── crop_decimate.hpp
│ │ ├── crop_non_zero.hpp
│ │ ├── debayer.hpp
│ │ ├── edge_aware.hpp
│ │ ├── processor.hpp
│ │ ├── rectify.hpp
│ │ ├── resize.hpp
│ │ ├── track_marker.hpp
│ │ └── utils.hpp
├── launch
│ └── image_proc.launch.py
├── package.xml
├── src
│ ├── crop_decimate.cpp
│ ├── crop_non_zero.cpp
│ ├── debayer.cpp
│ ├── edge_aware.cpp
│ ├── image_proc
│ │ └── processor.cpp
│ ├── rectify.cpp
│ ├── resize.cpp
│ └── track_marker.cpp
└── test
│ ├── resources
│ ├── calibration_file.ini
│ └── logo.png
│ ├── rostest.cpp
│ └── test_rectify.cpp
├── image_publisher
├── CHANGELOG.rst
├── CMakeLists.txt
├── doc
│ ├── components.rst
│ ├── conf.py
│ └── index.rst
├── include
│ └── image_publisher
│ │ ├── image_publisher.hpp
│ │ └── visibility.h
├── launch
│ ├── image_publisher_component_file.launch.py
│ ├── image_publisher_file.launch.py
│ ├── image_publisher_mono.launch.py
│ ├── image_publisher_stereo.launch.py
│ └── splash.png
├── package.xml
└── src
│ ├── image_publisher.cpp
│ └── image_publisher_node.cpp
├── image_rotate
├── CHANGELOG.rst
├── CMakeLists.txt
├── doc
│ ├── components.rst
│ ├── conf.py
│ ├── images
│ │ └── image_rotate.jpg
│ └── index.rst
├── include
│ └── image_rotate
│ │ ├── image_flip.hpp
│ │ ├── image_rotate_node.hpp
│ │ └── visibility.h
├── launch
│ ├── image_flip.launch.py
│ └── image_rotate.launch.py
├── mainpage.dox
├── package.xml
└── src
│ ├── image_flip.cpp
│ ├── image_rotate.cpp
│ └── image_rotate_node.cpp
├── image_view
├── CHANGELOG.rst
├── CMakeLists.txt
├── doc
│ ├── components.rst
│ ├── conf.py
│ └── index.rst
├── include
│ └── image_view
│ │ ├── disparity_view_node.hpp
│ │ ├── extract_images_node.hpp
│ │ ├── image_saver_node.hpp
│ │ ├── image_view_node.hpp
│ │ ├── stereo_view_node.hpp
│ │ └── video_recorder_node.hpp
├── mainpage.dox
├── package.xml
├── rosdoc.yaml
├── scripts
│ └── extract_images_sync
└── src
│ ├── disparity_view.cpp
│ ├── disparity_view_node.cpp
│ ├── extract_images.cpp
│ ├── extract_images_node.cpp
│ ├── image_saver.cpp
│ ├── image_saver_node.cpp
│ ├── image_view.cpp
│ ├── image_view_node.cpp
│ ├── stereo_view.cpp
│ ├── stereo_view_node.cpp
│ ├── utils.hpp
│ ├── video_recorder.cpp
│ └── video_recorder_node.cpp
├── stereo_image_proc
├── CHANGELOG.rst
├── CMakeLists.txt
├── doc
│ ├── components.rst
│ ├── conf.py
│ ├── configuration.rst
│ ├── images
│ │ ├── disparity.jpg
│ │ ├── raw.png
│ │ ├── rectified.png
│ │ ├── stereo_frames.png
│ │ └── stereo_image_proc.png
│ ├── index.rst
│ └── tutorials.rst
├── include
│ └── stereo_image_proc
│ │ └── stereo_processor.hpp
├── launch
│ └── stereo_image_proc.launch.py
├── package.xml
├── src
│ └── stereo_image_proc
│ │ ├── disparity_node.cpp
│ │ ├── point_cloud_node.cpp
│ │ └── stereo_processor.cpp
└── test
│ ├── data
│ ├── README.md
│ ├── aloe-L.png
│ ├── aloe-R.png
│ └── aloe-disp.png
│ ├── fixtures
│ ├── disparity_image_publisher.py
│ └── stereo_image_publisher.py
│ ├── test_disparity_node.py
│ └── test_point_cloud_node.py
├── tools
└── ros2_dependencies.repos
├── tracetools_image_pipeline
├── .gitignore
├── CHANGELOG.rst
├── CMakeLists.txt
├── Doxyfile
├── README.md
├── include
│ └── tracetools_image_pipeline
│ │ ├── config.h.in
│ │ ├── tp_call.h
│ │ ├── tracetools.h
│ │ ├── utils.hpp
│ │ └── visibility_control.hpp
├── package.xml
└── src
│ ├── status.c
│ ├── tp_call.c
│ ├── tracetools.c
│ └── utils.cpp
└── wiki_files
├── dcam-driver.svg
├── image_proc.svg
├── image_proc_dual.svg
├── rospack_nosubdirs
├── stereo_image_proc.svg
├── stereo_image_proc_stereo.svg
├── stereocam-driver.svg
└── stoc.svg
/.github/workflows/basic-build-ci.yaml:
--------------------------------------------------------------------------------
1 | name: Basic Build Workflow
2 |
3 | on:
4 | push:
5 | branches: [rolling]
6 | pull_request:
7 | types: [opened, reopened, synchronize]
8 |
9 | jobs:
10 | build-rolling:
11 | runs-on: ubuntu-latest
12 | strategy:
13 | fail-fast: false
14 | container:
15 | image: osrf/ros2:devel
16 | steps:
17 | - name: Checkout repo
18 | uses: actions/checkout@v4
19 | - name: Create Workspace
20 | run: |
21 | mkdir src_tmp
22 | mv `find -maxdepth 1 -not -name . -not -name src_tmp` src_tmp/
23 | mv src_tmp/ src/
24 | - name: Install Prerequisites
25 | run: |
26 | bash -c 'source /opt/ros/rolling/setup.bash; \
27 | apt-get update && apt-get upgrade -y && rosdep update; \
28 | rosdep install --from-paths src --ignore-src --rosdistro=rolling -y'
29 | - name: Build Workspace
30 | run: |
31 | bash -c 'source /opt/ros/rolling/setup.bash; \
32 | colcon build'
33 | - name: Run Tests
34 | run: |
35 | bash -c 'source /opt/ros/rolling/setup.bash; \
36 | colcon test; \
37 | colcon test-result --verbose'
38 | build-rolling-testing:
39 | runs-on: ubuntu-latest
40 | strategy:
41 | fail-fast: false
42 | container:
43 | image: osrf/ros2:testing
44 | steps:
45 | - name: Checkout repo
46 | uses: actions/checkout@v4
47 | - name: Create Workspace
48 | run: |
49 | mkdir src_tmp
50 | mv `find -maxdepth 1 -not -name . -not -name src_tmp` src_tmp/
51 | mv src_tmp/ src/
52 | - name: Install Prerequisites
53 | run: |
54 | apt update -qq
55 | apt install -qq -y lsb-release wget curl gnupg2 git
56 | curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros2-testing-archive-keyring.gpg
57 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros2-testing-archive-keyring.gpg] http://packages.ros.org/ros2-testing/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
58 | apt-get update && apt-get upgrade -q -y
59 | bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
60 | apt-get update && apt-get upgrade -y && rosdep update; \
61 | rosdep install --from-paths src --ignore-src -y'
62 | - name: Build Workspace
63 | run: |
64 | bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
65 | colcon build'
66 | - name: Run Tests
67 | run: |
68 | bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
69 | colcon test; \
70 | colcon test-result --verbose'
71 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *pyc
2 | .vscode/
3 | */doc/generated
4 | build
5 | install
6 | log
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Any contribution that you make to this repository will
2 | be under the BSD license 2.0, as dictated by that
3 | [license](https://opensource.org/licenses/BSD-3-Clause).
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | image_pipeline
2 | ==============
3 |
4 | [](https://build.ros2.org/job/Rdev__image_pipeline__ubuntu_noble_amd64/)
5 |
6 | This package fills the gap between getting raw images from a camera driver and higher-level vision processing.
7 |
8 | Documentation is hosted in the ROS 2 API docs.
9 | The [image_pipeline](http://docs.ros.org/en/rolling/p/image_pipeline/)
10 | documentation includes an overview,
11 | [details on camera_info](http://docs.ros.org/en/rolling/p/image_pipeline/camera_info.html),
12 | and links to the documentation for each individual package.
13 |
14 | Not every aspect has been ported to the new ROS 2 API documentation yet, so
15 | there is still additional (partially outdated) information
16 | in [the ROS wiki entry](http://wiki.ros.org/image_pipeline).
17 |
18 | If you are using an Nvidia Jetson platform, consider using modules from [Isaac Image Proc](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_image_pipeline) - a collection of hardware accelerated `image_proc` features for the Jetsons.
19 |
--------------------------------------------------------------------------------
/camera_calibration/button.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/button.jpg
--------------------------------------------------------------------------------
/camera_calibration/doc/api.rst:
--------------------------------------------------------------------------------
1 | API Documentation
2 | =================
3 |
4 | .. autoclass:: camera_calibration.mono_calibrator.MonoCalibrator
5 | :members:
6 |
7 | .. autoclass:: camera_calibration.stereo_calibrator.StereoCalibrator
8 | :members:
9 |
--------------------------------------------------------------------------------
/camera_calibration/doc/components.rst:
--------------------------------------------------------------------------------
1 | Nodes
2 | =====
3 |
4 | This package includes a number of ROS 2 components that can be assembled
5 | into image processing pipelines.
6 | See the tutorial :ref:`Launch image_proc Components`.
7 |
8 | Alternatively, each component can be run as a standalone node.
9 |
10 | camera_calibrator
11 | -----------------
12 | ``cameracalibrator`` subscribes to ROS raw image topics, and presents a
13 | calibration window. It can run in both monocular and stereo modes.
14 | The calibration window shows the current images from the cameras,
15 | highlighting the checkerboard. When the user presses the **CALIBRATE**
16 | button, the node computes the camera calibration parameters. When the
17 | user clicks **COMMIT**, the node uploads these new calibration parameters
18 | to the camera driver using a service call.
19 |
20 | Subscribed Topics
21 | ^^^^^^^^^^^^^^^^^
22 | * **image** (sensor_msgs/Image): Raw image topic, for monocular cameras.
23 | * **left** (sensor_msgs/Image): Raw left image topic, for stereo cameras.
24 | * **right** (sensor_msgs/Image): Raw right image topic, for stereo cameras.
25 |
26 | Services Called
27 | ^^^^^^^^^^^^^^^
28 | * **camera/set_camera_info** (sensor_msgs/SetCameraInfo): Sets the camera
29 | info for a monocular camera.
30 | * **left_camera/set_camera_info** (sensor_msgs/SetCameraInfo): Sets the camera
31 | info for the left camera of a stereo pair.
32 | * **right_camera/set_camera_info** (sensor_msgs/SetCameraInfo): Sets the camera
33 | info for the right camera of a stereo pair.
34 |
35 | camera_check
36 | ------------
37 | ``cameracheck`` subscribes to ROS rectified image topics and their associated
38 | camera_info, and prints out an error estimate. It can run in both monocular
39 | and stereo modes. The program expects to see a standard checkerboard target.
40 |
41 | Subscribed Topics
42 | ^^^^^^^^^^^^^^^^^
43 | * **monocular/image** (sensor_msgs/Image): Rectified image topic, for
44 | monocular camera.
45 | * **monocular/camera_info** (sensor_msgs/CameraInfo): Camera info for
46 | the monocular camera.
47 | * **stereo/left/image** (sensor_msgs/Image): Rectified left image topic,
48 | for stereo cameras.
49 | * **stereo/right/image** (sensor_msgs/Image): Rectified right image topic,
50 | for stereo cameras.
51 | * **stereo/camera_info** (sensor_msgs/CameraInfo): Camera info for the
52 | stereo pair.
53 |
--------------------------------------------------------------------------------
/camera_calibration/doc/images/cal0006.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/cal0006.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/cal0007.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/cal0007.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/cal0008.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/cal0008.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/cal0009.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/cal0009.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/cal0011.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/cal0011.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/cal0012.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/cal0012.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/check-108.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/check-108.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/mono_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/mono_0.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/mono_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/mono_1.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/mono_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/mono_2.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/stereo_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/stereo_0.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/stereo_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/stereo_1.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/stereo_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/stereo_2.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/stereo_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/stereo_3.png
--------------------------------------------------------------------------------
/camera_calibration/doc/images/stereo_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/doc/images/stereo_4.png
--------------------------------------------------------------------------------
/camera_calibration/mainpage.dox:
--------------------------------------------------------------------------------
1 | /**
2 | \mainpage
3 | \htmlinclude manifest.html
4 |
5 | \b The camera_calibration package contains tools for calibrating monocular and stereo cameras.
6 |
7 | \section codeapi Code API
8 |
9 | camera_calibration does not have a code API.
10 |
11 | \section rosapi ROS API
12 |
13 | List of nodes:
14 | - \b calibrationnode
15 |
16 |
17 |
18 |
19 |
20 | \subsection node_name calibrationnode
21 |
22 | calibrationnode subscribes to ROS raw image topics, and presents a
23 | calibration window. It can run in both monocular and stereo modes.
24 | The calibration window shows the current images from the cameras,
25 | highlighting the checkerboard. When the user presses the "CALIBRATE"
26 | button, the node computes the camera calibration parameters. When the
27 | user clicks "UPLOAD", the node uploads these new calibration parameters
28 | to the camera driver using a service call.
29 |
30 | \subsubsection Usage
31 | \verbatim
32 | $ node_type1 [standard ROS args]
33 | \endverbatim
34 |
35 | \par Example
36 |
37 | \verbatim
38 | $ rosrun camera_calibration cal.py right:=/my_stereo/right/image_raw left:=/my_stereo/left/image_raw left_camera:=/my_stereo/left right_camera:=/my_stereo/right
39 | \endverbatim
40 |
41 |
42 | \subsubsection topics ROS topics
43 |
44 | Subscribes to:
45 | - \b "left": [sensor_msgs/Image] left raw image topic, for stereo cameras
46 | - \b "right": [sensor_msgs/Image] left raw image topic, for stereo cameras
47 | - \b "image": [sensor_msgs/Image] raw image topic, for monocular cameras
48 |
49 | Makes service calls to:
50 |
51 | \subsubsection services ROS services
52 | - \b "foo_service": [std_srvs/FooType] description of foo_service
53 | - \b "camera/set_camera_info": [sensor_msgs/SetCameraInfo] node of the camera for monocular
54 | - \b "left_camera/set_camera_info": [sensor_msgs/SetCameraInfo] node of the left stereo camera
55 | - \b "right_camera/set_camera_info": [sensor_msgs/SetCameraInfo] node of the left stereo camera
56 |
57 |
58 |
59 | */
60 |
--------------------------------------------------------------------------------
/camera_calibration/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | camera_calibration
5 | 7.0.0
6 |
7 | camera_calibration allows easy calibration of monocular or stereo
8 | cameras using a checkerboard calibration target.
9 |
10 |
11 | Vincent Rabaud
12 | Joshua Whitley
13 | Jacob Perron
14 | Michael Ferguson
15 |
16 | BSD
17 | https://index.ros.org/p/camera_calibration/
18 | https://github.com/ros-perception/image_pipeline/issues
19 | https://github.com/ros-perception/image_pipeline
20 | James Bowman
21 | Patrick Mihelich
22 |
23 | cv_bridge
24 | image_geometry
25 | message_filters
26 | python3-opencv
27 | rclpy
28 | std_srvs
29 | sensor_msgs
30 | python3-semver
31 |
32 | ament_copyright
33 | ament_flake8
34 | ament_pep257
35 | python3-pytest
36 | python3-requests
37 |
38 |
39 | ament_python
40 | rosdoc2.yaml
41 |
42 |
43 |
--------------------------------------------------------------------------------
/camera_calibration/pytest.ini:
--------------------------------------------------------------------------------
1 | [pytest]
2 | junit_family=xunit2
3 |
--------------------------------------------------------------------------------
/camera_calibration/resource/camera_calibration:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/resource/camera_calibration
--------------------------------------------------------------------------------
/camera_calibration/rosdoc2.yaml:
--------------------------------------------------------------------------------
1 | ## Default configuration, generated by rosdoc2.
2 |
3 | ## This 'attic section' self-documents this file's type and version.
4 | type: 'rosdoc2 config'
5 | version: 1
6 |
7 | ---
8 |
9 | settings:
10 | ## If this is true, a standard index page is generated in the output directory.
11 | ## It uses the package information from the 'package.xml' to show details
12 | ## about the package, creates a table of contents for the various builders
13 | ## that were run, and may contain links to things like build farm jobs for
14 | ## this package or links to other versions of this package.
15 |
16 | ## If false, you can still include content that would have been in the index
17 | ## into one of your '.rst' files from your Sphinx project, using the
18 | ## '.. include::' directive in Sphinx.
19 | ## For example, you could include it in a custom 'index.rst' so you can have
20 | ## the standard information followed by custom content.
21 |
22 | ## TODO(wjwwood): provide a concrete example of this (relative path?)
23 |
24 | ## If this is not specified explicitly, it defaults to 'true'.
25 | generate_package_index: true
26 |
27 | ## This setting is relevant mostly if the standard Python package layout cannot
28 | ## be assumed for 'sphinx-apidoc' invocation. The user can provide the path
29 | ## (relative to the 'package.xml' file) where the Python modules defined by this
30 | ## package are located.
31 | python_source: 'src/camera_calibration'
32 |
33 | ## This setting, if true, attempts to run `doxygen` and the `breathe`/`exhale`
34 | ## extensions to `sphinx` regardless of build type. This is most useful if the
35 | ## user would like to generate C/C++ API documentation for a package that is not
36 | ## of the `ament_cmake/cmake` build type.
37 | always_run_doxygen: false
38 |
39 | ## This setting, if true, attempts to run `sphinx-apidoc` regardless of build
40 | ## type. This is most useful if the user would like to generate Python API
41 | ## documentation for a package that is not of the `ament_python` build type.
42 | always_run_sphinx_apidoc: false
43 |
44 | # This setting, if provided, will override the build_type of this package
45 | # for documentation purposes only. If not provided, documentation will be
46 | # generated assuming the build_type in package.xml.
47 | # override_build_type: 'ament_python'
48 | builders:
49 | ## Each stanza represents a separate build step, performed by a specific 'builder'.
50 | ## The key of each stanza is the builder to use; this must be one of the
51 | ## available builders.
52 | ## The value of each stanza is a dictionary of settings for the builder that
53 | ## outputs to that directory.
54 | ## Required keys in the settings dictionary are:
55 | ## * 'output_dir' - determines output subdirectory for builder instance
56 | ## relative to --output-directory
57 | ## * 'name' - used when referencing the built docs from the index.
58 |
59 | - doxygen: {
60 | name: 'camera_calibration Public C/C++ API',
61 | output_dir: 'generated/doxygen'
62 | }
63 | - sphinx: {
64 | name: 'camera_calibration',
65 | ## This path is relative to output staging.
66 | doxygen_xml_directory: 'generated/doxygen/xml',
67 | output_dir: ''
68 | }
69 |
--------------------------------------------------------------------------------
/camera_calibration/setup.cfg:
--------------------------------------------------------------------------------
1 | [develop]
2 | script_dir=$base/lib/camera_calibration
3 | [install]
4 | install_scripts=$base/lib/camera_calibration
5 |
--------------------------------------------------------------------------------
/camera_calibration/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | from setuptools import setup, find_packages
3 |
4 | PACKAGE_NAME = "camera_calibration"
5 |
6 | setup(
7 | name=PACKAGE_NAME,
8 | version='7.0.0',
9 | packages=["camera_calibration", "camera_calibration.nodes"],
10 | data_files=[
11 | ('share/ament_index/resource_index/packages',
12 | ['resource/' + PACKAGE_NAME]),
13 | ('share/' + PACKAGE_NAME, ['package.xml']),
14 | ],
15 | py_modules=[],
16 | package_dir={'': 'src'},
17 | install_requires=[
18 | 'setuptools',
19 | ],
20 | zip_safe=True,
21 | author='James Bowman, Patrick Mihelich',
22 | maintainer='Vincent Rabaud, Steven Macenski, Joshua Whitley',
23 | maintainer_email='vincent.rabaud@gmail.com, stevenmacenski@gmail.com, whitleysoftwareservices@gmail.com',
24 | keywords=['ROS2'],
25 | description='Camera_calibration allows easy calibration of monocular or stereo cameras using a checkerboard calibration target .',
26 | license='BSD',
27 | tests_require=[
28 | 'pytest',
29 | 'requests'
30 | ],
31 | entry_points={
32 | 'console_scripts': [
33 | 'cameracalibrator = camera_calibration.nodes.cameracalibrator:main',
34 | 'cameracheck = camera_calibration.nodes.cameracheck:main',
35 | 'tarfile_calibration = camera_calibration.nodes.tarfile_calibration:main',
36 | ],
37 | },
38 | )
39 |
--------------------------------------------------------------------------------
/camera_calibration/src/camera_calibration/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/src/camera_calibration/__init__.py
--------------------------------------------------------------------------------
/camera_calibration/src/camera_calibration/nodes/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/camera_calibration/src/camera_calibration/nodes/__init__.py
--------------------------------------------------------------------------------
/camera_calibration/src/camera_calibration/nodes/cameracheck.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Software License Agreement (BSD License)
4 | #
5 | # Copyright (c) 2009, Willow Garage, Inc.
6 | # All rights reserved.
7 | #
8 | # Redistribution and use in source and binary forms, with or without
9 | # modification, are permitted provided that the following conditions
10 | # are met:
11 | #
12 | # * Redistributions of source code must retain the above copyright
13 | # notice, this list of conditions and the following disclaimer.
14 | # * Redistributions in binary form must reproduce the above
15 | # copyright notice, this list of conditions and the following
16 | # disclaimer in the documentation and/or other materials provided
17 | # with the distribution.
18 | # * Neither the name of the Willow Garage nor the names of its
19 | # contributors may be used to endorse or promote products derived
20 | # from this software without specific prior written permission.
21 | #
22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 | # POSSIBILITY OF SUCH DAMAGE.
34 |
35 | import rclpy
36 | from camera_calibration.camera_checker import CameraCheckerNode
37 |
38 |
39 | def main():
40 | from optparse import OptionParser
41 | parser = OptionParser()
42 | parser.add_option("-s", "--size", default="8x6",
43 | help="specify chessboard size as nxm [default: %default]")
44 | parser.add_option("-q", "--square", default=".108",
45 | help="specify chessboard square size in meters [default: %default]")
46 | parser.add_option(
47 | "--approximate", type="float", default=0.0,
48 | help="allow specified slop (in seconds) when pairing images from unsynchronized stereo cameras")
49 |
50 | options, _ = parser.parse_args(rclpy.utilities.remove_ros_args())
51 | rclpy.init()
52 |
53 | size = tuple([int(c) for c in options.size.split('x')])
54 | dim = float(options.square)
55 | approximate = float(options.approximate)
56 | node = CameraCheckerNode("cameracheck", size, dim, approximate)
57 | rclpy.spin(node)
58 |
59 |
60 | if __name__ == "__main__":
61 | main()
62 |
--------------------------------------------------------------------------------
/depth_image_proc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(depth_image_proc)
3 |
4 | # Default to C++14
5 | if(NOT CMAKE_CXX_STANDARD)
6 | set(CMAKE_CXX_STANDARD 14)
7 | endif()
8 |
9 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10 | add_compile_options(-Wall -Wextra -Wpedantic)
11 | endif()
12 |
13 | find_package(ament_cmake_auto REQUIRED)
14 | ament_auto_find_build_dependencies()
15 |
16 | find_package(Eigen3 QUIET)
17 | if(NOT EIGEN3_FOUND)
18 | find_package(Eigen REQUIRED)
19 | set(EIGEN3_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
20 | include_directories(include ${EIGEN3_INCLUDE_DIRS})
21 | endif()
22 |
23 | find_package(OpenCV REQUIRED)
24 |
25 | ament_auto_add_library(${PROJECT_NAME} SHARED
26 | src/conversions.cpp
27 | src/convert_metric.cpp
28 | src/crop_foremost.cpp
29 | src/disparity.cpp
30 | src/point_cloud_xyz.cpp
31 | src/point_cloud_xyzrgb.cpp
32 | src/point_cloud_xyzi.cpp
33 | src/point_cloud_xyz_radial.cpp
34 | src/point_cloud_xyzi_radial.cpp
35 | src/point_cloud_xyzrgb_radial.cpp
36 | src/register.cpp
37 | )
38 |
39 | # Register individual components and also build standalone nodes for each
40 | rclcpp_components_register_node(${PROJECT_NAME}
41 | PLUGIN "depth_image_proc::ConvertMetricNode"
42 | EXECUTABLE convert_metric_node
43 | )
44 | rclcpp_components_register_node(${PROJECT_NAME}
45 | PLUGIN "depth_image_proc::CropForemostNode"
46 | EXECUTABLE crop_foremost_node
47 | )
48 | rclcpp_components_register_node(${PROJECT_NAME}
49 | PLUGIN "depth_image_proc::DisparityNode"
50 | EXECUTABLE disparity_node
51 | )
52 | rclcpp_components_register_node(${PROJECT_NAME}
53 | PLUGIN "depth_image_proc::PointCloudXyzNode"
54 | EXECUTABLE point_cloud_xyz_node
55 | )
56 | rclcpp_components_register_node(${PROJECT_NAME}
57 | PLUGIN "depth_image_proc::PointCloudXyzrgbNode"
58 | EXECUTABLE point_cloud_xyzrgb_node
59 | )
60 | rclcpp_components_register_node(${PROJECT_NAME}
61 | PLUGIN "depth_image_proc::PointCloudXyziNode"
62 | EXECUTABLE point_cloud_xyzi_node
63 | )
64 | rclcpp_components_register_node(${PROJECT_NAME}
65 | PLUGIN "depth_image_proc::PointCloudXyzRadialNode"
66 | EXECUTABLE point_cloud_xyz_radial_node
67 | )
68 | rclcpp_components_register_node(${PROJECT_NAME}
69 | PLUGIN "depth_image_proc::PointCloudXyziRadialNode"
70 | EXECUTABLE point_cloud_xyzi_radial_node
71 | )
72 | rclcpp_components_register_node(${PROJECT_NAME}
73 | PLUGIN "depth_image_proc::PointCloudXyziRadialNode"
74 | EXECUTABLE point_cloud_xyzrgb_radial_node
75 | )
76 | rclcpp_components_register_node(${PROJECT_NAME}
77 | PLUGIN "depth_image_proc::RegisterNode"
78 | EXECUTABLE register_node
79 | )
80 |
81 | target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES})
82 |
83 | if(BUILD_TESTING)
84 | find_package(ament_lint_auto REQUIRED)
85 | ament_lint_auto_find_test_dependencies()
86 | endif()
87 |
88 | ament_auto_package(INSTALL_TO_SHARE launch)
89 |
--------------------------------------------------------------------------------
/depth_image_proc/doc/images/depth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/depth_image_proc/doc/images/depth.png
--------------------------------------------------------------------------------
/depth_image_proc/doc/images/depth_reg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/depth_image_proc/doc/images/depth_reg.png
--------------------------------------------------------------------------------
/depth_image_proc/doc/images/disparity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/depth_image_proc/doc/images/disparity.png
--------------------------------------------------------------------------------
/depth_image_proc/doc/images/rgb.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/depth_image_proc/doc/images/rgb.jpg
--------------------------------------------------------------------------------
/depth_image_proc/doc/images/rviz_xyz.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/depth_image_proc/doc/images/rviz_xyz.png
--------------------------------------------------------------------------------
/depth_image_proc/doc/images/rviz_xyzrgb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/depth_image_proc/doc/images/rviz_xyzrgb.png
--------------------------------------------------------------------------------
/depth_image_proc/doc/index.rst:
--------------------------------------------------------------------------------
1 | Overview
2 | ========
3 |
4 | ``depth_image_proc`` provides basic processing for depth images, much as
5 | ``image_proc`` does for traditional 2D images. The two packages are
6 | complementary; for example, you can (and should!) rectify your depth
7 | image before converting it to a point cloud.
8 |
9 | A variety of camera technologies can produce depth images:
10 |
11 | * The Kinect and related devices
12 | * Traditional stereo cameras
13 | * Time-of-flight cameras
14 |
15 | See REP 118 for details on depth image representation. The REP recommends
16 | that, wherever possible, producers and consumers of depth data use depth
17 | images (of type sensor_msgs/Image) instead of sensor_msgs/DisparityImage.
18 |
19 | All ROS 2 components (besides ``ConvertMetricNode``) in this package support
20 | both standard floating point depth images and OpenNI-specific uint16 depth
21 | images. Thus when working with OpenNI cameras (e.g. the Kinect), you can
22 | save a few CPU cycles by using the uint16 raw topics instead of the float
23 | topics.
24 |
25 | For an example of ``depth_image_proc`` in practice, examine the contents of
26 | ``openni2_launch``.
27 |
28 | .. toctree::
29 | :maxdepth: 2
30 |
31 | self
32 | components
33 | tutorials
34 | image_proc
35 |
36 | Indices and tables
37 | ==================
38 |
39 | * :ref:`genindex`
40 | * :ref:`search`
41 |
--------------------------------------------------------------------------------
/depth_image_proc/doc/tutorials.rst:
--------------------------------------------------------------------------------
1 | Tutorials
2 | =========
3 |
4 | .. _Launch depth_image_proc Components:
5 |
6 | Launching depth_image_proc Components
7 | -------------------------------------
8 | While each of the components is available as a ROS 2 node, the
9 | recommended way to build pipelines is using the components as
10 | this will save overhead by not having to serialize messages
11 | between components.
12 |
13 | .. code-block:: python
14 |
15 | from launch import LaunchDescription
16 | from launch_ros.actions import ComposableNodeContainer
17 | from launch_ros.descriptions import ComposableNode
18 |
19 | def generate_launch_description():
20 |
21 | container = ComposableNodeContainer(
22 | name='depth_image_proc_container',
23 | package='rclcpp_components',
24 | executable='component_container',
25 | composable_node_descriptions=[
26 | ComposableNode(
27 | package='depth_image_proc',
28 | plugin='depth_image_proc::PointCloudXyzrgbNode',
29 | name='point_cloud_xyzrgb_node',
30 | remappings=[
31 | ('rgb/image_rect_color', 'rgb/image'),
32 | ('depth_registered/image_rect', 'depth_registered/image'),
33 | ('points', 'depth_registered/points'),
34 | ],
35 | ),
36 | ]
37 | )
38 |
39 | return LaunchDescription([container])
40 |
41 | Using Compressed Image Transport
42 | --------------------------------
43 | All of the components and nodes in ``depth_image_proc`` support
44 | ``image_transport``. This allows a subscriber to specify the transport to
45 | be used. By default, this is ``raw``, which means an uncompressed
46 | ``sensor_msgs/Image``. When transmitting images over limited bandwidth
47 | networks, such as WiFi, it can be helpful to use ``compressed`` format.
48 |
49 | For the depth images, use the ``depth_image_transport`` parameter. For
50 | setting the transport for intensity or rgb images, the ``image_transport``
51 | parameter is used:
52 |
53 | .. code-block:: bash
54 |
55 | $ ros2 run depth_image_proc point_cloud_xyz_node --ros-args -p depth_image_transport:=compressed
56 |
57 | Remapping camera_info Topics
58 | ----------------------------
59 | See `tutorial in image_pipline `_.
60 |
61 | Using QoS Overrides
62 | -------------------
63 | See `tutorial in image_pipline `_.
64 |
--------------------------------------------------------------------------------
/depth_image_proc/include/depth_image_proc/depth_traits.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef DEPTH_IMAGE_PROC__DEPTH_TRAITS_HPP_
34 | #define DEPTH_IMAGE_PROC__DEPTH_TRAITS_HPP_
35 |
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | namespace depth_image_proc
42 | {
43 |
44 | // Encapsulate differences between processing float and uint16_t depths
45 | template
46 | struct DepthTraits {};
47 |
48 | template<>
49 | struct DepthTraits
50 | {
51 | static inline bool valid(uint16_t depth) {return depth != 0;}
52 | static inline float toMeters(uint16_t depth) {return depth * 0.001f;} // originally mm
53 | static inline uint16_t fromMeters(float depth) {return (depth * 1000.0f) + 0.5f;}
54 | // Do nothing - already zero-filled
55 | static inline void initializeBuffer(std::vector & buffer) {(void) buffer;}
56 | };
57 |
58 | template<>
59 | struct DepthTraits
60 | {
61 | static inline bool valid(float depth) {return std::isfinite(depth);}
62 | static inline float toMeters(float depth) {return depth;}
63 | static inline float fromMeters(float depth) {return depth;}
64 |
65 | static inline void initializeBuffer(std::vector & buffer)
66 | {
67 | float * start = reinterpret_cast(&buffer[0]);
68 | float * end = reinterpret_cast(&buffer[0] + buffer.size());
69 | std::fill(start, end, std::numeric_limits::quiet_NaN());
70 | }
71 | };
72 |
73 | } // namespace depth_image_proc
74 |
75 | #endif // DEPTH_IMAGE_PROC__DEPTH_TRAITS_HPP_
76 |
--------------------------------------------------------------------------------
/depth_image_proc/include/depth_image_proc/point_cloud_xyz.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef DEPTH_IMAGE_PROC__POINT_CLOUD_XYZ_HPP_
34 | #define DEPTH_IMAGE_PROC__POINT_CLOUD_XYZ_HPP_
35 |
36 | #include
37 |
38 | #include "depth_image_proc/visibility.h"
39 | #include "image_geometry/pinhole_camera_model.hpp"
40 |
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 |
49 | #include
50 |
51 | namespace depth_image_proc
52 | {
53 |
54 | namespace enc = sensor_msgs::image_encodings;
55 |
56 | class PointCloudXyzNode : public rclcpp::Node
57 | {
58 | public:
59 | DEPTH_IMAGE_PROC_PUBLIC PointCloudXyzNode(const rclcpp::NodeOptions & options);
60 |
61 | private:
62 | using PointCloud2 = sensor_msgs::msg::PointCloud2;
63 | using Image = sensor_msgs::msg::Image;
64 | using CameraInfo = sensor_msgs::msg::CameraInfo;
65 |
66 | // Subscriptions
67 | image_transport::CameraSubscriber sub_depth_;
68 | int queue_size_;
69 |
70 | // Parameters
71 | double invalid_depth_;
72 |
73 | // Publications
74 | std::mutex connect_mutex_;
75 | rclcpp::Publisher::SharedPtr pub_point_cloud_;
76 |
77 | image_geometry::PinholeCameraModel model_;
78 |
79 | void depthCb(
80 | const Image::ConstSharedPtr & depth_msg,
81 | const CameraInfo::ConstSharedPtr & info_msg);
82 | };
83 |
84 | } // namespace depth_image_proc
85 |
86 | #endif // DEPTH_IMAGE_PROC__POINT_CLOUD_XYZ_HPP_
87 |
--------------------------------------------------------------------------------
/depth_image_proc/include/depth_image_proc/point_cloud_xyz_radial.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef DEPTH_IMAGE_PROC__POINT_CLOUD_XYZ_RADIAL_HPP_
34 | #define DEPTH_IMAGE_PROC__POINT_CLOUD_XYZ_RADIAL_HPP_
35 |
36 | #include
37 | #include
38 | #include
39 |
40 | #include "depth_image_proc/visibility.h"
41 | #include "image_geometry/pinhole_camera_model.hpp"
42 |
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 |
50 | namespace depth_image_proc
51 | {
52 |
53 | class PointCloudXyzRadialNode : public rclcpp::Node
54 | {
55 | public:
56 | DEPTH_IMAGE_PROC_PUBLIC PointCloudXyzRadialNode(const rclcpp::NodeOptions & options);
57 |
58 | private:
59 | // Subscriptions
60 | image_transport::CameraSubscriber sub_depth_;
61 | int queue_size_;
62 |
63 | // Publications
64 | std::mutex connect_mutex_;
65 | using PointCloud = sensor_msgs::msg::PointCloud2;
66 | rclcpp::Publisher::SharedPtr pub_point_cloud_;
67 |
68 | std::vector D_;
69 | std::array K_;
70 |
71 | uint32_t width_;
72 | uint32_t height_;
73 |
74 | cv::Mat transform_;
75 |
76 | void depthCb(
77 | const sensor_msgs::msg::Image::ConstSharedPtr & depth_msg,
78 | const sensor_msgs::msg::CameraInfo::ConstSharedPtr & info_msg);
79 | };
80 |
81 | } // namespace depth_image_proc
82 |
83 | #endif // DEPTH_IMAGE_PROC__POINT_CLOUD_XYZ_RADIAL_HPP_
84 |
--------------------------------------------------------------------------------
/depth_image_proc/include/depth_image_proc/point_cloud_xyzi.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef DEPTH_IMAGE_PROC__POINT_CLOUD_XYZI_HPP_
34 | #define DEPTH_IMAGE_PROC__POINT_CLOUD_XYZI_HPP_
35 |
36 | #include
37 | #include
38 |
39 | #include "depth_image_proc/visibility.h"
40 | #include "image_geometry/pinhole_camera_model.hpp"
41 | #include "message_filters/subscriber.hpp"
42 | #include "message_filters/sync_policies/approximate_time.hpp"
43 | #include "message_filters/synchronizer.hpp"
44 |
45 | #include
46 | #include
47 | #include
48 | #include
49 | #include
50 |
51 | namespace depth_image_proc
52 | {
53 |
54 | namespace enc = sensor_msgs::image_encodings;
55 |
56 | class PointCloudXyziNode : public rclcpp::Node
57 | {
58 | public:
59 | DEPTH_IMAGE_PROC_PUBLIC PointCloudXyziNode(const rclcpp::NodeOptions & options);
60 |
61 | private:
62 | using Image = sensor_msgs::msg::Image;
63 | using CameraInfo = sensor_msgs::msg::CameraInfo;
64 | using PointCloud = sensor_msgs::msg::PointCloud2;
65 |
66 | // Subscriptions
67 | image_transport::SubscriberFilter sub_depth_, sub_intensity_;
68 | message_filters::Subscriber sub_info_;
69 | using SyncPolicy =
70 | message_filters::sync_policies::ApproximateTime;
71 | using Synchronizer = message_filters::Synchronizer;
72 | std::shared_ptr sync_;
73 |
74 | // parameters
75 | float invalid_depth_;
76 |
77 | // Publications
78 | std::mutex connect_mutex_;
79 | rclcpp::Publisher::SharedPtr pub_point_cloud_;
80 |
81 | image_geometry::PinholeCameraModel model_;
82 |
83 | void imageCb(
84 | const Image::ConstSharedPtr & depth_msg,
85 | const Image::ConstSharedPtr & intensity_msg,
86 | const CameraInfo::ConstSharedPtr & info_msg);
87 | };
88 |
89 | } // namespace depth_image_proc
90 |
91 | #endif // DEPTH_IMAGE_PROC__POINT_CLOUD_XYZI_HPP_
92 |
--------------------------------------------------------------------------------
/depth_image_proc/include/depth_image_proc/visibility.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 | #ifndef DEPTH_IMAGE_PROC__VISIBILITY_H_
33 | #define DEPTH_IMAGE_PROC__VISIBILITY_H_
34 |
35 | #ifdef __cplusplus
36 | extern "C"
37 | {
38 | #endif
39 |
40 | // This logic was borrowed (then namespaced) from the examples on the gcc wiki:
41 | // https://gcc.gnu.org/wiki/Visibility
42 |
43 | #if defined _WIN32 || defined __CYGWIN__
44 |
45 | #ifdef __GNUC__
46 | #define DEPTH_IMAGE_PROC_EXPORT __attribute__ ((dllexport))
47 | #define DEPTH_IMAGE_PROC_IMPORT __attribute__ ((dllimport))
48 | #else
49 | #define DEPTH_IMAGE_PROC_EXPORT __declspec(dllexport)
50 | #define DEPTH_IMAGE_PROC_IMPORT __declspec(dllimport)
51 | #endif
52 |
53 | #ifdef DEPTH_IMAGE_PROC_DLL
54 | #define DEPTH_IMAGE_PROC_PUBLIC DEPTH_IMAGE_PROC_EXPORT
55 | #else
56 | #define DEPTH_IMAGE_PROC_PUBLIC DEPTH_IMAGE_PROC_IMPORT
57 | #endif
58 |
59 | #define DEPTH_IMAGE_PROC_PUBLIC_TYPE DEPTH_IMAGE_PROC_PUBLIC
60 |
61 | #define DEPTH_IMAGE_PROC_LOCAL
62 |
63 | #else
64 |
65 | #define DEPTH_IMAGE_PROC_EXPORT __attribute__ ((visibility("default")))
66 | #define DEPTH_IMAGE_PROC_IMPORT
67 |
68 | #if __GNUC__ >= 4
69 | #define DEPTH_IMAGE_PROC_PUBLIC __attribute__ ((visibility("default")))
70 | #define DEPTH_IMAGE_PROC_LOCAL __attribute__ ((visibility("hidden")))
71 | #else
72 | #define DEPTH_IMAGE_PROC_PUBLIC
73 | #define DEPTH_IMAGE_PROC_LOCAL
74 | #endif
75 |
76 | #define DEPTH_IMAGE_PROC_PUBLIC_TYPE
77 | #endif
78 |
79 | #ifdef __cplusplus
80 | }
81 | #endif
82 |
83 | #endif // DEPTH_IMAGE_PROC__VISIBILITY_H_
84 |
--------------------------------------------------------------------------------
/depth_image_proc/launch/convert_metric.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import os
34 |
35 | from ament_index_python.packages import get_package_share_directory
36 | from launch import LaunchDescription
37 |
38 | import launch_ros.actions
39 | import launch_ros.descriptions
40 |
41 |
42 | def generate_launch_description():
43 | default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
44 | 'launch', 'rviz/convert_metric.rviz')
45 | return LaunchDescription([
46 | # install realsense from https://github.com/intel/ros2_intel_realsense
47 | launch_ros.actions.Node(
48 | package='realsense2_camera',
49 | executable='realsense2_camera_node',
50 | namespace='',
51 | output='screen'),
52 |
53 | # launch plugin through rclcpp_components container
54 | launch_ros.actions.ComposableNodeContainer(
55 | name='container',
56 | namespace='',
57 | package='rclcpp_components',
58 | executable='component_container',
59 | composable_node_descriptions=[
60 | # Driver itself
61 | launch_ros.descriptions.ComposableNode(
62 | package='depth_image_proc',
63 | plugin='depth_image_proc::ConvertMetricNode',
64 | name='convert_metric_node',
65 | remappings=[('image_raw', '/camera/depth/image_rect_raw'),
66 | ('image', '/camera/depth/converted_image')]
67 | ),
68 | ],
69 | output='screen',
70 | ),
71 |
72 | # rviz
73 | launch_ros.actions.Node(
74 | package='rviz2', executable='rviz2', output='screen',
75 | arguments=['--display-config', default_rviz]),
76 | ])
77 |
--------------------------------------------------------------------------------
/depth_image_proc/launch/crop_foremost.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import os
34 |
35 | from ament_index_python.packages import get_package_share_directory
36 | from launch import LaunchDescription
37 |
38 | import launch_ros.actions
39 | import launch_ros.descriptions
40 |
41 |
42 | def generate_launch_description():
43 | default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
44 | 'launch', 'rviz/crop_formost.rviz')
45 | return LaunchDescription([
46 | # install realsense from https://github.com/intel/ros2_intel_realsense
47 | launch_ros.actions.Node(
48 | package='realsense2_camera',
49 | executable='realsense2_camera_node',
50 | namespace='',
51 | output='screen'),
52 |
53 | launch_ros.actions.ComposableNodeContainer(
54 | name='container',
55 | namespace='',
56 | package='rclcpp_components',
57 | executable='component_container',
58 | composable_node_descriptions=[
59 | # Driver itself
60 | launch_ros.descriptions.ComposableNode(
61 | package='depth_image_proc',
62 | plugin='depth_image_proc::CropForemostNode',
63 | name='crop_foremost_node',
64 | remappings=[('image_raw', '/camera/depth/image_rect_raw'),
65 | ('image', '/camera/depth/converted_image')]
66 | ),
67 | ],
68 | output='screen',
69 | ),
70 |
71 | # rviz
72 | launch_ros.actions.Node(
73 | package='rviz2', executable='rviz2', output='screen',
74 | arguments=['--display-config', default_rviz]),
75 | ])
76 |
--------------------------------------------------------------------------------
/depth_image_proc/launch/point_cloud_xyz.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import os
34 |
35 | from ament_index_python.packages import get_package_share_directory
36 | from launch import LaunchDescription
37 |
38 | import launch_ros.actions
39 | import launch_ros.descriptions
40 |
41 |
42 | def generate_launch_description():
43 | default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
44 | 'launch', 'rviz/point_cloud_xyz.rviz')
45 | return LaunchDescription([
46 | # install realsense from https://github.com/intel/ros2_intel_realsense
47 | launch_ros.actions.Node(
48 | package='realsense2_camera',
49 | executable='realsense2_camera_node',
50 | namespace='',
51 | output='screen'),
52 |
53 | # launch plugin through rclcpp_components container
54 | launch_ros.actions.ComposableNodeContainer(
55 | name='container',
56 | namespace='',
57 | package='rclcpp_components',
58 | executable='component_container',
59 | composable_node_descriptions=[
60 | # Driver itself
61 | launch_ros.descriptions.ComposableNode(
62 | package='depth_image_proc',
63 | plugin='depth_image_proc::PointCloudXyzNode',
64 | name='point_cloud_xyz_node',
65 | remappings=[('image_rect', '/camera/depth/image_rect_raw'),
66 | ('image', '/camera/depth/converted_image')]
67 | ),
68 | ],
69 | output='screen',
70 | ),
71 |
72 | # rviz
73 | launch_ros.actions.Node(
74 | package='rviz2', executable='rviz2', output='screen',
75 | arguments=['--display-config', default_rviz]),
76 | ])
77 |
--------------------------------------------------------------------------------
/depth_image_proc/launch/point_cloud_xyz_radial.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import os
34 |
35 | from ament_index_python.packages import get_package_share_directory
36 | from launch import LaunchDescription
37 |
38 | import launch_ros.actions
39 | import launch_ros.descriptions
40 |
41 |
42 | def generate_launch_description():
43 | default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
44 | 'launch', 'rviz/point_cloud_xyz_radial.rviz')
45 | return LaunchDescription([
46 | # install realsense from https://github.com/intel/ros2_intel_realsense
47 | launch_ros.actions.Node(
48 | package='realsense2_camera',
49 | executable='realsense2_camera_node',
50 | namespace='',
51 | output='screen'),
52 |
53 | # launch plugin through rclcpp_components container
54 | launch_ros.actions.ComposableNodeContainer(
55 | name='container',
56 | namespace='',
57 | package='rclcpp_components',
58 | executable='component_container',
59 | composable_node_descriptions=[
60 | # Driver itself
61 | launch_ros.descriptions.ComposableNode(
62 | package='depth_image_proc',
63 | plugin='depth_image_proc::PointCloudXyzRadialNode',
64 | name='point_cloud_xyz_radial_node',
65 | remappings=[('depth/image_raw', '/camera/depth/image_rect_raw'),
66 | ('image', '/camera/depth/converted_image')]
67 | ),
68 | ],
69 | output='screen',
70 | ),
71 |
72 | # rviz
73 | launch_ros.actions.Node(
74 | package='rviz2', executable='rviz2', output='screen',
75 | arguments=['--display-config', default_rviz]),
76 | ])
77 |
--------------------------------------------------------------------------------
/depth_image_proc/launch/point_cloud_xyzrgb.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import os
34 |
35 | from ament_index_python.packages import get_package_share_directory
36 | from launch import LaunchDescription
37 |
38 | import launch_ros.actions
39 | import launch_ros.descriptions
40 |
41 |
42 | def generate_launch_description():
43 | default_rviz = os.path.join(get_package_share_directory('depth_image_proc'),
44 | 'launch', 'rviz/point_cloud_xyzrgb.rviz')
45 | return LaunchDescription([
46 | # install realsense from https://github.com/intel/ros2_intel_realsense
47 | launch_ros.actions.Node(
48 | package='realsense2_camera',
49 | executable='realsense2_camera_node',
50 | namespace='',
51 | parameters=[{'align_depth.enable': True},],
52 | output='screen'),
53 |
54 | # launch plugin through rclcpp_components container
55 | launch_ros.actions.ComposableNodeContainer(
56 | name='container',
57 | namespace='',
58 | package='rclcpp_components',
59 | executable='component_container',
60 | composable_node_descriptions=[
61 | # Driver itself
62 | launch_ros.descriptions.ComposableNode(
63 | package='depth_image_proc',
64 | plugin='depth_image_proc::PointCloudXyzrgbNode',
65 | name='point_cloud_xyzrgb_node',
66 | remappings=[('rgb/image_rect_color', '/camera/color/image_raw'),
67 | ('depth_registered/image_rect',
68 | '/camera/aligned_depth_to_color/image_raw'),
69 | ('points', '/camera/depth_registered/points')]
70 | ),
71 | ],
72 | output='screen',
73 | ),
74 |
75 | # rviz
76 | launch_ros.actions.Node(
77 | package='rviz2', executable='rviz2', output='screen',
78 | arguments=['--display-config', default_rviz]),
79 | ])
80 |
--------------------------------------------------------------------------------
/depth_image_proc/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | depth_image_proc
5 | 7.0.0
6 |
7 |
8 | Contains components for processing depth images such as those
9 | produced by OpenNI camera. Functions include creating disparity
10 | images and point clouds, as well as registering (reprojecting)
11 | a depth image into another camera frame.
12 |
13 |
14 |
15 | Vincent Rabaud
16 | Joshua Whitley
17 | Chris Ye
18 | Jacob Perron
19 | Michael Ferguson
20 |
21 | BSD
22 | https://index.ros.org/p/depth_image_proc/
23 | https://github.com/ros-perception/image_pipeline/issues
24 | https://github.com/ros-perception/image_pipeline
25 | Patrick Mihelich
26 |
27 | ament_cmake_auto
28 |
29 | class_loader
30 |
31 | cv_bridge
32 | image_geometry
33 | image_transport
34 | libopencv-dev
35 | image_proc
36 | message_filters
37 | rclcpp
38 | rclcpp_components
39 | sensor_msgs
40 | stereo_msgs
41 | tf2
42 | tf2_eigen
43 | tf2_ros
44 |
45 | ament_lint_auto
46 | ament_lint_common
47 |
48 |
49 | ament_cmake
50 |
51 |
52 |
--------------------------------------------------------------------------------
/image_pipeline/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(image_pipeline)
3 |
4 | # Default to C++14
5 | if(NOT CMAKE_CXX_STANDARD)
6 | set(CMAKE_CXX_STANDARD 14)
7 | endif()
8 |
9 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10 | add_compile_options(-Wall -Wextra -Wpedantic)
11 | endif()
12 |
13 | find_package(ament_cmake REQUIRED)
14 |
15 | if(BUILD_TESTING)
16 | find_package(ament_lint_auto REQUIRED)
17 | ament_lint_auto_find_test_dependencies()
18 | endif()
19 |
20 | ament_package()
21 |
--------------------------------------------------------------------------------
/image_pipeline/doc/changelog.rst:
--------------------------------------------------------------------------------
1 | Changelog Notes
2 | ===============
3 |
4 | While there is an official changelog for each package, this page summarizes
5 | the major changes between distributions
6 |
7 | Changes in Jazzy Jalisco
8 | ------------------------
9 | There are several major change between ``Iron`` and ``Jazzy``:
10 |
11 | * All components now properly support ``image_transport`` paramter,
12 | or ``depth_image_transport`` parameter if the topic is a depth image.
13 | In most places, this consists of simply adding the parameter, or making
14 | the parameter work, however two cases should be noted where the
15 | parameter was renamed:
16 |
17 | * image_view::ExtractImages: incorrectly named parameter ``transport``
18 | was renamed to more consistent ``image_transport``.
19 | * imaeg_view::StereoView: incorrectly named parameter ``transport``
20 | was renamed to more consistent ``image_transport``.
21 |
22 | * Improvements to QoS support:
23 |
24 | * Most components now support QoS overrides via ROS 2 parameters
25 | * The ``use_system_default_qos`` parameter has been removed from
26 | stereo_image_proc::DisparityNode and stereo_image_proc::PointCloudNode
27 | as the QoS overrides are the newer, preferred method.
28 |
29 | * All components now properly support remapping the ``camera_info`` topic
30 | for an associated ``image`` topic. For instance, if you remap ``image``
31 | to ``my/image`` then ``my/camera_info`` will be used. Previously you
32 | would have to manually remap the ``camera_info`` topic. See also
33 | :ref:`Remapping camera_info Topics`.
34 | * The input of ``depth_image_proc/point_cloud_xyz_radial`` is renamed
35 | from ``image_raw`` to ``depth/image_raw`` for consistency.
36 | * The inputs of ``depth_image_proc/point_cloud_xyzrgb_radial`` are renamed
37 | from ``depth_registered/image_rect`` to ``depth/image_raw`` and
38 | ``rgb/image_rect_color`` to ``rgb/image_raw`` to make clear that the
39 | unrectified camera projection matrix is used, and for consistency with
40 | other radial nodes.
41 | * The boolen parameter ``full_dp`` from the DisparityNode has been deleted
42 | and a new integer parameter ``sgbm_mode`` added to enable all the
43 | variations of the stereo matching algorithm SGBM available from the
44 | OpenCV library.
45 |
--------------------------------------------------------------------------------
/image_pipeline/doc/images/CameraCoords.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/image_pipeline/doc/images/CameraCoords.png
--------------------------------------------------------------------------------
/image_pipeline/doc/images/CameraInfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/image_pipeline/doc/images/CameraInfo.png
--------------------------------------------------------------------------------
/image_pipeline/doc/index.rst:
--------------------------------------------------------------------------------
1 | Overview
2 | ========
3 |
4 | The ``image_pipeline`` stack is designed to process raw camera images
5 | into useful inputs to vision algorithms: rectified mono/color images,
6 | stereo disparity images, and stereo point clouds. Components include:
7 |
8 | * **Calibration**: Cameras must be calibrated in order to relate the
9 | images they produce to the three-dimensional world. The
10 | ``camera_calibration`` package provides tools to calibrate monocular
11 | and stereo cameras in your ROS system. The :ref:`Camera Info` page
12 | provides a detailed description of the parameters used by the
13 | pipeline.
14 | * **Monocular processing**: The raw image stream can be piped through
15 | the ``image_proc`` node to remove camera distortion. The node also
16 | performs color interpolation for Bayer pattern color cameras.
17 | * **Stereo processing**: The ``stereo_image_proc`` package performs
18 | the duties of ``image_proc`` for a pair of cameras co-calibrated
19 | for stereo vision. It also uses stereo processing to produce
20 | disparity images and point clouds.
21 | * **Depth processing**: ``depth_image_proc`` provides components
22 | for processing depth images (as produced by the Kinect,
23 | time-of-flight cameras, etc.), such as producing point clouds.
24 | * **Visualization**: The ``image_view`` package provides a lightweight
25 | alternative to ``rviz2`` for viewing an image topic. It also includes
26 | a ``stereo_view`` tool for viewing stereo pairs and disparity images.
27 |
28 | .. toctree::
29 | :maxdepth: 2
30 |
31 | self
32 | camera_info
33 | tutorials
34 | changelog
35 | camera_calibration <../camera_calibration/index.html#http://>
36 | depth_image_proc <../depth_image_proc/index.html#http://>
37 | image_proc <../image_proc/index.html#http://>
38 | image_publisher <../image_publisher/index.html#http://>
39 | image_rotate <../image_rotate/index.html#http://>
40 | image_view <../image_view/index.html#http://>
41 | stereo_image_proc <../stereo_image_proc/index.html#http://>
42 |
43 | Indices and tables
44 | ==================
45 |
46 | * :ref:`genindex`
47 | * :ref:`search`
48 |
--------------------------------------------------------------------------------
/image_pipeline/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | image_pipeline
5 | 7.0.0
6 | image_pipeline fills the gap between getting raw images from a camera driver and higher-level vision processing.
7 |
8 | Vincent Rabaud
9 | Joshua Whitley
10 | Jacob Perron
11 | Michael Ferguson
12 |
13 | BSD
14 | https://index.ros.org/p/image_pipeline/
15 | https://github.com/ros-perception/image_pipeline/issues
16 | https://github.com/ros-perception/image_pipeline
17 | Patrick Mihelich
18 | James Bowman
19 |
20 | ament_cmake
21 |
22 |
23 | camera_calibration
24 | depth_image_proc
25 | image_proc
26 | image_publisher
27 | image_rotate
28 | image_view
29 | stereo_image_proc
30 |
31 | ament_lint_auto
32 | ament_cmake_lint_cmake
33 | ament_cmake_xmllint
34 |
35 |
36 | ament_cmake
37 | rosdoc2.yaml
38 |
39 |
40 |
--------------------------------------------------------------------------------
/image_pipeline/rosdoc2.yaml:
--------------------------------------------------------------------------------
1 | type: 'rosdoc2 config'
2 | version: 1
3 |
4 | ---
5 |
6 | settings:
7 | generate_package_index: false
8 | always_run_doxygen: false
9 | enable_breathe: false
10 | enable_exhale: false
11 | always_run_sphinx_apidoc: false
12 | override_build_type: 'ament_python'
13 | python_source: 'doc'
14 |
15 | builders:
16 | - sphinx: {
17 | name: 'image_pipeline',
18 | sphinx_sourcedir: 'doc',
19 | output_dir: ''
20 | }
--------------------------------------------------------------------------------
/image_proc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(image_proc)
3 |
4 | # ROS2 Flags
5 | if(NOT CMAKE_CXX_STANDARD)
6 | set(CMAKE_CXX_STANDARD 14)
7 | endif()
8 |
9 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10 | add_compile_options(-Wall -Wextra -Wpedantic)
11 | endif()
12 |
13 | find_package(ament_cmake_auto REQUIRED)
14 | ament_auto_find_build_dependencies()
15 |
16 | find_package(OpenCV REQUIRED)
17 | if(OpenCV_VERSION VERSION_LESS "3.2.0")
18 | message(FATAL "Minimum OpenCV version is 3.2.0 (found version ${OpenCV_VERSION})")
19 | endif()
20 |
21 | # image_proc library
22 | ament_auto_add_library(${PROJECT_NAME} SHARED
23 | src/${PROJECT_NAME}/processor.cpp
24 | )
25 | target_link_libraries(${PROJECT_NAME}
26 | ${OpenCV_LIBRARIES}
27 | )
28 |
29 | # rectify component and node
30 | ament_auto_add_library(rectify SHARED
31 | src/rectify.cpp)
32 | target_compile_definitions(rectify
33 | PRIVATE "COMPOSITION_BUILDING_DLL"
34 | )
35 | rclcpp_components_register_node(rectify
36 | PLUGIN "image_proc::RectifyNode"
37 | EXECUTABLE rectify_node
38 | )
39 |
40 | # debayer component and node
41 | ament_auto_add_library(debayer SHARED
42 | src/debayer.cpp
43 | src/edge_aware.cpp
44 | )
45 | target_compile_definitions(debayer
46 | PRIVATE "COMPOSITION_BUILDING_DLL"
47 | )
48 | rclcpp_components_register_node(debayer
49 | PLUGIN "image_proc::DebayerNode"
50 | EXECUTABLE debayer_node
51 | )
52 |
53 | # resize component and node
54 | ament_auto_add_library(resize SHARED
55 | src/resize.cpp
56 | )
57 | target_compile_definitions(resize
58 | PRIVATE "COMPOSITION_BUILDING_DLL"
59 | )
60 | rclcpp_components_register_node(resize
61 | PLUGIN "image_proc::ResizeNode"
62 | EXECUTABLE resize_node
63 | )
64 |
65 | # crop_decimate component and node
66 | ament_auto_add_library(crop_decimate SHARED
67 | src/crop_decimate.cpp
68 | )
69 | target_compile_definitions(crop_decimate
70 | PRIVATE "COMPOSITION_BUILDING_DLL"
71 | )
72 | rclcpp_components_register_node(crop_decimate
73 | PLUGIN "image_proc::CropDecimateNode"
74 | EXECUTABLE crop_decimate_node
75 | )
76 |
77 | # crop_non_zero component and node
78 | ament_auto_add_library(crop_non_zero SHARED
79 | src/crop_non_zero.cpp
80 | )
81 | target_compile_definitions(crop_non_zero
82 | PRIVATE "COMPOSITION_BUILDING_DLL"
83 | )
84 | rclcpp_components_register_node(crop_non_zero
85 | PLUGIN "image_proc::CropNonZeroNode"
86 | EXECUTABLE crop_non_zero_node
87 | )
88 |
89 | # track_marker component and node
90 | ament_auto_add_library(track_marker SHARED
91 | src/track_marker.cpp
92 | )
93 | target_compile_definitions(track_marker
94 | PRIVATE "COMPOSITION_BUILDING_DLL"
95 | )
96 | rclcpp_components_register_node(track_marker
97 | PLUGIN "image_proc::TrackMarkerNode"
98 | EXECUTABLE track_marker_node
99 | )
100 |
101 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
102 | target_link_libraries(image_proc "stdc++fs")
103 | endif()
104 |
105 | if(BUILD_TESTING)
106 | find_package(ament_lint_auto REQUIRED)
107 | ament_lint_auto_find_test_dependencies()
108 |
109 | add_definitions(-D_SRC_RESOURCES_DIR_PATH="${CMAKE_CURRENT_SOURCE_DIR}/test/resources")
110 |
111 | find_package(ament_cmake_gtest)
112 | ament_auto_add_gtest(test_rectify test/test_rectify.cpp)
113 |
114 | find_package(ament_cmake_gtest)
115 | ament_auto_add_gtest(rostest test/rostest.cpp)
116 | endif()
117 |
118 | ament_auto_package(INSTALL_TO_SHARE launch)
119 |
--------------------------------------------------------------------------------
/image_proc/doc/images/left_raw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/image_proc/doc/images/left_raw.png
--------------------------------------------------------------------------------
/image_proc/doc/images/left_rect_color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/image_proc/doc/images/left_rect_color.png
--------------------------------------------------------------------------------
/image_proc/doc/index.rst:
--------------------------------------------------------------------------------
1 | Overview
2 | ========
3 |
4 | This package contains a number of ROS 2 components and nodes for image processing.
5 |
6 | An example of what ``image_proc`` components can do is taking an original
7 | camera image, which is Bayered and distorted, and transforming it into a
8 | rectified image, de-Bayered and undistorted (amount of black border may
9 | vary depending on calibration):
10 |
11 | |raw| |color|
12 |
13 | .. |raw| image:: images/left_raw.png
14 | :width: 49%
15 |
16 | .. |color| image:: images/left_rect_color.png
17 | :width: 49%
18 |
19 | The images above were produced using the tutorial :ref:`Using image_proc Launch File`.
20 |
21 | .. toctree::
22 | :maxdepth: 2
23 |
24 | self
25 | components
26 | tutorials
27 | image_proc
28 |
29 | Indices and tables
30 | ==================
31 |
32 | * :ref:`genindex`
33 | * :ref:`search`
34 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/crop_decimate.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2008, 2019 Willow Garage, Inc., Steve Macenski, Joshua Whitley
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__CROP_DECIMATE_HPP_
34 | #define IMAGE_PROC__CROP_DECIMATE_HPP_
35 |
36 | #include
37 |
38 | #include "cv_bridge/cv_bridge.hpp"
39 |
40 | #include
41 | #include
42 | #include
43 | #include
44 |
45 | namespace image_proc
46 | {
47 |
48 | enum class CropDecimateModes
49 | {
50 | CropDecimate_NN = 0,
51 | CropDecimate_Linear = 1,
52 | CropDecimate_Cubic = 2,
53 | CropDecimate_Area = 3,
54 | CropDecimate_Lanczos4 = 4
55 | };
56 |
57 | using cv_bridge::CvImage;
58 | using cv_bridge::CvImageConstPtr;
59 | using cv_bridge::toCvShare;
60 |
61 | class CropDecimateNode : public rclcpp::Node
62 | {
63 | public:
64 | explicit CropDecimateNode(const rclcpp::NodeOptions &);
65 |
66 | private:
67 | image_transport::CameraSubscriber sub_;
68 | image_transport::CameraPublisher pub_;
69 | int queue_size_;
70 | std::string target_frame_id_;
71 | int decimation_x_, decimation_y_, offset_x_, offset_y_, width_, height_;
72 | std::string image_topic_;
73 | CropDecimateModes interpolation_;
74 |
75 | void imageCb(
76 | const sensor_msgs::msg::Image::ConstSharedPtr image_msg,
77 | const sensor_msgs::msg::CameraInfo::ConstSharedPtr info_msg);
78 | };
79 |
80 | } // namespace image_proc
81 |
82 | #endif // IMAGE_PROC__CROP_DECIMATE_HPP_
83 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/crop_non_zero.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2008, 2019 Willow Garage, Inc., Steve Macenski, Joshua Whitley
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__CROP_NON_ZERO_HPP_
34 | #define IMAGE_PROC__CROP_NON_ZERO_HPP_
35 |
36 | #include
37 | #include
38 |
39 | #include
40 | #include
41 | #include
42 |
43 | namespace image_proc
44 | {
45 |
46 | class CropNonZeroNode : public rclcpp::Node
47 | {
48 | public:
49 | explicit CropNonZeroNode(const rclcpp::NodeOptions &);
50 |
51 | private:
52 | std::string image_topic_;
53 |
54 | // Subscriptions
55 | image_transport::Subscriber sub_raw_;
56 |
57 | // Publications
58 | std::mutex connect_mutex_;
59 |
60 | image_transport::Publisher pub_;
61 |
62 | void imageCb(const sensor_msgs::msg::Image::ConstSharedPtr & raw_msg);
63 | };
64 | } // namespace image_proc
65 | #endif // IMAGE_PROC__CROP_NON_ZERO_HPP_
66 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/debayer.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2008, 2019, Willow Garage, Inc., Andreas Klintberg, Joshua Whitley
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__DEBAYER_HPP_
34 | #define IMAGE_PROC__DEBAYER_HPP_
35 |
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | namespace image_proc
42 | {
43 |
44 | class DebayerNode
45 | : public rclcpp::Node
46 | {
47 | public:
48 | explicit DebayerNode(const rclcpp::NodeOptions &);
49 |
50 | private:
51 | image_transport::Subscriber sub_raw_;
52 |
53 | int debayer_;
54 | std::string image_topic_;
55 |
56 | int debayer_bilinear_ = 0;
57 | int debayer_edgeaware_ = 1;
58 | int debayer_edgeaware_weighted_ = 2;
59 | int debayer_vng_ = 3;
60 |
61 | image_transport::Publisher pub_mono_;
62 | image_transport::Publisher pub_color_;
63 |
64 | void connectCb();
65 | void imageCb(const sensor_msgs::msg::Image::ConstSharedPtr & raw_msg);
66 | };
67 |
68 | } // namespace image_proc
69 |
70 | #endif // IMAGE_PROC__DEBAYER_HPP_
71 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/edge_aware.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2008, 2019, Willow Garage, Inc., Andreas Klintberg, Joshua Whitley
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__EDGE_AWARE_HPP_
34 | #define IMAGE_PROC__EDGE_AWARE_HPP_
35 |
36 | #include
37 |
38 | // Edge-aware debayering algorithms, intended for eventual inclusion in OpenCV.
39 |
40 | namespace image_proc
41 | {
42 |
43 | void debayerEdgeAware(const cv::Mat & bayer, cv::Mat & color);
44 | void debayerEdgeAwareWeighted(const cv::Mat & bayer, cv::Mat & color);
45 |
46 | } // namespace image_proc
47 |
48 | #endif // IMAGE_PROC__EDGE_AWARE_HPP_
49 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/processor.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2008, 2019 Willow Garage, Inc., Andreas Klintberg, Joshua Whitley
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__PROCESSOR_HPP_
34 | #define IMAGE_PROC__PROCESSOR_HPP_
35 |
36 | #include
37 |
38 | #include "image_geometry/pinhole_camera_model.hpp"
39 |
40 | #include
41 | #include
42 |
43 | namespace image_proc
44 | {
45 |
46 | struct ImageSet
47 | {
48 | std::string color_encoding;
49 | cv::Mat mono;
50 | cv::Mat rect;
51 | cv::Mat color;
52 | cv::Mat rect_color;
53 | };
54 |
55 | class Processor
56 | {
57 | public:
58 | Processor()
59 | : interpolation_(cv::INTER_LINEAR)
60 | {
61 | }
62 |
63 | int interpolation_;
64 |
65 | enum
66 | {
67 | MONO = 1 << 0,
68 | RECT = 1 << 1,
69 | COLOR = 1 << 2,
70 | RECT_COLOR = 1 << 3,
71 | ALL = MONO | RECT | COLOR | RECT_COLOR
72 | };
73 |
74 | bool process(
75 | const sensor_msgs::msg::Image::ConstSharedPtr & raw_image,
76 | const image_geometry::PinholeCameraModel & model,
77 | ImageSet & output, int flags = ALL) const;
78 | };
79 |
80 | } // namespace image_proc
81 |
82 | #endif // IMAGE_PROC__PROCESSOR_HPP_
83 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/rectify.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2008, 2019 Willow Garage, Inc., Andreas Klintberg, Joshua Whitley
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__RECTIFY_HPP_
34 | #define IMAGE_PROC__RECTIFY_HPP_
35 |
36 | #include
37 | #include
38 |
39 | #include "image_geometry/pinhole_camera_model.hpp"
40 |
41 | #include
42 | #include
43 | #include
44 | #include
45 |
46 | namespace image_proc
47 | {
48 |
49 | class RectifyNode
50 | : public rclcpp::Node
51 | {
52 | public:
53 | explicit RectifyNode(const rclcpp::NodeOptions &);
54 |
55 | private:
56 | image_transport::CameraSubscriber sub_camera_;
57 |
58 | int queue_size_;
59 | int interpolation_;
60 | std::string image_topic_;
61 | image_transport::Publisher pub_rect_;
62 |
63 | // Processing state (note: only safe because we're using single-threaded NodeHandle!)
64 | image_geometry::PinholeCameraModel model_;
65 |
66 | void imageCb(
67 | const sensor_msgs::msg::Image::ConstSharedPtr & image_msg,
68 | const sensor_msgs::msg::CameraInfo::ConstSharedPtr & info_msg);
69 | };
70 |
71 | } // namespace image_proc
72 |
73 | #endif // IMAGE_PROC__RECTIFY_HPP_
74 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/resize.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2008, 2019 Willow Garage, Inc., Andreas Klintberg, Joshua Whitley
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__RESIZE_HPP_
34 | #define IMAGE_PROC__RESIZE_HPP_
35 |
36 | #include
37 | #include
38 |
39 | #include
40 | #include
41 | #include
42 | #include
43 |
44 | namespace image_proc
45 | {
46 |
47 | class ResizeNode
48 | : public rclcpp::Node
49 | {
50 | public:
51 | explicit ResizeNode(const rclcpp::NodeOptions &);
52 |
53 | protected:
54 | image_transport::CameraPublisher pub_image_;
55 | image_transport::CameraSubscriber sub_image_;
56 |
57 | int interpolation_;
58 | bool use_scale_;
59 | double scale_height_;
60 | double scale_width_;
61 | int height_;
62 | int width_;
63 | std::string image_topic_;
64 |
65 | cv_bridge::CvImage scaled_cv_;
66 |
67 | std::mutex connect_mutex_;
68 |
69 | void connectCb();
70 |
71 | void imageCb(
72 | sensor_msgs::msg::Image::ConstSharedPtr image_msg,
73 | sensor_msgs::msg::CameraInfo::ConstSharedPtr info_msg);
74 | };
75 |
76 | } // namespace image_proc
77 |
78 | #endif // IMAGE_PROC__RESIZE_HPP_
79 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/track_marker.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2024 Open Navigation LLC
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__TRACK_MARKER_HPP_
34 | #define IMAGE_PROC__TRACK_MARKER_HPP_
35 |
36 | #include
37 | #include
38 | #include
39 |
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 |
47 | namespace image_proc
48 | {
49 |
50 | class TrackMarkerNode : public rclcpp::Node
51 | {
52 | public:
53 | explicit TrackMarkerNode(const rclcpp::NodeOptions &);
54 |
55 | private:
56 | image_transport::CameraSubscriber sub_camera_;
57 |
58 | int queue_size_;
59 | int marker_id_;
60 | double marker_size_;
61 | std::string image_topic_;
62 | rclcpp::Publisher::SharedPtr pub_;
63 |
64 | cv::Ptr detector_params_;
65 | cv::Ptr dictionary_;
66 |
67 | void imageCb(
68 | const sensor_msgs::msg::Image::ConstSharedPtr & image_msg,
69 | const sensor_msgs::msg::CameraInfo::ConstSharedPtr & info_msg);
70 | };
71 |
72 | } // namespace image_proc
73 |
74 | #endif // IMAGE_PROC__TRACK_MARKER_HPP_
75 |
--------------------------------------------------------------------------------
/image_proc/include/image_proc/utils.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2023 Willow Garage, Inc., Michal Wojcik
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of {copyright_holder} nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PROC__UTILS_HPP_
34 | #define IMAGE_PROC__UTILS_HPP_
35 |
36 | #include
37 |
38 | #include
39 |
40 | namespace image_proc
41 | {
42 |
43 | inline
44 | rmw_qos_profile_t getTopicQosProfile(rclcpp::Node * node, const std::string & topic)
45 | {
46 | /**
47 | * Given a topic name, get the QoS profile with which it is being published.
48 |  * Replaces history and depth settings with default sensor values since they cannot be retrieved.
49 | * @param node pointer to the ROS node
50 | * @param topic name of the topic
51 | * @returns QoS profile of the publisher to the topic. If there are several publishers, it returns
52 | * returns the profile of the first one on the list. If no publishers exist, it returns
53 | * the sensor data profile.
54 | */
55 | std::string topic_resolved = node->get_node_base_interface()->resolve_topic_or_service_name(
56 | topic, false);
57 | auto topics_info = node->get_publishers_info_by_topic(topic_resolved);
58 | if (topics_info.size()) {
59 | auto profile = topics_info[0].qos_profile().get_rmw_qos_profile();
60 | profile.history = rmw_qos_profile_sensor_data.history;
61 | profile.depth = rmw_qos_profile_sensor_data.depth;
62 | return profile;
63 | } else {
64 | return rmw_qos_profile_sensor_data;
65 | }
66 | }
67 |
68 | } // namespace image_proc
69 |
70 | #endif // IMAGE_PROC__UTILS_HPP_
71 |
--------------------------------------------------------------------------------
/image_proc/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | image_proc
5 | 7.0.0
6 | Single image rectification and color processing.
7 |
8 | Vincent Rabaud
9 | Joshua Whitley
10 | Jacob Perron
11 | Michael Ferguson
12 |
13 | BSD
14 | https://index.ros.org/p/image_proc/
15 | https://github.com/ros-perception/image_pipeline/issues
16 | https://github.com/ros-perception/image_pipeline
17 | Patrick Mihelich
18 | Kurt Konolige
19 | Jeremy Leibs
20 |
21 | ament_cmake_auto
22 |
23 | camera_calibration_parsers
24 | cv_bridge
25 | image_geometry
26 | image_transport
27 | geometry_msgs
28 | libopencv-dev
29 | rclcpp
30 | rclcpp_components
31 | rcutils
32 | sensor_msgs
33 | tf2
34 | tf2_geometry_msgs
35 | tracetools_image_pipeline
36 |
37 | ament_lint_auto
38 | ament_lint_common
39 |
40 |
41 | ament_cmake
42 |
43 |
44 |
--------------------------------------------------------------------------------
/image_proc/test/resources/calibration_file.ini:
--------------------------------------------------------------------------------
1 | [image]
2 |
3 | #comment
4 | width
5 | 640
6 |
7 | ; comment
8 | height
9 | 480
10 |
11 | [mono_left]
12 |
13 | camera matrix
14 | 369.344588 0.000000 320.739078
15 | 0.000000 367.154330 203.592450
16 | 0.000000 0.000000 1.000000
17 |
18 | distortion
19 | 0.189544 -0.018229 -0.000630 0.000054 -0.000212
20 |
21 | rectification
22 | 1.000000 0.000000 0.000000
23 | 0.000000 1.000000 0.000000
24 | 0.000000 0.000000 1.000000
25 |
26 | projection
27 | 262.927429 0.000000 320.984481 0.000000
28 | 0.000000 302.056213 188.592437 0.000000
29 | 0.000000 0.000000 1.000000 0.000000
30 |
--------------------------------------------------------------------------------
/image_proc/test/resources/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/image_proc/test/resources/logo.png
--------------------------------------------------------------------------------
/image_publisher/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(image_publisher)
3 |
4 | # Default to C++14
5 | if(NOT CMAKE_CXX_STANDARD)
6 | set(CMAKE_CXX_STANDARD 14)
7 | endif()
8 |
9 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10 | add_compile_options(-Wall -Wextra -Wpedantic)
11 | endif()
12 |
13 | find_package(ament_cmake_auto REQUIRED)
14 | find_package(camera_info_manager REQUIRED)
15 | ament_auto_find_build_dependencies()
16 |
17 | find_package(OpenCV REQUIRED COMPONENTS core imgcodecs videoio)
18 | message(STATUS "opencv version ${OpenCV_VERSION}")
19 |
20 | ament_auto_add_library(image_publisher SHARED src/image_publisher.cpp)
21 | target_link_libraries(image_publisher ${OpenCV_LIBRARIES} camera_info_manager::camera_info_manager)
22 | rclcpp_components_register_nodes(image_publisher "${PROJECT_NAME}::ImagePublisher")
23 | set(node_plugins "${node_plugins}${PROJECT_NAME}::ImagePublisher;$\n")
24 |
25 | ament_auto_add_executable(image_publisher_node src/image_publisher_node.cpp)
26 |
27 | if(BUILD_TESTING)
28 | find_package(ament_lint_auto REQUIRED)
29 | ament_lint_auto_find_test_dependencies()
30 | endif()
31 |
32 | ament_auto_package(INSTALL_TO_SHARE launch)
33 |
--------------------------------------------------------------------------------
/image_publisher/doc/components.rst:
--------------------------------------------------------------------------------
1 | Nodes and Components
2 | ====================
3 |
4 | image_publisher::ImagePublisher
5 | -------------------------------
6 | Component to publish sensor_msgs/Image, requires filename argument.
7 | Also avialable as a ROS 2 node named ``image_publisher``.
8 |
9 | Published Topics
10 | ^^^^^^^^^^^^^^^^
11 | * **image_raw** (sensor_msgs/Image): ROS Image message of your input file.
12 | * **camera_info** (sensor_msgs/CameraInfo): CameraInfo published along with Image.
13 |
14 | Parameters
15 | ^^^^^^^^^^
16 | * **filename** (string, default: ""): Name of image file to be published.
17 | * **field_of_view** (double, default: 0): Camera field of view (deg) used to calculate focal length for camera info topic.
18 | * **flip_horizontal** (bool, default: false): Flip output image horizontally.
19 | * **flip_vertical** (bool, default: false): Flip output image vertically.
20 | * **frame_id** (string, default: "camera") Frame id inserted in published
21 | image and camera_info.
22 | * **publish_rate** (double, default: 10): Rate to publish image (hz).
23 | * **camera_info_uri** (string, default: ""): Path to camera info.
24 |
--------------------------------------------------------------------------------
/image_publisher/doc/index.rst:
--------------------------------------------------------------------------------
1 | Overview
2 | ========
3 |
4 | ``image_publisher`` provides a node/component for publishing images
5 | as a ROS 2 image topic.
6 |
7 | Simplest example is:
8 |
9 | .. code-block:: bash
10 |
11 | ros2 run image_publisher image_publisher /opt/ros/rolling/share/rviz/images/splash.png
12 |
13 | .. toctree::
14 | :maxdepth: 2
15 |
16 | self
17 | components
18 | image_publisher
19 |
20 | Indices and tables
21 | ==================
22 |
23 | * :ref:`genindex`
24 | * :ref:`search`
25 |
--------------------------------------------------------------------------------
/image_publisher/include/image_publisher/image_publisher.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_PUBLISHER__IMAGE_PUBLISHER_HPP_
34 | #define IMAGE_PUBLISHER__IMAGE_PUBLISHER_HPP_
35 |
36 | #include
37 |
38 | #include
39 | #include
40 | #include
41 | #include
42 |
43 | namespace image_publisher
44 | {
45 |
46 | class ImagePublisher : public rclcpp::Node
47 | {
48 | public:
49 | ImagePublisher(
50 | const rclcpp::NodeOptions & options,
51 | const std::string & filename = "");
52 |
53 | protected:
54 | void onInit();
55 | void doWork();
56 | void reconfigureCallback();
57 |
58 | private:
59 | image_transport::CameraPublisher pub_;
60 |
61 | cv::VideoCapture cap_;
62 | cv::Mat image_;
63 | rclcpp::TimerBase::SharedPtr timer_;
64 |
65 | rclcpp::Node::OnSetParametersCallbackHandle::SharedPtr on_set_parameters_callback_handle_;
66 |
67 | std::string filename_;
68 | double field_of_view_;
69 | bool flip_horizontal_;
70 | bool flip_vertical_;
71 | bool image_flipped_;
72 | bool retry_; // If enabled will retry loading image from the filename_
73 | int timeout_; // Time after which retrying starts
74 |
75 | std::string frame_id_;
76 | double publish_rate_;
77 | std::string camera_info_url_;
78 | bool flip_image_;
79 | int flip_value_;
80 | sensor_msgs::msg::CameraInfo camera_info_;
81 | };
82 |
83 | } // namespace image_publisher
84 |
85 | #endif // IMAGE_PUBLISHER__IMAGE_PUBLISHER_HPP_
86 |
--------------------------------------------------------------------------------
/image_publisher/include/image_publisher/visibility.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 | #ifndef IMAGE_PUBLISHER__VISIBILITY_H_
33 | #define IMAGE_PUBLISHER__VISIBILITY_H_
34 |
35 | #ifdef __cplusplus
36 | extern "C"
37 | {
38 | #endif
39 |
40 | // This logic was borrowed (then namespaced) from the examples on the gcc wiki:
41 | // https://gcc.gnu.org/wiki/Visibility
42 |
43 | #if defined _WIN32 || defined __CYGWIN__
44 |
45 | #ifdef __GNUC__
46 | #define IMAGE_PUBLISHER_EXPORT __attribute__ ((dllexport))
47 | #define IMAGE_PUBLISHER_IMPORT __attribute__ ((dllimport))
48 | #else
49 | #define IMAGE_PUBLISHER_EXPORT __declspec(dllexport)
50 | #define IMAGE_PUBLISHER_IMPORT __declspec(dllimport)
51 | #endif
52 |
53 | #ifdef IMAGE_PUBLISHER_DLL
54 | #define IMAGE_PUBLISHER_PUBLIC IMAGE_PUBLISHER_EXPORT
55 | #else
56 | #define IMAGE_PUBLISHER_PUBLIC IMAGE_PUBLISHER_IMPORT
57 | #endif
58 |
59 | #define IMAGE_PUBLISHER_PUBLIC_TYPE IMAGE_PUBLISHER_PUBLIC
60 |
61 | #define IMAGE_PUBLISHER_LOCAL
62 |
63 | #else
64 |
65 | #define IMAGE_PUBLISHER_EXPORT __attribute__ ((visibility("default")))
66 | #define IMAGE_PUBLISHER_IMPORT
67 |
68 | #if __GNUC__ >= 4
69 | #define IMAGE_PUBLISHER_PUBLIC __attribute__ ((visibility("default")))
70 | #define IMAGE_PUBLISHER_LOCAL __attribute__ ((visibility("hidden")))
71 | #else
72 | #define IMAGE_PUBLISHER_PUBLIC
73 | #define IMAGE_PUBLISHER_LOCAL
74 | #endif
75 |
76 | #define IMAGE_PUBLISHER_PUBLIC_TYPE
77 | #endif
78 |
79 | #ifdef __cplusplus
80 | }
81 | #endif
82 |
83 | #endif // IMAGE_PUBLISHER__VISIBILITY_H_
84 |
--------------------------------------------------------------------------------
/image_publisher/launch/image_publisher_component_file.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import os
34 |
35 | from ament_index_python.packages import get_package_share_directory
36 | from launch import LaunchDescription
37 | from launch.actions import DeclareLaunchArgument
38 | from launch.substitutions import LaunchConfiguration
39 | from launch_ros.actions import ComposableNodeContainer
40 | from launch_ros.descriptions import ComposableNode
41 |
42 |
43 | # This is basically the same as image_publsher_file.launch.py - but using the component
44 | def generate_launch_description():
45 | filename = os.path.join(get_package_share_directory('image_publisher'), 'launch',
46 | 'splash.png')
47 | use_sim_time = LaunchConfiguration('use_sim_time', default='false')
48 | return LaunchDescription([
49 |
50 | DeclareLaunchArgument(
51 | 'use_sim_time',
52 | default_value='false',
53 | description='Use simulation clock if true'),
54 |
55 | ComposableNodeContainer(
56 | name='image_publisher_container',
57 | namespace='',
58 | package='rclcpp_components',
59 | executable='component_container',
60 | composable_node_descriptions=[
61 | ComposableNode(
62 | package='image_publisher',
63 | plugin='image_publisher::ImagePublisher',
64 | name='image_publisher',
65 | parameters=[{'filename': filename,
66 | 'use_sim_time': use_sim_time}],
67 | remappings=[('image_raw', '/camera/image_raw'),
68 | ('camera_info', '/camera/camera_info')],
69 | )
70 | ],
71 | output='screen',
72 | ),
73 | ])
74 |
--------------------------------------------------------------------------------
/image_publisher/launch/image_publisher_file.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | import os
34 |
35 | from ament_index_python.packages import get_package_share_directory
36 | from launch import LaunchDescription
37 | from launch.actions import DeclareLaunchArgument
38 | from launch.substitutions import LaunchConfiguration
39 | import launch_ros.actions
40 |
41 |
42 | def generate_launch_description():
43 | filename = os.path.join(get_package_share_directory('image_publisher'), 'launch',
44 | 'splash.png')
45 | use_sim_time = LaunchConfiguration('use_sim_time', default='false')
46 | return LaunchDescription([
47 |
48 | DeclareLaunchArgument(
49 | 'use_sim_time',
50 | default_value='false',
51 | description='Use simulation clock if true'),
52 |
53 | launch_ros.actions.Node(
54 | package='image_publisher', executable='image_publisher_node', output='screen',
55 | arguments=[filename],
56 | parameters=[{'use_sim_time': use_sim_time}],
57 | remappings=[('image_raw', '/camera/image_raw'),
58 | ('camera_info', '/camera/camera_info')]),
59 | ])
60 |
--------------------------------------------------------------------------------
/image_publisher/launch/image_publisher_mono.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | from launch import LaunchDescription
34 | from launch.actions import DeclareLaunchArgument
35 | from launch.substitutions import LaunchConfiguration
36 | import launch_ros.actions
37 |
38 |
39 | def generate_launch_description():
40 | device_0 = '0'
41 | use_sim_time = LaunchConfiguration('use_sim_time', default='false')
42 | return LaunchDescription([
43 |
44 | DeclareLaunchArgument(
45 | 'use_sim_time',
46 | default_value='false',
47 | description='Use simulation clock if true'),
48 |
49 | launch_ros.actions.Node(
50 | package='image_publisher', executable='image_publisher_node', output='screen',
51 | arguments=[device_0],
52 | parameters=[{'use_sim_time': use_sim_time}],
53 | remappings=[('image_raw', '/camera/image_raw'),
54 | ('camera_info', '/camera/camera_info')]),
55 | ])
56 |
--------------------------------------------------------------------------------
/image_publisher/launch/image_publisher_stereo.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | from launch import LaunchDescription
34 | from launch.actions import DeclareLaunchArgument
35 | from launch.substitutions import LaunchConfiguration
36 | import launch_ros.actions
37 |
38 |
39 | def generate_launch_description():
40 | device_0 = '0'
41 | device_1 = '1'
42 | use_sim_time = LaunchConfiguration('use_sim_time', default='false')
43 | return LaunchDescription([
44 |
45 | DeclareLaunchArgument(
46 | 'use_sim_time',
47 | default_value='false',
48 | description='Use simulation clock if true'),
49 |
50 | # image_publisher stereo left
51 | launch_ros.actions.Node(
52 | package='image_publisher', executable='image_publisher_node', output='screen',
53 | arguments=[device_0],
54 | parameters=[{'use_sim_time': use_sim_time}],
55 | name='image_publisher_left',
56 | remappings=[('image_raw', '/left/image_raw'),
57 | ('camera_info', '/left/camera_info')]),
58 |
59 | # image_publisher stereo right
60 | launch_ros.actions.Node(
61 | package='image_publisher', executable='image_publisher_node', output='screen',
62 | arguments=[device_1],
63 | parameters=[{'use_sim_time': use_sim_time}],
64 | name='image_publisher_right',
65 | remappings=[('image_raw', '/right/image_raw'),
66 | ('camera_info', '/right/camera_info')]),
67 | ])
68 |
--------------------------------------------------------------------------------
/image_publisher/launch/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/image_publisher/launch/splash.png
--------------------------------------------------------------------------------
/image_publisher/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | image_publisher
5 | 7.0.0
6 |
7 |
8 | Contains a node publish an image stream from single image file
9 | or avi motion file.
10 |
11 |
12 |
13 | Vincent Rabaud
14 | Joshua Whitley
15 | Chris Ye
16 | Jacob Perron
17 | Michael Ferguson
18 |
19 | BSD
20 | https://index.ros.org/p/image_publisher/
21 | https://github.com/ros-perception/image_pipeline/issues
22 | https://github.com/ros-perception/image_pipeline
23 | Kei Okada
24 |
25 | ament_cmake_auto
26 |
27 | camera_info_manager
28 | cv_bridge
29 | image_transport
30 | rcl_interfaces
31 | rclcpp
32 | rclcpp_components
33 |
34 | ament_lint_auto
35 | ament_lint_common
36 |
37 |
38 | ament_cmake
39 |
40 |
41 |
--------------------------------------------------------------------------------
/image_publisher/src/image_publisher_node.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #include
34 |
35 | #include
36 |
37 | int main(int argc, char ** argv)
38 | {
39 | // Force flush of the stdout buffer.
40 | setvbuf(stdout, NULL, _IONBF, BUFSIZ);
41 |
42 | rclcpp::init(argc, argv);
43 |
44 | if (argc <= 1) {
45 | RCUTILS_LOG_ERROR(
46 | "image_publisher requires filename. Typical command-line usage:\n"
47 | "\t$ ros2 run image_publisher image_publisher ");
48 | return 1;
49 | }
50 |
51 | rclcpp::NodeOptions options;
52 | auto publisher = std::make_shared(options, argv[1]);
53 |
54 | rclcpp::spin(publisher);
55 | rclcpp::shutdown();
56 | return 0;
57 | }
58 |
--------------------------------------------------------------------------------
/image_rotate/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(image_rotate)
3 |
4 | # Default to C++14
5 | if(NOT CMAKE_CXX_STANDARD)
6 | set(CMAKE_CXX_STANDARD 14)
7 | endif()
8 |
9 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10 | add_compile_options(-Wall -Wextra -Wpedantic)
11 | endif()
12 |
13 | find_package(ament_cmake_auto REQUIRED)
14 | ament_auto_find_build_dependencies()
15 |
16 | find_package(OpenCV REQUIRED core imgproc)
17 |
18 | ament_auto_add_library(${PROJECT_NAME} SHARED src/image_rotate_node.cpp)
19 | target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES})
20 | rclcpp_components_register_nodes(${PROJECT_NAME} "${PROJECT_NAME}::ImageRotateNode")
21 | set(node_plugins "${node_plugins}${PROJECT_NAME}::ImageRotateNode;$\n")
22 |
23 | ament_auto_add_executable(image_rotate_bin src/image_rotate.cpp)
24 | set_target_properties(image_rotate_bin PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
25 | target_link_libraries(image_rotate_bin ${OpenCV_LIBRARIES} ${PROJECT_NAME})
26 |
27 | ament_auto_add_library(image_flip SHARED src/image_flip.cpp)
28 | target_link_libraries(image_flip ${OpenCV_LIBRARIES})
29 | rclcpp_components_register_node(image_flip
30 | PLUGIN "${PROJECT_NAME}::ImageFlipNode"
31 | EXECUTABLE image_flip_node
32 | )
33 |
34 | if(BUILD_TESTING)
35 | find_package(ament_lint_auto REQUIRED)
36 | ament_lint_auto_find_test_dependencies()
37 | endif()
38 |
39 | ament_auto_package(INSTALL_TO_SHARE launch)
40 |
--------------------------------------------------------------------------------
/image_rotate/doc/images/image_rotate.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/image_rotate/doc/images/image_rotate.jpg
--------------------------------------------------------------------------------
/image_rotate/doc/index.rst:
--------------------------------------------------------------------------------
1 | Overview
2 | ========
3 |
4 | This package contains a node that rotates an image stream in a way that
5 | minimizes the angle between a vector in some arbitrary frame and a vector
6 | in the camera frame. The frame of the outgoing image is published by the
7 | node.
8 |
9 | This node is intended to allow camera images to be visualized in an
10 | orientation that is more intuitive than the hardware-constrained
11 | orientation of the physical camera. This is particularly helpful,
12 | for example, to show images from the PR2's forearm cameras with a
13 | consistent up direction, despite the fact that the forearms need to
14 | rotate in arbitrary ways during manipulation.
15 |
16 | It is not recommended to use the output from this node for further
17 | computation, as it interpolates the source image, introduces black
18 | borders, and does not output a ``camera_info``.
19 |
20 | |image_rotate|
21 |
22 | .. |image_rotate| image:: images/image_rotate.jpg
23 |
24 | .. toctree::
25 | :maxdepth: 2
26 |
27 | self
28 | components
29 | image_rotate
30 |
31 | Indices and tables
32 | ==================
33 |
34 | * :ref:`genindex`
35 | * :ref:`search`
36 |
--------------------------------------------------------------------------------
/image_rotate/include/image_rotate/visibility.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #ifndef IMAGE_ROTATE__VISIBILITY_H_
34 | #define IMAGE_ROTATE__VISIBILITY_H_
35 |
36 | // This logic was borrowed (then namespaced) from the examples on the gcc wiki:
37 | // https://gcc.gnu.org/wiki/Visibility
38 |
39 | #if defined _WIN32 || defined __CYGWIN__
40 |
41 | #ifdef __GNUC__
42 | #define IMAGE_ROTATE_EXPORT __attribute__ ((dllexport))
43 | #define IMAGE_ROTATE_IMPORT __attribute__ ((dllimport))
44 | #else
45 | #define IMAGE_ROTATE_EXPORT __declspec(dllexport)
46 | #define IMAGE_ROTATE_IMPORT __declspec(dllimport)
47 | #endif
48 |
49 | #ifdef IMAGE_ROTATE_DLL
50 | #define IMAGE_ROTATE_PUBLIC IMAGE_ROTATE_EXPORT
51 | #else
52 | #define IMAGE_ROTATE_PUBLIC IMAGE_ROTATE_IMPORT
53 | #endif
54 |
55 | #define IMAGE_ROTATE_PUBLIC_TYPE IMAGE_ROTATE_PUBLIC
56 |
57 | #define IMAGE_ROTATE_LOCAL
58 |
59 | #else
60 |
61 | #define IMAGE_ROTATE_EXPORT __attribute__ ((visibility("default")))
62 | #define IMAGE_ROTATE_IMPORT
63 |
64 | #if __GNUC__ >= 4
65 | #define IMAGE_ROTATE_PUBLIC __attribute__ ((visibility("default")))
66 | #define IMAGE_ROTATE_LOCAL __attribute__ ((visibility("hidden")))
67 | #else
68 | #define IMAGE_ROTATE_PUBLIC
69 | #define IMAGE_ROTATE_LOCAL
70 | #endif
71 |
72 | #define IMAGE_ROTATE_PUBLIC_TYPE
73 | #endif
74 |
75 | #endif // IMAGE_ROTATE__VISIBILITY_H_
76 |
--------------------------------------------------------------------------------
/image_rotate/launch/image_flip.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2022, CHRISLab, Christopher Newport University
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | """Demonstration of basic launch of the image_flip_node with remappings."""
34 |
35 | from launch import LaunchDescription
36 | import launch_ros.actions
37 |
38 |
39 | def generate_launch_description():
40 | """Launch description for basic launch of the image_flip."""
41 | return LaunchDescription([
42 | launch_ros.actions.Node(
43 | package='image_rotate', executable='image_flip',
44 | output='screen', name='camera_flip',
45 | remappings=[('image', 'camera/rgb/image_raw'),
46 | ('rotated/image', 'camera_rotated/image_rotated')],
47 | parameters=[{'output_frame_id': 'camera_rotated',
48 | 'rotation_steps': 2,
49 | 'use_camera_info': True}])])
50 |
--------------------------------------------------------------------------------
/image_rotate/launch/image_rotate.launch.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2008, Willow Garage, Inc.
2 | # All rights reserved.
3 | #
4 | # Software License Agreement (BSD License 2.0)
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions
8 | # are met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | # * Neither the name of the Willow Garage nor the names of its
17 | # contributors may be used to endorse or promote products derived
18 | # from this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | # POSSIBILITY OF SUCH DAMAGE.
32 |
33 | from launch import LaunchDescription
34 | import launch_ros.actions
35 |
36 |
37 | def generate_launch_description():
38 | return LaunchDescription([
39 | launch_ros.actions.Node(
40 | package='image_rotate', executable='image_rotate', output='screen',
41 | remappings=[('image', '/camera/color/image_raw'),
42 | ('camera_info', '/camera/color/camera_info'),
43 | ('rotated/image', '/camera/color/image_raw_rotated')]),
44 | ])
45 |
--------------------------------------------------------------------------------
/image_rotate/mainpage.dox:
--------------------------------------------------------------------------------
1 | /**
2 | \mainpage
3 | \htmlinclude manifest.html
4 |
5 | \b image_rotate is ...
6 |
7 |
10 |
11 |
12 | \section codeapi Code API
13 |
14 |
24 |
25 |
26 | */
27 |
--------------------------------------------------------------------------------
/image_rotate/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | image_rotate
5 | 7.0.0
6 |
7 |
8 | Contains a node that rotates an image stream in a way that minimizes
9 | the angle between a vector in some arbitrary frame and a vector in the
10 | camera frame. The frame of the outgoing image is published by the node.
11 |
12 |
13 | This node is intended to allow camera images to be visualized in an
14 | orientation that is more intuitive than the hardware-constrained
15 | orientation of the physical camera. This is particularly helpful, for
16 | example, to show images from the PR2's forearm cameras with a
17 | consistent up direction, despite the fact that the forearms need to
18 | rotate in arbitrary ways during manipulation.
19 |
20 |
21 | It is not recommended to use the output from this node for further
22 | computation, as it interpolates the source image, introduces black
23 | borders, and does not output a camera_info.
24 |
25 |
26 |
27 | Vincent Rabaud
28 | Joshua Whitley
29 | Jacob Perron
30 | Michael Ferguson
31 |
32 | BSD
33 | https://index.ros.org/p/image_rotate/
34 | https://github.com/ros-perception/image_pipeline/issues
35 | https://github.com/ros-perception/image_pipeline
36 | Blaise Gassend
37 | David Conner
38 |
39 | ament_cmake_auto
40 |
41 | class_loader
42 |
43 | cv_bridge
44 | geometry_msgs
45 | image_transport
46 | libopencv-dev
47 | rcl_interfaces
48 | rclcpp
49 | rclcpp_components
50 | sensor_msgs
51 | tf2
52 | tf2_geometry_msgs
53 | tf2_ros
54 |
55 | ament_lint_auto
56 | ament_lint_common
57 |
58 |
59 | ament_cmake
60 |
61 |
62 |
--------------------------------------------------------------------------------
/image_rotate/src/image_rotate.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2008, Willow Garage, Inc.
2 | // All rights reserved.
3 | //
4 | // Software License Agreement (BSD License 2.0)
5 | //
6 | // Redistribution and use in source and binary forms, with or without
7 | // modification, are permitted provided that the following conditions
8 | // are met:
9 | //
10 | // * Redistributions of source code must retain the above copyright
11 | // notice, this list of conditions and the following disclaimer.
12 | // * Redistributions in binary form must reproduce the above
13 | // copyright notice, this list of conditions and the following
14 | // disclaimer in the documentation and/or other materials provided
15 | // with the distribution.
16 | // * Neither the name of the Willow Garage nor the names of its
17 | // contributors may be used to endorse or promote products derived
18 | // from this software without specific prior written permission.
19 | //
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | // POSSIBILITY OF SUCH DAMAGE.
32 |
33 | #include "image_rotate/image_rotate_node.hpp"
34 | #include
35 |
36 | int main(int argc, char ** argv)
37 | {
38 | // Force flush of the stdout buffer.
39 | setvbuf(stdout, NULL, _IONBF, BUFSIZ);
40 |
41 | rclcpp::init(argc, argv);
42 | rclcpp::NodeOptions options;
43 | auto node = std::make_shared(options);
44 |
45 | rclcpp::spin(node);
46 | rclcpp::shutdown();
47 |
48 | return 0;
49 | }
50 |
--------------------------------------------------------------------------------
/image_view/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(image_view)
3 |
4 | if(NOT CMAKE_CXX_STANDARD)
5 | set(CMAKE_CXX_STANDARD 14)
6 | endif()
7 |
8 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9 | add_compile_options(-Wall -Wextra -Wpedantic)
10 | endif()
11 |
12 | find_package(ament_cmake_auto REQUIRED)
13 | ament_auto_find_build_dependencies()
14 |
15 | find_package(OpenCV REQUIRED)
16 |
17 | # Deal with the GUI's
18 | if(ANDROID)
19 | return()
20 | endif()
21 |
22 | ament_auto_add_library(${PROJECT_NAME}_nodes SHARED
23 | src/disparity_view_node.cpp
24 | src/extract_images_node.cpp
25 | src/image_view_node.cpp
26 | src/image_saver_node.cpp
27 | src/stereo_view_node.cpp
28 | src/video_recorder_node.cpp
29 | )
30 | target_link_libraries(${PROJECT_NAME}_nodes
31 | ${OpenCV_LIBRARIES}
32 | )
33 | target_compile_definitions(${PROJECT_NAME}_nodes
34 | PRIVATE "COMPOSITION_BUILDING_DLL"
35 | )
36 | rclcpp_components_register_nodes(${PROJECT_NAME}_nodes
37 | "${PROJECT_NAME}::DisparityViewNode"
38 | "${PROJECT_NAME}::ExtractImagesNode"
39 | "${PROJECT_NAME}::ImageViewNode"
40 | "${PROJECT_NAME}::ImageSaverNode"
41 | "${PROJECT_NAME}::StereoViewNode"
42 | "${PROJECT_NAME}::VideoRecorderNode"
43 | )
44 |
45 | # Image viewers
46 | ament_auto_add_executable(disparity_view
47 | src/disparity_view.cpp
48 | )
49 | target_link_libraries(disparity_view
50 | ${PROJECT_NAME}_nodes
51 | )
52 | add_dependencies(disparity_view
53 | ${PROJECT_NAME}_nodes
54 | )
55 |
56 | ament_auto_add_executable(${PROJECT_NAME}
57 | src/image_view.cpp
58 | )
59 | target_link_libraries(${PROJECT_NAME}
60 | ${PROJECT_NAME}_nodes
61 | )
62 | add_dependencies(${PROJECT_NAME}
63 | ${PROJECT_NAME}_nodes
64 | )
65 |
66 | ament_auto_add_executable(stereo_view
67 | src/stereo_view.cpp
68 | )
69 | target_link_libraries(stereo_view
70 | ${PROJECT_NAME}_nodes
71 | )
72 | add_dependencies(stereo_view
73 | ${PROJECT_NAME}_nodes
74 | )
75 |
76 | # Other Tools
77 | ament_auto_add_executable(extract_images
78 | src/extract_images.cpp
79 | )
80 | target_link_libraries(extract_images
81 | ${PROJECT_NAME}_nodes
82 | )
83 | add_dependencies(extract_images
84 | ${PROJECT_NAME}_nodes
85 | )
86 |
87 | ament_auto_add_executable(image_saver
88 | src/image_saver.cpp
89 | )
90 | target_link_libraries(image_saver
91 | ${PROJECT_NAME}_nodes
92 | )
93 | add_dependencies(image_saver
94 | ${PROJECT_NAME}_nodes
95 | )
96 |
97 | ament_auto_add_executable(video_recorder
98 | src/video_recorder.cpp
99 | )
100 | target_link_libraries(video_recorder
101 | ${PROJECT_NAME}_nodes
102 | )
103 | add_dependencies(video_recorder
104 | ${PROJECT_NAME}_nodes
105 | )
106 |
107 | if(BUILD_TESTING)
108 | find_package(ament_lint_auto)
109 | ament_lint_auto_find_test_dependencies()
110 | endif()
111 |
112 | install(
113 | PROGRAMS scripts/extract_images_sync
114 | DESTINATION lib/${PROJECT_NAME}
115 | )
116 |
117 | ament_auto_package()
118 |
--------------------------------------------------------------------------------
/image_view/doc/index.rst:
--------------------------------------------------------------------------------
1 | Overview
2 | ========
3 |
4 | This package contains a number of ROS 2 components and nodes for viewing image topics.
5 |
6 | Viewing a Single Image Topic
7 | ----------------------------
8 |
9 | .. code-block:: bash
10 |
11 | ros 2 run image_view image_view --ros-args -r image:=
12 |
13 | For example, to view raw images on the topic ``/camera/image``, use:
14 |
15 | .. code-block:: bash
16 |
17 | ros2 run image_view image_view --ros-args -r image:=/camera/image
18 |
19 | You may save the current image by right-clicking on the display window. By default,
20 | images will be saved as ``frame0000.jpg``, ``frame0001.jpg``, ....
21 |
22 | If you want to view a compressed image stream (usually a good idea over wireless!)
23 | using the capabilities of ``image_transport``, specify the transport type as a
24 | command-line parameter. For example, if ``theora_image_transport`` is built on the
25 | publisher's side, you can use theora transport:
26 |
27 | .. code-block:: bash
28 |
29 | ros2 run image_view image_view --ros-args -r image:=/camera/image -p image_transport:=theora
30 |
31 | .. _`Viewing Stereo Images`:
32 |
33 | Viewing Stereo Images
34 | ---------------------
35 |
36 | .. code-block:: bash
37 |
38 | ros2 run image_view stereo_view --ros-args -p stereo:= -p image:=
39 |
40 | For example, to view stereo image pairs on topics
41 | ``/my_stereo_cam/left/image_rect_color`` and ``/my_stereo_cam/right/image_rect_color``,
42 | use:
43 |
44 | .. code-block:: bash
45 |
46 | ros2 run image_view stereo_view --ros-args -r stereo:=/my_stereo_cam -r image:=image_rect_color
47 |
48 | ``stereo_view`` also shows the disparity image computed from the stereo pair
49 | color-mapped for clarity.
50 |
51 | You may save the current image pair by right-clicking on any display window.
52 | By default, images will be saved as ``left0000.jpg``, ``right0000.jpg``, ``disp0000.jpg``,
53 | ``left0001.jpg``, ``right0001.jpg``, ``disp0001.jpg``.... As with ``image_view``,
54 | you can specify an image transport to use for the left and right image as an optional
55 | parameter.
56 |
57 | .. toctree::
58 | :maxdepth: 2
59 |
60 | self
61 | components
62 | image_view
63 |
64 | Indices and tables
65 | ==================
66 |
67 | * :ref:`genindex`
68 | * :ref:`search`
69 |
--------------------------------------------------------------------------------
/image_view/include/image_view/disparity_view_node.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Joshua Whitley
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef IMAGE_VIEW__DISPARITY_VIEW_NODE_HPP_
16 | #define IMAGE_VIEW__DISPARITY_VIEW_NODE_HPP_
17 |
18 | #include
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | namespace image_view
26 | {
27 |
28 | class DisparityViewNode
29 | : public rclcpp::Node
30 | {
31 | public:
32 | explicit DisparityViewNode(const rclcpp::NodeOptions & options);
33 | explicit DisparityViewNode(const DisparityViewNode &) = default;
34 | explicit DisparityViewNode(DisparityViewNode &&) = default;
35 | DisparityViewNode & operator=(const DisparityViewNode &) = default;
36 | DisparityViewNode & operator=(DisparityViewNode &&) = default;
37 | ~DisparityViewNode();
38 |
39 | private:
40 | // colormap for disparities, RGB order
41 | static unsigned char colormap[];
42 |
43 | std::string window_name_;
44 | bool autosize_;
45 | rclcpp::Subscription::SharedPtr sub_;
46 | cv::Mat_ disparity_color_;
47 | bool initialized;
48 |
49 | void imageCb(const stereo_msgs::msg::DisparityImage::SharedPtr msg);
50 | };
51 |
52 | } // namespace image_view
53 |
54 | #endif // IMAGE_VIEW__DISPARITY_VIEW_NODE_HPP_
55 |
--------------------------------------------------------------------------------
/image_view/include/image_view/extract_images_node.hpp:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Software License Agreement (BSD License)
3 | *
4 | * Copyright (c) 2008, Willow Garage, Inc.
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | *
11 | * * Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above
14 | * copyright notice, this list of conditions and the following
15 | * disclaimer in the documentation and/or other materials provided
16 | * with the distribution.
17 | * * Neither the name of the Willow Garage nor the names of its
18 | * contributors may be used to endorse or promote products derived
19 | * from this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | * POSSIBILITY OF SUCH DAMAGE.
33 | *********************************************************************/
34 |
35 | // Copyright 2019, Joshua Whitley
36 | //
37 | // Licensed under the Apache License, Version 2.0 (the "License");
38 | // you may not use this file except in compliance with the License.
39 | // You may obtain a copy of the License at
40 | //
41 | // http://www.apache.org/licenses/LICENSE-2.0
42 | //
43 | // Unless required by applicable law or agreed to in writing, software
44 | // distributed under the License is distributed on an "AS IS" BASIS,
45 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 | // See the License for the specific language governing permissions and
47 | // limitations under the License.
48 |
49 | #ifndef IMAGE_VIEW__EXTRACT_IMAGES_NODE_HPP_
50 | #define IMAGE_VIEW__EXTRACT_IMAGES_NODE_HPP_
51 |
52 | #include
53 | #include
54 |
55 | #include
56 | #include
57 | #include
58 |
59 | namespace image_view
60 | {
61 |
62 | class ExtractImagesNode
63 | : public rclcpp::Node
64 | {
65 | public:
66 | explicit ExtractImagesNode(const rclcpp::NodeOptions & options);
67 |
68 | private:
69 | image_transport::Subscriber sub_;
70 |
71 | sensor_msgs::msg::Image::ConstSharedPtr last_msg_;
72 | std::mutex image_mutex_;
73 |
74 | std::string window_name_;
75 | std::string filename_format_;
76 | int count_;
77 | rclcpp::Time _time;
78 | double sec_per_frame_;
79 |
80 | void image_cb(const sensor_msgs::msg::Image::ConstSharedPtr & msg);
81 | };
82 |
83 | } // namespace image_view
84 |
85 | #endif // IMAGE_VIEW__EXTRACT_IMAGES_NODE_HPP_
86 |
--------------------------------------------------------------------------------
/image_view/include/image_view/image_view_node.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Joshua Whitley
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef IMAGE_VIEW__IMAGE_VIEW_NODE_HPP_
16 | #define IMAGE_VIEW__IMAGE_VIEW_NODE_HPP_
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #include "cv_bridge/cv_bridge.hpp"
26 |
27 | #include
28 | #include
29 | #include
30 |
31 | namespace image_view
32 | {
33 |
34 | class ThreadSafeImage
35 | {
36 | std::mutex mutex_;
37 | std::condition_variable condition_;
38 | cv_bridge::CvImageConstPtr image_;
39 |
40 | public:
41 | void set(cv_bridge::CvImageConstPtr image);
42 | cv_bridge::CvImageConstPtr get();
43 | cv_bridge::CvImageConstPtr pop();
44 | };
45 |
46 | class ImageViewNode
47 | : public rclcpp::Node
48 | {
49 | public:
50 | explicit ImageViewNode(const rclcpp::NodeOptions & options);
51 | explicit ImageViewNode(const ImageViewNode &) = default;
52 | explicit ImageViewNode(ImageViewNode &&) = default;
53 | ImageViewNode & operator=(const ImageViewNode &) = default;
54 | ImageViewNode & operator=(ImageViewNode &&) = default;
55 | ~ImageViewNode();
56 |
57 | private:
58 | ThreadSafeImage queued_image_, shown_image_;
59 | bool autosize_;
60 | int window_height_, window_width_;
61 | bool g_gui;
62 | std::string filename_format_;
63 | image_transport::Subscriber sub_;
64 | int count_;
65 | double min_image_value_, max_image_value_;
66 | int colormap_;
67 | rclcpp::TimerBase::SharedPtr gui_timer_;
68 | std::shared_ptr> pub_;
69 | std::string window_name_;
70 | std::thread window_thread_;
71 | rclcpp::Node::OnSetParametersCallbackHandle::SharedPtr on_set_parameters_callback_handle_;
72 |
73 | void imageCb(const sensor_msgs::msg::Image::ConstSharedPtr & msg);
74 | static void mouseCb(int event, int x, int y, int flags, void * param);
75 | void windowThread();
76 | rcl_interfaces::msg::SetParametersResult paramCallback(const std::vector &);
77 | std::mutex param_mutex_;
78 | };
79 |
80 | } // namespace image_view
81 |
82 | #endif // IMAGE_VIEW__IMAGE_VIEW_NODE_HPP_
83 |
--------------------------------------------------------------------------------
/image_view/include/image_view/video_recorder_node.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2012, 2013, 2019 Open Source Robotics Foundation, Joshua Whitley
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef IMAGE_VIEW__VIDEO_RECORDER_NODE_HPP_
16 | #define IMAGE_VIEW__VIDEO_RECORDER_NODE_HPP_
17 |
18 | #include
19 |
20 | #include
21 | #include
22 |
23 | #include
24 |
25 | namespace image_view
26 | {
27 |
28 | class VideoRecorderNode
29 | : public rclcpp::Node
30 | {
31 | public:
32 | explicit VideoRecorderNode(const rclcpp::NodeOptions & options);
33 | explicit VideoRecorderNode(const VideoRecorderNode &) = default;
34 | explicit VideoRecorderNode(VideoRecorderNode &&) = default;
35 | VideoRecorderNode & operator=(const VideoRecorderNode &) = default;
36 | VideoRecorderNode & operator=(VideoRecorderNode &&) = default;
37 | ~VideoRecorderNode();
38 |
39 | private:
40 | cv::VideoWriter outputVideo;
41 |
42 | int g_count;
43 | rclcpp::Time g_last_wrote_time;
44 | std::string encoding;
45 | std::string codec;
46 | double fps;
47 | double min_depth_range;
48 | double max_depth_range;
49 | bool use_dynamic_range;
50 | int colormap;
51 | image_transport::Subscriber sub_image;
52 | bool recording_started;
53 | std::string filename;
54 |
55 | void callback(const sensor_msgs::msg::Image::ConstSharedPtr & image_msg);
56 | };
57 |
58 | } // namespace image_view
59 |
60 | #endif // IMAGE_VIEW__VIDEO_RECORDER_NODE_HPP_
61 |
--------------------------------------------------------------------------------
/image_view/mainpage.dox:
--------------------------------------------------------------------------------
1 | /**
2 | @mainpage image_view
3 |
4 | @htmlinclude manifest.html
5 |
6 | @b image_view is a simple utility for viewing an image topic. For usage see
7 | http://www.ros.org/wiki/image_view.
8 |
9 | Currently this package has no public code API.
10 |
11 | */
12 |
--------------------------------------------------------------------------------
/image_view/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | image_view
5 | 7.0.0
6 |
7 | A simple viewer for ROS image topics. Includes a specialized viewer
8 | for stereo + disparity images.
9 |
10 |
11 | Vincent Rabaud
12 | Joshua Whitley
13 | Jacob Perron
14 | Michael Ferguson
15 |
16 | BSD
17 | https://index.ros.org/p/image_view/
18 | https://github.com/ros-perception/image_pipeline/issues
19 | https://github.com/ros-perception/image_pipeline
20 | Patrick Mihelich
21 |
22 | ament_cmake_auto
23 |
24 | camera_calibration_parsers
25 | cv_bridge
26 | image_transport
27 | message_filters
28 | rclcpp
29 | rclcpp_components
30 | sensor_msgs
31 | std_srvs
32 | stereo_msgs
33 |
34 | rclpy
35 |
36 | ament_lint_auto
37 | ament_lint_common
38 |
39 |
40 | ament_cmake
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/image_view/rosdoc.yaml:
--------------------------------------------------------------------------------
1 | - builder: doxygen
2 | name: C++ API
3 | output_dir: c++
4 | file_patterns: '*.c *.cpp *.h *.cc *.hh *.dox'
5 |
--------------------------------------------------------------------------------
/image_view/src/disparity_view.cpp:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Software License Agreement (BSD License)
3 | *
4 | * Copyright (c) 2008, Willow Garage, Inc.
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | *
11 | * * Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above
14 | * copyright notice, this list of conditions and the following
15 | * disclaimer in the documentation and/or other materials provided
16 | * with the distribution.
17 | * * Neither the name of the Willow Garage nor the names of its
18 | * contributors may be used to endorse or promote products derived
19 | * from this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | * POSSIBILITY OF SUCH DAMAGE.
33 | *********************************************************************/
34 |
35 | // Copyright 2019, Joshua Whitley
36 | //
37 | // Licensed under the Apache License, Version 2.0 (the "License");
38 | // you may not use this file except in compliance with the License.
39 | // You may obtain a copy of the License at
40 | //
41 | // http://www.apache.org/licenses/LICENSE-2.0
42 | //
43 | // Unless required by applicable law or agreed to in writing, software
44 | // distributed under the License is distributed on an "AS IS" BASIS,
45 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 | // See the License for the specific language governing permissions and
47 | // limitations under the License.
48 |
49 | #include
50 |
51 | #include
52 |
53 | #include "image_view/disparity_view_node.hpp"
54 |
55 | using image_view::DisparityViewNode;
56 |
57 | int main(int argc, char ** argv)
58 | {
59 | rclcpp::init(argc, argv);
60 |
61 | rclcpp::NodeOptions options;
62 | auto dv_node = std::make_shared(options);
63 |
64 | rclcpp::spin(dv_node);
65 | return 0;
66 | }
67 |
--------------------------------------------------------------------------------
/image_view/src/extract_images.cpp:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Software License Agreement (BSD License)
3 | *
4 | * Copyright (c) 2008, Willow Garage, Inc.
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | *
11 | * * Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above
14 | * copyright notice, this list of conditions and the following
15 | * disclaimer in the documentation and/or other materials provided
16 | * with the distribution.
17 | * * Neither the name of the Willow Garage nor the names of its
18 | * contributors may be used to endorse or promote products derived
19 | * from this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | * POSSIBILITY OF SUCH DAMAGE.
33 | *********************************************************************/
34 |
35 | // Copyright 2019, Joshua Whitley
36 | //
37 | // Licensed under the Apache License, Version 2.0 (the "License");
38 | // you may not use this file except in compliance with the License.
39 | // You may obtain a copy of the License at
40 | //
41 | // http://www.apache.org/licenses/LICENSE-2.0
42 | //
43 | // Unless required by applicable law or agreed to in writing, software
44 | // distributed under the License is distributed on an "AS IS" BASIS,
45 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 | // See the License for the specific language governing permissions and
47 | // limitations under the License.
48 |
49 | #include
50 |
51 | #include
52 |
53 | #include
54 |
55 | int main(int argc, char ** argv)
56 | {
57 | using image_view::ExtractImagesNode;
58 |
59 | rclcpp::init(argc, argv);
60 |
61 | rclcpp::NodeOptions options;
62 | auto ein = std::make_shared(options);
63 |
64 | rclcpp::spin(ein);
65 |
66 | return 0;
67 | }
68 |
--------------------------------------------------------------------------------
/image_view/src/image_saver.cpp:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Software License Agreement (BSD License)
3 | *
4 | * Copyright (c) 2008, Willow Garage, Inc.
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | *
11 | * * Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above
14 | * copyright notice, this list of conditions and the following
15 | * disclaimer in the documentation and/or other materials provided
16 | * with the distribution.
17 | * * Neither the name of the Willow Garage nor the names of its
18 | * contributors may be used to endorse or promote products derived
19 | * from this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | * POSSIBILITY OF SUCH DAMAGE.
33 | *********************************************************************/
34 |
35 | // Copyright 2019, Joshua Whitley
36 | //
37 | // Licensed under the Apache License, Version 2.0 (the "License");
38 | // you may not use this file except in compliance with the License.
39 | // You may obtain a copy of the License at
40 | //
41 | // http://www.apache.org/licenses/LICENSE-2.0
42 | //
43 | // Unless required by applicable law or agreed to in writing, software
44 | // distributed under the License is distributed on an "AS IS" BASIS,
45 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 | // See the License for the specific language governing permissions and
47 | // limitations under the License.
48 |
49 | #include
50 |
51 | #include
52 |
53 | #include "image_view/image_saver_node.hpp"
54 |
55 | int main(int argc, char ** argv)
56 | {
57 | using image_view::ImageSaverNode;
58 |
59 | rclcpp::init(argc, argv);
60 |
61 | rclcpp::NodeOptions options;
62 | auto is_node = std::make_shared(options);
63 |
64 | rclcpp::spin(is_node);
65 | }
66 |
--------------------------------------------------------------------------------
/image_view/src/image_view.cpp:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Software License Agreement (BSD License)
3 | *
4 | * Copyright (c) 2008, Willow Garage, Inc.
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | *
11 | * * Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above
14 | * copyright notice, this list of conditions and the following
15 | * disclaimer in the documentation and/or other materials provided
16 | * with the distribution.
17 | * * Neither the name of the Willow Garage nor the names of its
18 | * contributors may be used to endorse or promote products derived
19 | * from this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | * POSSIBILITY OF SUCH DAMAGE.
33 | *********************************************************************/
34 |
35 | // Copyright 2019, Joshua Whitley
36 | //
37 | // Licensed under the Apache License, Version 2.0 (the "License");
38 | // you may not use this file except in compliance with the License.
39 | // You may obtain a copy of the License at
40 | //
41 | // http://www.apache.org/licenses/LICENSE-2.0
42 | //
43 | // Unless required by applicable law or agreed to in writing, software
44 | // distributed under the License is distributed on an "AS IS" BASIS,
45 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 | // See the License for the specific language governing permissions and
47 | // limitations under the License.
48 |
49 | #include
50 |
51 | #include
52 |
53 | #include "image_view/image_view_node.hpp"
54 |
55 | int main(int argc, char ** argv)
56 | {
57 | using image_view::ImageViewNode;
58 |
59 | rclcpp::init(argc, argv);
60 |
61 | rclcpp::NodeOptions options;
62 | auto iv_node = std::make_shared(options);
63 |
64 | rclcpp::spin(iv_node);
65 |
66 | rclcpp::shutdown();
67 |
68 | return 0;
69 | }
70 |
--------------------------------------------------------------------------------
/image_view/src/stereo_view.cpp:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Software License Agreement (BSD License)
3 | *
4 | * Copyright (c) 2008, Willow Garage, Inc.
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | *
11 | * * Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above
14 | * copyright notice, this list of conditions and the following
15 | * disclaimer in the documentation and/or other materials provided
16 | * with the distribution.
17 | * * Neither the name of the Willow Garage nor the names of its
18 | * contributors may be used to endorse or promote products derived
19 | * from this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | * POSSIBILITY OF SUCH DAMAGE.
33 | *********************************************************************/
34 |
35 | // Copyright 2019, Joshua Whitley
36 | //
37 | // Licensed under the Apache License, Version 2.0 (the "License");
38 | // you may not use this file except in compliance with the License.
39 | // You may obtain a copy of the License at
40 | //
41 | // http://www.apache.org/licenses/LICENSE-2.0
42 | //
43 | // Unless required by applicable law or agreed to in writing, software
44 | // distributed under the License is distributed on an "AS IS" BASIS,
45 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 | // See the License for the specific language governing permissions and
47 | // limitations under the License.
48 |
49 | #include
50 |
51 | #include
52 |
53 | #include "image_view/stereo_view_node.hpp"
54 |
55 | int main(int argc, char ** argv)
56 | {
57 | using image_view::StereoViewNode;
58 |
59 | rclcpp::init(argc, argv);
60 |
61 | rclcpp::NodeOptions options;
62 | auto svn = std::make_shared(options);
63 |
64 | rclcpp::spin(svn);
65 |
66 | return 0;
67 | }
68 |
--------------------------------------------------------------------------------
/image_view/src/utils.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2024 Open Source Robotics Foundation, Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef UTILS_HPP_
16 | #define UTILS_HPP_
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | namespace image_view
23 | {
24 | // TODO(ahcorde): Use std::format when C++20 is available
25 | template
26 | std::string string_format(const std::string & format, Args ... args)
27 | {
28 | // Extra space for '\0'
29 | int size_s = std::snprintf(nullptr, 0, format.c_str(), args ...) + 1;
30 | if (size_s <= 0) {
31 | throw std::runtime_error("Error during formatting.");
32 | }
33 | auto size = static_cast(size_s);
34 | std::unique_ptr buf(new char[size]);
35 | std::snprintf(buf.get(), size, format.c_str(), args ...);
36 | // We don't want the '\0' inside
37 | return std::string(buf.get(), buf.get() + size - 1);
38 | }
39 | } // namespace image_view
40 |
41 | #endif // UTILS_HPP_
42 |
--------------------------------------------------------------------------------
/image_view/src/video_recorder.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2012, 2013, 2019 Open Source Robotics Foundation, Joshua Whitley
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include
16 |
17 | #include
18 |
19 | #include "image_view/video_recorder_node.hpp"
20 |
21 | int main(int argc, char ** argv)
22 | {
23 | using image_view::VideoRecorderNode;
24 |
25 | rclcpp::init(argc, argv);
26 |
27 | rclcpp::NodeOptions options;
28 | auto vr_node = std::make_shared(options);
29 |
30 | rclcpp::spin(vr_node);
31 |
32 | return 0;
33 | }
34 |
--------------------------------------------------------------------------------
/stereo_image_proc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(stereo_image_proc)
3 |
4 | if(NOT CMAKE_CXX_STANDARD)
5 | set(CMAKE_CXX_STANDARD 14)
6 | endif()
7 |
8 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9 | add_compile_options(-Wall -Wextra -Wpedantic)
10 | endif()
11 |
12 | find_package(ament_cmake_auto REQUIRED)
13 | ament_auto_find_build_dependencies()
14 |
15 | find_package(OpenCV REQUIRED)
16 |
17 | # See note in image_proc/CMakeLists.txt
18 | # add_definitions(-DOPENCV_TRAITS_ENABLE_DEPRECATED)
19 |
20 | ament_auto_add_library(${PROJECT_NAME} SHARED
21 | src/${PROJECT_NAME}/stereo_processor.cpp
22 | src/${PROJECT_NAME}/disparity_node.cpp
23 | src/${PROJECT_NAME}/point_cloud_node.cpp
24 | )
25 | target_link_libraries(${PROJECT_NAME}
26 | ${OpenCV_LIBRARIES}
27 | )
28 |
29 | # Register individual components and also build standalone nodes for each
30 | rclcpp_components_register_node(${PROJECT_NAME}
31 | PLUGIN "stereo_image_proc::DisparityNode"
32 | EXECUTABLE disparity_node
33 | )
34 | rclcpp_components_register_node(${PROJECT_NAME}
35 | PLUGIN "stereo_image_proc::PointCloudNode"
36 | EXECUTABLE point_cloud_node
37 | )
38 |
39 | if(BUILD_TESTING)
40 | find_package(ament_lint_auto REQUIRED)
41 | ament_lint_auto_find_test_dependencies()
42 |
43 | set(_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")
44 | if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
45 | set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}")
46 | endif()
47 |
48 | ament_add_pytest_test("test_disparity_node" test/test_disparity_node.py
49 | PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
50 | )
51 |
52 | ament_add_pytest_test("test_point_cloud_node" test/test_point_cloud_node.py
53 | PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
54 | )
55 |
56 | set(PYTHON_EXECUTABLE "${_PYTHON_EXECUTABLE}")
57 | endif()
58 |
59 | ament_auto_package(INSTALL_TO_SHARE launch)
60 |
--------------------------------------------------------------------------------
/stereo_image_proc/doc/configuration.rst:
--------------------------------------------------------------------------------
1 | .. _Configuration:
2 |
3 | Configuration
4 | =============
5 |
6 | Overview
7 | --------
8 |
9 | The ``stereo_image_proc.launch.py`` launch file provides a full example and
10 | performs rectification and de-mosaicing of raw stereo camera image pairs.
11 | It also perform stereo processing to generate disparity images and point clouds.
12 |
13 | In topic names below, left and right are remapped using the ``left_namespace``
14 | and ``right_namespace`` launch file parameters.
15 |
16 | |stereo|
17 |
18 | .. |stereo| image:: images/stereo_image_proc.png
19 | :width: 75%
20 |
21 | All processing is on demand. Color processing is performed only if there is a
22 | subscriber to a color topic. Rectification is performed only if there is a
23 | subscriber to a rectified topic. Disparities and point clouds are generated
24 | only if there is a subscriber to a relevant topic. While there are no subscribers
25 | to output topics, the nodes unsubscribe from the ``image_raw`` and
26 | ``camera_info`` topics.
27 |
28 | Point clouds are generated in the optical frame of the left imager
29 | (X Right, Y Down, Z out):
30 |
31 | |stereo_frames|
32 |
33 | .. |stereo_frames| image:: images/stereo_frames.png
34 | :width: 50%
35 |
36 |
37 | Quick Start
38 | -----------
39 |
40 | Make sure your stereo camera driver(s) are running. You can check
41 | ``ros2 topic list | grep image_raw`` to see the available raw image
42 | topics from compatible drivers.
43 |
44 | To get rectified and/or colorized image streams, you need to launch the
45 | ``stereo_image_proc.launch.py`` launch file. If you are running on a
46 | robot, it's probably best to run the launch file there. For example,
47 | if your stereo camera driver(s) are publishing:
48 |
49 | .. code-block::
50 |
51 | /stereo/left/image_raw
52 | /stereo/left/camera_info
53 | /stereo/right/image_raw
54 | /stereo/right/camera_info
55 |
56 | you could do:
57 |
58 | .. code-block:: bash
59 |
60 | ros2 launch stereo_image_proc stereo_image_proc.launch.py namespace:=stereo
61 |
62 | Notice that we add the ``stereo`` namespace. Internally the launch file
63 | also has a ``left_namespace`` and ``right_namespace`` which default to
64 | ``left`` and ``right``. Using this launch file is equivalent to Launching
65 | two instances of the ``image_proc/image_proc.launch.py`` launch file in the
66 | ``stereo/left`` and ``stereo/right`` namespaces, with the addition of
67 | the stereo outputs: disparity images (``stereo/disparity`` topic) and point
68 | clouds (``stereo/points2`` topic)
69 |
70 | In a separate terminal (on your home machine, if you are running on a robot):
71 |
72 | .. code-block:: bash
73 |
74 | $ ros2 run image_view image_view image:=/stereo/left/image_rect_color
75 |
76 | This will display a rectified color image from the left stereo camera.
77 | Alternatively, stereo_view will show you both the left and right images
78 | as well as a color-mapped disparity image:
79 |
80 | .. code-block:: bash
81 |
82 | $ ros2 run image_view stereo_view stereo:=/stereo image:=image_rect_color
83 |
84 | To view point clouds, you can use ``rviz2``.
85 |
86 | Choosing Good Stereo Parameters
87 | -------------------------------
88 |
89 | There is an extensive tutorial on the
90 | `ROS 1 wiki `,
91 | however not all components exist in ROS 2 yet.
92 |
--------------------------------------------------------------------------------
/stereo_image_proc/doc/images/disparity.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/stereo_image_proc/doc/images/disparity.jpg
--------------------------------------------------------------------------------
/stereo_image_proc/doc/images/raw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/stereo_image_proc/doc/images/raw.png
--------------------------------------------------------------------------------
/stereo_image_proc/doc/images/rectified.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/stereo_image_proc/doc/images/rectified.png
--------------------------------------------------------------------------------
/stereo_image_proc/doc/images/stereo_frames.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/stereo_image_proc/doc/images/stereo_frames.png
--------------------------------------------------------------------------------
/stereo_image_proc/doc/images/stereo_image_proc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/stereo_image_proc/doc/images/stereo_image_proc.png
--------------------------------------------------------------------------------
/stereo_image_proc/doc/index.rst:
--------------------------------------------------------------------------------
1 | Overview
2 | ========
3 |
4 | This package contains a number of ROS 2 components, nodes, and launch files
5 | for stereo image processing.
6 |
7 | If porting from ROS 1, please note that the ``stereo_image_proc`` node no
8 | longer exists and instead you should use ``stereo_image_proc.launch.py``.
9 | See the :ref:`Configuration` page for more detail.
10 |
11 | ``DisparityNode`` can compute disparity images from incoming stereo
12 | pairs using
13 | `OpenCV's block matching `_
14 | algorithm. These are best inspected
15 | using ``stereo_view`` which is available in the ``image_view`` package.
16 |
17 | ``PointCloudNode`` can produce point clouds, which you can view in ``rviz``,
18 | and process with PCL.
19 |
20 | The image below shows the **left/image_raw** and **right_image_raw**.
21 | These are the raw images from each camera.
22 |
23 | |raw|
24 |
25 | .. |raw| image:: images/raw.png
26 |
27 | Below are the **left/image_rect_color** and **right/image_rect_color**.
28 | These are the rectified images from each camera.
29 | The red lines show that the same point in the real world
30 | lies on the same horizontal line in each rectified image.
31 |
32 | |rectified|
33 |
34 | .. |rectified| image:: images/rectified.png
35 |
36 | The resulting disparity image is shown below,
37 | viewed with ``stereo_view`` from the ``image_view`` package.
38 |
39 | |disparity|
40 |
41 | .. |disparity| image:: images/disparity.jpg
42 |
43 |
44 | .. toctree::
45 | :maxdepth: 2
46 |
47 | self
48 | components
49 | configuration
50 | tutorials
51 | stereo_image_proc
52 |
53 | Indices and tables
54 | ==================
55 |
56 | * :ref:`genindex`
57 | * :ref:`search`
58 |
--------------------------------------------------------------------------------
/stereo_image_proc/doc/tutorials.rst:
--------------------------------------------------------------------------------
1 | Tutorials
2 | =========
3 |
4 | .. _Launch stereo_image_proc Components:
5 |
6 | Launching stereo_image_proc Components
7 | --------------------------------------
8 | While each of the components is available as a ROS 2 node, the
9 | recommended way to build pipelines is using the components as
10 | this will save overhead by not having to serialize messages
11 | between components.
12 |
13 | For a detailed example, see ``stereo_image_proc.launch.py``.
14 |
15 | Using Compressed Image Transport
16 | --------------------------------
17 | All of the components and nodes in ``stereo_image_proc`` support
18 | ``image_transport``. This allows a subscriber to specify the transport to
19 | be used. By default, this is ``raw``, which means an uncompressed
20 | ``sensor_msgs/Image``. When transmitting images over limited bandwidth
21 | networks, such as WiFi, it can be helpful to use ``compressed`` format.
22 |
23 | .. code-block:: bash
24 |
25 | $ ros2 run stereo_image_proc disparity_node --ros-args -p image_transport:=compressed
26 |
27 | Remapping camera_info Topics
28 | ----------------------------
29 | When a ``camera_info`` topic is needed, an image_transport camera subscriber
30 | is typically used. ROS 2 convention for naming ``camera_info`` topics is:
31 |
32 | * camera/image - an image in namespace ``camera``.
33 | * camera/camera_info - the associated camera info
34 |
35 | So if a node subscribes to a topic called ``image``, and the user remaps this
36 | to ``my_camera/image``, then the associated camera info will be automatically
37 | remapped to ``mycamera/camera_info``.
38 |
39 | Most ROS 2 camera drivers will follow the convention, but occasionally they do
40 | not. In this case, you will have to manually remap the camera_info - but due
41 | to the way that ROS 2 remapping works you have to use the fully resolved
42 | camera info topic. An example:
43 |
44 | * ``image`` is remapped to ``my_camera/image``.
45 | * The fully resolved name for the camera info is now ``my_camera/camera_info``.
46 | * If your camera driver actually publishes ``another_ns/camera_info``, then
47 | you would have to remap ``my_camera/camera_info`` to ``another_ns/camera_info``.
48 |
--------------------------------------------------------------------------------
/stereo_image_proc/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | stereo_image_proc
5 | 7.0.0
6 | Stereo and single image rectification and disparity processing.
7 |
8 | Vincent Rabaud
9 | Joshua Whitley
10 | Jacob Perron
11 | Michael Ferguson
12 |
13 | BSD
14 | https://index.ros.org/p/stereo_image_proc/
15 | https://github.com/ros-perception/image_pipeline/issues
16 | https://github.com/ros-perception/image_pipeline
17 | Patrick Mihelich
18 | Kurt Konolige
19 | Jeremy Leibs
20 |
21 | ament_cmake_auto
22 |
23 | cv_bridge
24 | image_geometry
25 | image_proc
26 | image_transport
27 | message_filters
28 | rclcpp
29 | rclcpp_components
30 | sensor_msgs
31 | stereo_msgs
32 |
33 | ament_cmake_pytest
34 | ament_lint_auto
35 | ament_lint_common
36 | launch
37 | launch_ros
38 | launch_testing
39 | launch_testing_ament_cmake
40 | python3-opencv
41 | python_cmake_module
42 | rclpy
43 | ros_testing
44 |
45 |
46 | ament_cmake
47 |
48 |
49 |
--------------------------------------------------------------------------------
/stereo_image_proc/test/data/README.md:
--------------------------------------------------------------------------------
1 | The images in this directory were copied from the OpenCV project [from this location](https://github.com/opencv/opencv_extra/tree/dc0c6c1ee2cd142f936e7f957bbc595df2ce17e8/testdata/gpu/stereobm).
2 | Images are licensed under the open-source BSD license: https://opencv.org/license/
3 |
--------------------------------------------------------------------------------
/stereo_image_proc/test/data/aloe-L.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/stereo_image_proc/test/data/aloe-L.png
--------------------------------------------------------------------------------
/stereo_image_proc/test/data/aloe-R.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/stereo_image_proc/test/data/aloe-R.png
--------------------------------------------------------------------------------
/stereo_image_proc/test/data/aloe-disp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/stereo_image_proc/test/data/aloe-disp.png
--------------------------------------------------------------------------------
/tools/ros2_dependencies.repos:
--------------------------------------------------------------------------------
1 | repositories:
2 | image_common:
3 | type: git
4 | url: https://github.com/ros-perception/image_common.git
5 | version: ros2
6 | vision_opencv:
7 | type: git
8 | url: https://github.com/ros-perception/vision_opencv.git
9 | version: ros2
10 |
11 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/.gitignore:
--------------------------------------------------------------------------------
1 | doc_output/
2 | .DS_Store
3 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/Doxyfile:
--------------------------------------------------------------------------------
1 | # All settings not listed here will use the Doxygen default values.
2 |
3 | PROJECT_NAME = "tracetools_image_pipeline"
4 | PROJECT_NUMBER = master
5 | PROJECT_BRIEF = "LTTng tracing provider wrapper for image_pipeline ROS 2 meta-package."
6 |
7 | INPUT = ./include
8 |
9 | RECURSIVE = YES
10 | OUTPUT_DIRECTORY = doc_output
11 |
12 | EXTRACT_ALL = YES
13 | SORT_MEMBER_DOCS = NO
14 |
15 | GENERATE_LATEX = NO
16 |
17 | ENABLE_PREPROCESSING = YES
18 | MACRO_EXPANSION = YES
19 | EXPAND_ONLY_PREDEF = NO
20 | PREDEFINED = \
21 | "TRACETOOLS_PUBLIC="
22 |
23 | EXCLUDE_SYMBOLS = \
24 | "DECLARE_TRACEPOINT" \
25 | "_demangle_symbol" \
26 | "_get_symbol_funcptr"
27 |
28 | # Tag files that do not exist will produce a warning and cross-project linking will not work.
29 | TAGFILES += "../../../../../doxygen_tag_files/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/"
30 | # Uncomment to generate tag files for cross-project linking.
31 | # (path relative to workspace dir: doxygen_tag_files/$PACKAGE_NAME.tag)
32 | #GENERATE_TAGFILE = "../../../../../doxygen_tag_files/tracetools.tag"
33 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/README.md:
--------------------------------------------------------------------------------
1 | # tracetools_image_pipeline
2 |
3 | LTTng tracing provider wrapper for image_pipeline ROS 2 meta-package. `tracetools_image_pipeline` is a fork of [tracetools](https://gitlab.com/ros-tracing/ros2_tracing/-/tree/master/tracetools), refer to this package for the original work.
4 |
5 | ### Quality Declaration
6 |
7 | No quality is claimed according to [REP-2004](https://www.ros.org/reps/rep-2004.html).
8 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/include/tracetools_image_pipeline/config.h.in:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Víctor Mayoral-Vilches
2 | // Copyright 2019 Robert Bosch GmbH
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | #ifndef TRACETOOLS_IMAGE_PIPELINE__CONFIG_H_
17 | #define TRACETOOLS_IMAGE_PIPELINE__CONFIG_H_
18 |
19 | #cmakedefine TRACETOOLS_DISABLED
20 | #cmakedefine TRACETOOLS_LTTNG_ENABLED
21 |
22 | #endif // TRACETOOLS_IMAGE_PIPELINE__CONFIG_H_
23 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/include/tracetools_image_pipeline/utils.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Víctor Mayoral-Vilches
2 | // Copyright 2019 Robert Bosch GmbH
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | #ifndef TRACETOOLS_IMAGE_PIPELINE__UTILS_HPP_
17 | #define TRACETOOLS_IMAGE_PIPELINE__UTILS_HPP_
18 |
19 | #include
20 | #include
21 |
22 | #include "tracetools_image_pipeline/visibility_control.hpp"
23 |
24 | /// Default symbol, used when address resolution fails.
25 | #define SYMBOL_UNKNOWN "UNKNOWN"
26 |
27 | TRACETOOLS_PUBLIC const char * _demangle_symbol(const char * mangled);
28 |
29 | TRACETOOLS_PUBLIC const char * _get_symbol_funcptr(void * funcptr);
30 |
31 | /// Get symbol from an std::function object.
32 | /**
33 | * If function address resolution or symbol demangling fails,
34 | * this will return a string that starts with \ref SYMBOL_UNKNOWN.
35 | *
36 | * \param[in] f the std::function object
37 | * \return the symbol, or a placeholder
38 | */
39 | template
40 | const char * get_symbol(std::function f)
41 | {
42 | typedef T (fnType)(U...);
43 | fnType ** fnPointer = f.template target();
44 | // If we get an actual address
45 | if (fnPointer != nullptr) {
46 | void * funcptr = reinterpret_cast(*fnPointer);
47 | return _get_symbol_funcptr(funcptr);
48 | }
49 | // Otherwise we have to go through target_type()
50 | return _demangle_symbol(f.target_type().name());
51 | }
52 |
53 | /// Get symbol from a function-related object.
54 | /**
55 | * Fallback meant for lambdas with captures.
56 | *
57 | * \param[in] l a generic object
58 | * \return the symbol
59 | */
60 | template
61 | const char * get_symbol(L && l)
62 | {
63 | return _demangle_symbol(typeid(l).name());
64 | }
65 |
66 | #endif // TRACETOOLS_IMAGE_PIPELINE__UTILS_HPP_
67 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/include/tracetools_image_pipeline/visibility_control.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Víctor Mayoral-Vilches
2 | // Copyright 2015 Open Source Robotics Foundation, Inc.
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | /* This header must be included by all TRACETOOLS headers which declare symbols
17 | * which are defined in the TRACETOOLS library. When not building the TRACETOOLS
18 | * library, i.e. when using the headers in other package's code, the contents
19 | * of this header change the visibility of certain symbols which the TRACETOOLS
20 | * library cannot have, but the consuming code must have inorder to link.
21 | */
22 |
23 | #ifndef TRACETOOLS_IMAGE_PIPELINE__VISIBILITY_CONTROL_HPP_
24 | #define TRACETOOLS_IMAGE_PIPELINE__VISIBILITY_CONTROL_HPP_
25 |
26 | // This logic was borrowed (then namespaced) from the examples on the gcc wiki:
27 | // https://gcc.gnu.org/wiki/Visibility
28 |
29 | #if defined _WIN32 || defined __CYGWIN__
30 | #ifdef __GNUC__
31 | #define TRACETOOLS_EXPORT __attribute__ ((dllexport))
32 | #define TRACETOOLS_IMPORT __attribute__ ((dllimport))
33 | #else
34 | #define TRACETOOLS_EXPORT __declspec(dllexport)
35 | #define TRACETOOLS_IMPORT __declspec(dllimport)
36 | #endif
37 | #ifdef TRACETOOLS_BUILDING_DLL
38 | #define TRACETOOLS_PUBLIC TRACETOOLS_EXPORT
39 | #else
40 | #define TRACETOOLS_PUBLIC TRACETOOLS_IMPORT
41 | #endif
42 | #define TRACETOOLS_PUBLIC_TYPE TRACETOOLS_PUBLIC
43 | #define TRACETOOLS_LOCAL
44 | #else
45 | #define TRACETOOLS_EXPORT __attribute__ ((visibility("default")))
46 | #define TRACETOOLS_IMPORT
47 | #if __GNUC__ >= 4
48 | #define TRACETOOLS_PUBLIC __attribute__ ((visibility("default")))
49 | #define TRACETOOLS_LOCAL __attribute__ ((visibility("hidden")))
50 | #else
51 | #define TRACETOOLS_PUBLIC
52 | #define TRACETOOLS_LOCAL
53 | #endif
54 | #define TRACETOOLS_PUBLIC_TYPE
55 | #endif
56 |
57 | #endif // TRACETOOLS_IMAGE_PIPELINE__VISIBILITY_CONTROL_HPP_
58 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | tracetools_image_pipeline
5 | 7.0.0
6 |
7 | LTTng tracing provider wrapper for image_pipeline ROS 2 meta-package.
8 |
9 | Víctor Mayoral-Vilches
10 | Michael Ferguson
11 | Apache 2.0
12 | Víctor Mayoral-Vilches
13 |
14 | ament_cmake_ros
15 | pkg-config
16 |
17 | ament_lint_auto
18 | ament_lint_common
19 |
20 |
21 | ament_cmake
22 |
23 |
24 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/src/status.c:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Víctor Mayoral-Vilches
2 | // Copyright 2019 Robert Bosch GmbH
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | #include
17 | #include "tracetools_image_pipeline/tracetools.h"
18 |
19 | int main()
20 | {
21 | #ifndef TRACETOOLS_DISABLED
22 | printf("Tracing ");
23 | if (ros_trace_compile_status()) {
24 | printf("enabled\n");
25 | return 0;
26 | } else {
27 | printf("disabled\n");
28 | return 1;
29 | }
30 | #else
31 | printf("Tracing disabled through configuration\n");
32 | return 1;
33 | #endif
34 | }
35 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/src/tp_call.c:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Víctor Mayoral-Vilches
2 | // Copyright 2019 Robert Bosch GmbH
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | #define TRACEPOINT_CREATE_PROBES
17 |
18 | #define TRACEPOINT_DEFINE
19 | #include "tracetools_image_pipeline/tp_call.h"
20 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/src/tracetools.c:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Víctor Mayoral-Vilches
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "tracetools_image_pipeline/tracetools.h"
16 |
17 | #ifndef TRACETOOLS_DISABLED
18 |
19 | #ifdef TRACETOOLS_LTTNG_ENABLED
20 | # include "tracetools_image_pipeline/tp_call.h"
21 | # define CONDITIONAL_TP(...) \
22 | tracepoint(TRACEPOINT_PROVIDER, __VA_ARGS__)
23 | #else
24 | # define CONDITIONAL_TP(...)
25 | #endif
26 |
27 | bool ros_trace_compile_status()
28 | {
29 | #ifdef TRACETOOLS_LTTNG_ENABLED
30 | return true;
31 | #else
32 | return false;
33 | #endif
34 | }
35 |
36 | #ifndef _WIN32
37 | # pragma GCC diagnostic push
38 | # pragma GCC diagnostic ignored "-Wunused-parameter"
39 | #else
40 | # pragma warning(push)
41 | # pragma warning(disable: 4100)
42 | #endif
43 |
44 |
45 | void TRACEPOINT(
46 | image_proc_resize_init,
47 | const void * resize_node_arg,
48 | const void * resize_image_msg_arg,
49 | const void * resize_info_msg_arg)
50 | {
51 | CONDITIONAL_TP(
52 | image_proc_resize_init,
53 | resize_node_arg,
54 | resize_image_msg_arg,
55 | resize_info_msg_arg);
56 | }
57 |
58 | void TRACEPOINT(
59 | image_proc_resize_fini,
60 | const void * resize_node_arg,
61 | const void * resize_image_msg_arg,
62 | const void * resize_info_msg_arg)
63 | {
64 | CONDITIONAL_TP(
65 | image_proc_resize_fini,
66 | resize_node_arg,
67 | resize_image_msg_arg,
68 | resize_info_msg_arg);
69 | }
70 |
71 | void TRACEPOINT(
72 | image_proc_rectify_init,
73 | const void * rectify_node_arg,
74 | const void * rectify_image_msg_arg,
75 | const void * rectify_info_msg_arg)
76 | {
77 | CONDITIONAL_TP(
78 | image_proc_rectify_init,
79 | rectify_node_arg,
80 | rectify_image_msg_arg,
81 | rectify_info_msg_arg);
82 | }
83 |
84 | void TRACEPOINT(
85 | image_proc_rectify_fini,
86 | const void * rectify_node_arg,
87 | const void * rectify_image_msg_arg,
88 | const void * rectify_info_msg_arg)
89 | {
90 | CONDITIONAL_TP(
91 | image_proc_rectify_fini,
92 | rectify_node_arg,
93 | rectify_image_msg_arg,
94 | rectify_info_msg_arg);
95 | }
96 |
97 | #ifndef _WIN32
98 | # pragma GCC diagnostic pop
99 | #else
100 | # pragma warning(pop)
101 | #endif
102 |
103 | #endif // TRACETOOLS_DISABLED
104 |
--------------------------------------------------------------------------------
/tracetools_image_pipeline/src/utils.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Víctor Mayoral-Vilches
2 | // Copyright 2019 Robert Bosch GmbH
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 |
16 | #include "tracetools_image_pipeline/config.h"
17 |
18 | #ifdef TRACETOOLS_LTTNG_ENABLED
19 | #include
20 | #include
21 | #endif
22 | #include "tracetools_image_pipeline/utils.hpp"
23 |
24 | const char * _demangle_symbol(const char * mangled)
25 | {
26 | #ifdef TRACETOOLS_LTTNG_ENABLED
27 | char * demangled = nullptr;
28 | int status;
29 | demangled = abi::__cxa_demangle(mangled, NULL, 0, &status);
30 | // Use demangled symbol if possible
31 | const char * demangled_val = (status == 0 ? demangled : mangled);
32 | return demangled_val != 0 ? demangled_val : "UNKNOWN_demangling_failed";
33 | #else
34 | (void)mangled;
35 | return "DISABLED__demangle_symbol";
36 | #endif
37 | }
38 |
39 | const char * _get_symbol_funcptr(void * funcptr)
40 | {
41 | #ifdef TRACETOOLS_LTTNG_ENABLED
42 | Dl_info info;
43 | if (dladdr(funcptr, &info) == 0) {
44 | return SYMBOL_UNKNOWN;
45 | }
46 | return _demangle_symbol(info.dli_sname);
47 | #else
48 | (void)funcptr;
49 | return "DISABLED__get_symbol_funcptr";
50 | #endif
51 | }
52 |
--------------------------------------------------------------------------------
/wiki_files/rospack_nosubdirs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ros-perception/image_pipeline/746268fcfd21b389bc39ae60bb6345a53c838558/wiki_files/rospack_nosubdirs
--------------------------------------------------------------------------------