opencv 摄像头标定后得到了内外参数,然后怎么把图片上两点的距离换算为物理实际距离呢?感谢!

2025-03-01 11:53:11
推荐回答(2个)
回答1:

我重新编译了Calibration那个程序,然后自己写了个批处理.bat文件,代码如下,删除txt,然后调用它del/f/qlist_of_images_auto(bmp).txtdir*.bmp/B>>list_of_images_auto(bmp).txtOpenCV_Example_Calibration.exe-w7-h8-s5-ocamera.txt-op-oelist_of_images_auto(bmp).txtpause其中-ocamera.txt表示输出参数的文件名。不过这样用着不爽。你看源代码里面cvWrite(fs,"camera_matrix",camera_matrix);cvWrite(fs,"distortion_coefficients",dist_coeffs);的地方,知道什么意思了吧,向txt里面写这两个参数我后来是这么存的cvSave("DistortionMatrix.xml",dist_coeffs);cvSave("IntrinsicsMatrix.xml",camera_matrix);这样下次调用的时候可以直接用矩阵拿来计算矫正intrinsic=(CvMat*)cvLoad("IntrinsicsMatrix.xml");distortion=(CvMat*)cvLoad("DistortionMatrix.xml");。。。cvInitUndistortMap(this->imgprocess.intrinsic,this->imgprocess.distortion,this->imgprocess.mapx,this->imgprocess.mapy);等

回答2:

opencv中文论坛上那篇文章说得很清楚啊:

http://www.opencv.org.cn/forum.php?mod=viewthread&tid=11802