双USB相机
安装库
安装usb_cam
git clone https://github.com/bosch-ros-pkg/usb_cam.git
编译库
ROS路径添加到bashrc
安装image_view
sudo apt-get install ros-melodic-image-view
安装v4l-utils,用于查看相机参数
sudo apt install v4l-utils
使用相机
查看串口名称
ls /dev/video*
查看设备与设备名称
lsusb
Bus 001 Device 010: ID 1e4e:0109 Cubeternet
使用usb_cam打开
roslaunch usb_cam usb_cam-test.launch
查看摄像头参数
v4l2-ctl -d /dev/video0 --all
v4l2-ctl -d /dev/video2 --all --list-formats-ext
双相机
修改usb_cam的launch文件,复制一份,使用不同的串口名称和rostopic
参数调整:exposure调节相机曝光,一般调节范围是1~1000
Tips
deprecated pixel format used, make sure you did set range correctly
出现警告,原因:https://github.com/HypoX64/DeepMosaics/issues/50。从 yuv420p 源转换为 JPEG 时会出现警告,这使得 ffmpeg 选择 yuvj420p 作为输出格式。
VIDIOC_STREAMON error 28, No space left on device
出现ERROR,原因:https://blog.csdn.net/zhangwu1241/article/details/52983271。两个相机不能接在同一个USB口上。
如果必须要接多个相机,需要调整USB的带宽。Linux的机制会让第一个使用这个usb的设备把usb总线的带宽全部占满。所以每次都要强行的进入内核,把内核里面那个驱动给去掉,然后重新分配一个固定的带宽128。
sudo rmmod uvcvideo
sudo modprobe uvcvideo quirks=128
标定相机
size的值表示标定板图案内部点的个数,不是区块的个数
标定时尽量保持光线充足,同时防止标定板形变或反光
rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.0245 image:=/usb_cam_1/image_raw camera:=/usb_cam_1