Halcon 生成標(biāo)定板
Halcon生成標(biāo)定板:
gen_caltab(7, 7, 0.0125, 0.5, 'caltab.descr', 'caltab.ps')
XNum:X軸圓點數(shù)量
YNum:Y軸圓點數(shù)量
MarkDist:圓點間距,單位為米
DiameterRatio:圓點直徑與間距的比率
CalPlateDescr:標(biāo)定板描述文件
CalPlatePSFile:標(biāo)定板PostScript圖案,可以用PhotoShop打開。
Halcon12開始,可以使用新版蜂窩標(biāo)定板,生成代碼:
create_caltab(27, 31, 0.00258065, [13,6,6,20,20], [15,6,24,6,24], 'light_on_dark', 'calplate.cpd', 'calplate.ps')
NumRows:圓點行數(shù)
MarksPerRow:每行圓點數(shù)
Diameter:圓點直徑,單位為米
FinderRow:所有尋位標(biāo)志的行號
FinderColumn:所有尋位標(biāo)志的列號
Polarity:背景色,黑或白
新版蜂窩標(biāo)定板的行列數(shù)可以任意設(shè)置,圓心距為圓點直徑的2倍,尋位標(biāo)志不能多于5個
標(biāo)定板的精度建議比檢測精度高5-10倍,以下是不同標(biāo)定板制作工藝的大致精度:
(1)菲林印制,精度大致能做到0.05mm - 0.1mm,菲林就是電影底片,厚度一般為0.18mm,白色部分透明,需要用玻璃板壓平;
(2)氧化鋁標(biāo)定板,精度一般為0.01 - 0.001mm,用玻璃或陶瓷做基板,白色部分不透明,表面漫反射;
(3)玻璃標(biāo)定板,精度能做到0.001mm,圖案用光刻工藝加工,表面平整度很高,白色部分透明,黑色部分反光,可以用背光。
標(biāo)定板的尺寸選擇:
老版標(biāo)定板圖案尺寸為視場的1/2到3/4,新版蜂窩標(biāo)定板需要視場覆蓋1/3到2/3圖案區(qū)域,必須拍到至少1個尋位點
圓點直徑所占像素要大于50個,例如相機分辨率1280x960pix,視場大小40x30mm,則圓點直徑大概1.5mm。
Halcon標(biāo)定相機外參也可使用棋盤格標(biāo)定板,下面為代碼:
dev_update_off() read_image(Image, 'chessboard.png') gen_rectangle1 (ROI, 108.076, 86.0433, 406.842, 505.387) reduce_domain(Image, ROI, ImageReduced) dev_display(Image) * 1通過Harris方法提取角點 points_harris(ImageReduced, 0.7, 4, 0.08, 1000, Rows, Cols) gen_cross_contour_xld(Corners, Rows, Cols, 6, 0) dev_set_color('red') dev_display(Corners) stop() * 2通過邊緣擬合直線交叉點的方式提取角點 edges_sub_pix (ImageReduced, Edges, 'canny', 1, 20, 40) segment_contours_xld(Edges, ContoursSplit, 'lines_circles', 5, 4, 2) select_contours_xld(ContoursSplit, SelectedContours, 'contour_length', 10, 200, 0, 0) select_contours_xld(SelectedContours, HorizontalContours, 'direction', rad(-10), rad(10), 0, 0) union_adjacent_contours_xld(HorizontalContours, HorizontalContours, 10, 1, 'attr_keep') select_contours_xld(SelectedContours, VerticalContours, 'direction', rad(80), rad(100), 0, 0) union_adjacent_contours_xld(VerticalContours, VerticalContours, 10, 1, 'attr_keep') fit_line_contour_xld(HorizontalContours, 'tukey', -1, 0, 5, 2, RowBegin1, ColBegin1, RowEnd1, ColEnd1, Nr1, Nc1, Dist1) fit_line_contour_xld(VerticalContours, 'tukey', -1, 0, 5, 2, RowBegin2, ColBegin2, RowEnd2, ColEnd2, Nr2, Nc2, Dist2) Rows := [] Cols := [] for I := 0 to |RowBegin1| - 1 by 1 for J := 0 to |RowBegin2| - 1 by 1 intersection_lines(RowBegin1[I], ColBegin1[I], RowEnd1[I], ColEnd1[I], RowBegin2[J], ColBegin2[J], RowEnd2[J], ColEnd2[J], Row, Col, IsOverlapping) Rows := [Rows, Row] Cols := [Cols, Col] endfor endfor gen_cross_contour_xld(Corners, Rows, Cols, 6, 0) dev_set_color('green') dev_display(Corners) stop() * 擬合棋盤格平面位姿 WorldX := [] WorldY := [] WorldZ := [] for X := 0 to 10 by 1 for Y := 0 to 7 by 1 WorldX := [WorldX, X * 10] WorldY := [WorldY, Y * 10] WorldZ := [WorldZ, 0] endfor endfor read_cam_par ('cam_param.cal', CameraParam) vector_to_pose(WorldX, WorldY, WorldZ, Rows, Cols, CameraParam, 'iterative', 'error', Pose, Quality)

這里用兩種方法提取棋盤格的角點,如果鏡頭畸變較大的情況下,Harris方法精度更高。

浙公網(wǎng)安備 33010602011771號