A image from camera or video file and a camera info publisher node for ROS2.
- Works with USB cameras that are recognized by V4L2 and also IP cameras.
- It is also possible to publish frames of a video file.
- Undistortion of frames according to calibration data.
- Importing necessary configuration file generated by camera_calibrator node
- Additional parameters are stored in Launch File
Topic Name | Message Type |
---|---|
camera/image_color |
CompressedImage |
camera/image_undist_color |
CompressedImage |
camera/camera_info |
CameraInfo |
- OpenCV
To install:$ python3 -m pip install opencv-python
- PyYAML
To install:When you run the node, if you still get an error about PyYAML, check its version$ python3 -m pip install pyyaml
If it is smaller than$ python3 > import yaml > yaml.__version__
5.1
, you should update it$ python3 -m pip install -U pyyaml
- CvBridge
To install:$ sudo apt install ros-eloquent-cv-bridge
- Clone repository to
/your_workspace/src
$ git clone https://git.fh-aachen.de/kurhan/camera_rgb.git
- Build
/your_workspace
withcolcon
$ colcon build
It has only two parameters.
-
read_video
is a boolean variable which set image acquisiton source either a camera or video file-
If
True
then the node tries to read video file which is given in parametervideo_path
-
If
False
then the node tries to open designated camera in configuration file.
-
-
video_path
keeps the absolute path of desired video file, e.g./home/<user>/Desktop/sample.mp4
After setting all parameters in Launch File and configuration file properly then,
$ ros2 launch camera_rgb camera_rgb.launch.py
The node imports a YAML file generated by camera_calibrator as a configuration file. This file contains matrices for calibration and some more additional parameters which are required.
- The name of the file must be
camera.yaml
and it must be incamera_calibration/config
directory -
image_width
andimage_height
set resolution of camera -
camera_source
holds index number of camera. It is also possible to enter address of an IP Camera, e.g.http://192.168.0.123:5000/video
-
camera_fps
sets camera frame rate. -
camera_name
is useful when there are multiple cameras on the system. -
camera_matrix
is a unique result derived from calculations done on checkerboard and used for undistortion of captured frames.$f_x$ and$f_y$ are focal lengths and$c_x$ and$c_y$ are optical centers
distortion_model
is set toplumb bob
by default. This model requires1x5
distrotion matrix.distortion_coefficients
contains 5 coefficients and used for undistortion of captured frames.
For more info you can check OpenCV tutorial and documentation