This is a super simple pi camera node using python and opencv.
colcon build --packages-select rtf_pyopencv_camera
. install/setup.bash
ros2 run rtf_pyopencv_camera pycamera_node
ros2 param set <node_name> <param_name> <param_value>
ros2 param load <node_name> <parameter_file>
ros2 run <package_name> <executable_name> --ros-args --params-file <file_name>
/pycamera_node:
ros__parameters:
camera_num: 0
camera_size: 720
pycamera_node
- topics:
image
: uncompressed raw imageimage_compressed
: jpeg compressed image, rectified if calibration info provided
- CLI arguments
camera_num
: default 0
- parameters:
camera_size
: image size [height, width], default 320encoding
:bgr
,rgb
, defaultmono8
rectified
: use calibration data to rectify image before sending, defaultFalse
- topics:
grab_node
- capture image:
ros2 service call /capture std_srvs/srv/Empty
- TODO: Add video capture
capture_video
andcapture_image
- capture image:
$ ros2 launch rtf_pyopencv_camera pycamera_foxglove_launch.py
- C++: OpenCV_Cam
- C++: raspicam2_node
ros2 launch foxglove_bridge foxglove_bridge_launch.xml
I am using Ubuntu Server 24.04 on my Raspberry Pi.
- Add
start_x=1
to/boot/firmware/config.txt
- Note: making the change to
/boot/firmware/usercfg.txt
doesn't work
- Note: making the change to
- Reboot pi
- You should have
/dev/video0
now
Check all is working:
sudo apt install fswebcam
- Run:
fswebcam --save test.jpg -d /dev/video0 -r 1280x960
- You should now have a jpeg taken from the camera
Copyright (c) 2020 Reckless Ted's Funland
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.