当前位置:网站首页>【ROS】usb_ Cam camera calibration
【ROS】usb_ Cam camera calibration
2022-07-06 08:34:00 【Will_ Ye】
1. Nagging two sentences
When we want to use the camera for measurement , You need to calibrate the camera , Otherwise, the calculated result will have a big error , The calibration includes three parts : Internal reference , External parameters and distortion parameters . So the calibration process requires the above parameters .
It was probably troublesome to do this before , Experiments and calculations are needed to get , Now through ros The open source package of can complete camera calibration in a few minutes , Appreciate !
Specific description of the internal and external parameters distortion coefficient , You can see Reference The first link inside , It's very detailed .
2. preparation
There are three things to prepare :
- usb_cam Of ROS Start the package
- Camera calibration ROS package
- There is also a checkerboard for calibration
1)usb_cam Start the package
Use what I uploaded usb_cam edition , I don't know why GitHub The downloaded version is not good , This usb_cam The version is also sent by others , It's strange , I can study it later , See what's different , Both of them can turn on the camera , Just use GitHub After opening the version of ,apriltag_ros Do not output the correct value . Download here
Download after decompression , Put it in the corresponding work space in src In the document , for example catkin_ws
And then use catkin_make
compile
And then use ls /dev/video*
have a look usb Camera number , If
[email protected]:~/omni_ws$ ls /dev/video*
/dev/video0 /dev/video1 /dev/video2 /dev/video3
My notebook has webcam Another external camera is connected , Actually, two cameras have four numbers , In fact, only 0 and 2 Just go , They correspond to each other webcam and usb cam, The other two won't work , And then modify usb_cam/launch/usb_cam-test.launch
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video0" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<param name="autosize" value="true" />
</node>
</launch>
The main thing is to modify the <param name="video_device" value="/dev/video0" />
This one is ok , The default is 0, Change to /dev/video2
Just go
Then start roslaunch usb_cam usb_cam-test.launch
If there is an image, it will succeed .
2)ROS Camera calibration package
Very convenient , direct apt-get You can download and use :sudo apt-get install ros-melodic-camera-cibration
3) Print checkerboard
You can go to Google or Baidu Search for one , Something like this
Then figure out two things :
first , This is the chessboard size, For example, this one above is a 4x6 Of , Just count the intersections of the four grids. How many are there in a row , And a few in a column
the second , Determine the size of the grid , Measure according to the printed results , The picture above , I use A4 Paper printing , The side length of the printed grid is 0.026m, That is to say 2.6cm, Also measure the length and width of the lattice , See if it's really a square .
It is important to determine the above two points , The following input will use
3. Start calibration
Start the camera first , Then start the calibration procedure roslaunch usb_cam usb_cam-test.launch
rosrun camera_calibration cameracalibrator.py --size 4x6 --square 0.026 image:=/usb_cam/image_raw camera:=/usb_cam
The second instruction above is to start the calibration procedure , You need to input the chessboard size and square Corresponding to the two values mentioned above
Then you will see the following interface :
On the interface of the calibration program, you can see X Y Size Skew also CALIBRATE, SAVE and COMMIT The logo of
X: Indicates the left and right position of the calibration plate in the field of view
Y: The position on the calibration plate in the lower field of view
Size: Indicates the size of the calibration plate in the field of view , In fact, it's the distance from the camera
Skew: Indicates the inclination angle of the calibration plate in the field of view
After opening the program , You can start to adjust the position of the calibration plate , Let it move and rotate in various positions in the camera's field of view , Give Way X Y Size and Skew The bar below these four values turns green , And then you can see CALIBRATE This button turns blue , Click to start calculating camera parameters , This process needs to wait for a while , Wait patiently
When the calculation is finished , You can go to terminal See the following data
then SAVE The button will also turn blue , Click on SAVE Button will save the data to the default directory .
This catalog is in /tmp/calibrationdata.tar.gz
Open the package , There are pictures just collected , And save the parameters of the camera , as follows :
Put this inside ost.yaml
Unzip and put it in usb_cam Of src Under the table of contents , Then change your name , such as camera_calibration20220531.yaml
, I like to put these configuration files in a folder , Then write down the path
And then it's the last step , open launch file , Add one more line to import camera parameters :
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video2" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_info_url" value="package://usb_cam/camera_info/camera_calibration20220531.yaml"/>
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<param name="autosize" value="true" />
</node>
</launch>
Then follow the usual roslaunch start-up usb cam That's all right. , Then you can compare the measurement results before and after calibration , You will find that the accuracy has been greatly improved .
Reference
- Step1: Model 16 Camera parameters ( Internal reference 、 External reference 、 Distortion parameters ):
https://blog.csdn.net/weixin_43206570/article/details/84797361
边栏推荐
- Online yaml to CSV tool
- Configuring OSPF load sharing for Huawei devices
- JS inheritance method
- String to leading 0
- Rviz仿真时遇到机器人瞬间回到世界坐标原点的问题及可能原因
- PC easy to use essential software (used)
- Is it safe to open an account in Zheshang futures?
- VMware 虚拟化集群
- Trying to use is on a network resource that is unavailable
- Let the bullets fly for a while
猜你喜欢
Let the bullets fly for a while
堆排序详解
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
生成器参数传入参数
延迟初始化和密封类
Cisp-pte practice explanation
Chrome浏览器的crash问题
[brush questions] top101 must be brushed in the interview of niuke.com
Generator parameters incoming parameters
Pointer advanced --- pointer array, array pointer
随机推荐
Unified ordering background interface product description Chinese garbled
leetcode刷题 (5.28) 哈希表
How to conduct interface test? What are the precautions? Nanny level interpretation
Use Alibaba icon in uniapp
Configuring OSPF load sharing for Huawei devices
Precise query of tree tree
torch建立的网络模型使用torchviz显示
sublime text没关闭其他运行就使用CTRL+b运行另外的程序问题
pcd转ply后在meshlab无法打开,提示 Error details: Unespected eof
Image, CV2 read the conversion and size resize change of numpy array of pictures
What is CSRF (Cross Site Request Forgery)?
Deep analysis of C language data storage in memory
Mobile Test Engineer occupation yyds dry goods inventory
Indentation of tabs and spaces when writing programs for sublime text
sublime text的编写程序时的Tab和空格缩进问题
Pointer advanced --- pointer array, array pointer
Sort according to a number in a string in a column of CSV file
C language double pointer -- classic question type
【MySQL】锁
String to leading 0