篩選出來的點得坐標已經顯示在PxRow
、PxColunm
里邊
* 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)