Halcon 單相機標定板標定
首先得到相機的內參
gen_cam_par_area_scan_division (0.012, 0, 0.00000375, 0.00000375, 640, 480, 1280, 960, StartCamPar)
普通的畸變:’area_scan_division’ [’area_scan_division’, Focus, Kappa, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight
高精度畸變(多項式子):’area_scan_polynomial’ [’area_scan_polynomial’, Focus, K1, K2, K3, P1, P2, Sx, Sy, Cx, Cy, ImageWidth, ImageHeight
然後建立標定物件:
create_calib_data ('calibration_object', 1, 1, CalibDataID)//建立標定物件
set_calib_data_cam_param (CalibDataID, 0, [], StartCamPar)//設定相機的引數
set_calib_data_calib_object (CalibDataID, 0, 'calplate_80mm.cpd')//設定標定板的檔案
//查詢標定板
NumImages := 7
for I := 1 to NumImages by 1
read_image (Image, ImgPath + 'calib_image_' + I$'02d')
dev_display (Image)
find_calib_object (Image, CalibDataID, 0, 0, I, [], [])
get_calib_data_observ_contours (Caltab, CalibDataID, 'caltab', 0, 0, I)
get_calib_data_observ_points (CalibDataID, 0, 0, I, Row, Column, Index, StartPose)//獲取標定板的位姿
dev_set_color ('green')
dev_display (Caltab)
dev_set_color ('red')
disp_circle (WindowHandle, Row, Column, gen_tuple_const(|Row|,1.5))
endfor
//糾正實際世界座標位姿
set_origin_pose (Pose, 0, 0, 0.002, Pose)//由於標定板的厚度是0.02,所以Z平移到相機座標需要加上0.02
//標定相機
calibrate_cameras (CalibDataID, Errors)//標定相機
get_calib_data (CalibDataID, 'camera', 0, 'params', CamParam)//得到相機標定後的相機內參,這個內參包含了畸變引數
get_calib_data (CalibDataID, 'calib_obj_pose', [0,1], 'pose', Pose)//以第一張圖作為參考平面,得到參考平面的座標位姿
//座標轉換
image_points_to_world_plane (CamParam, Pose, Row, Col, 'mm', X1, Y1)//將相機平面對映到實際座標位置
位姿:描述是世界座標轉換到相機座標的旋轉平移引數