1. 程式人生 > 其它 >九點標定進行仿射變換halcon模擬程式碼

九點標定進行仿射變換halcon模擬程式碼

技術標籤:# Halcon影象處理例項

篩選出來的點得座標已經顯示在PxRowPxColunm裡邊

* Image Acquisition 01: Code generated by Image Acquisition 01
read_image (Image, 'C:/Users/Administrator/Desktop/標定板圖片.png')
dev_close_window ()
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_display (Image)
binary_threshold (Image, Region
, 'max_separability', 'dark', UsedThreshold) connection (Region, ConnectedRegions) *篩選出來九個點 select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 70) shape_trans (SelectedRegions, RegionTrans, 'outer_circle') *求出九點座標 area_center (RegionTrans, Area, Row, Column) disp_message (WindowHandle, 'R:'
+Row+' C:'+Column, 'Image', Row, Column, 'black', 'true') *九點標定行 PxRow:=[23.5, 23.5, 23.5, 71.5, 71.5, 71.5, 118.5, 118.5, 118.5] *九點標定列 PxColunm:=[28.5, 75.5, 122.5, 28.5, 75.5, 122.5, 28.5, 75.5, 122.5] *機器座標行 Qx:=[100,50,0,100,50,0,100,50,0] *機器座標列 Qy:=[0,0,0,50,50,50,100,100,100] *拿到機器座標和畫素座標求出關係矩陣 * 標定行
標定列 機器X 機器Y 得到矩陣 vector_to_hom_mat2d (PxRow, PxColunm, Qx, Qy, HomMat2D) *儲存矩陣 write_tuple (HomMat2D, '九點標定.tup') *讀取矩陣 read_tuple ('九點標定.tup', HomMat2D) *利用求出來的物體行列座標得到機器座標 affine_trans_point_2d (HomMat2D, PxRow, PxColunm, Qx1, Qy1)