close

關鍵在於

1.將相機上的點座標與軸控的點座標各自找出後   建立紡射變換

後續再由座標轉換  由 影像上的座標轉換到軸控的座標系

vector_to_hom_mat2d (Cols, Rows, PLCcol, PLCrow, HomMat2D)

affine_trans_point_2d (HomMat2D, TestCol, TestRow, Qx, Qy)

'=================================================================

dev_clear_window ()
read_image (Image, 'D:/yuezhan/项目/201859定位/t2/Vision/dingwei/biaoding.jpg')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
rgb1_to_gray (Image, GrayImage)
dev_display (GrayImage)
invert_image (GrayImage, ImageInvert)
threshold (ImageInvert, Regions, 62, 255)
connection (Regions, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 400, 700)
count_obj (SelectedRegions, Number)
for Index := 1 to Number by 1
    select_obj (SelectedRegions, ObjectSelected, Index)
    dev_display (ObjectSelected)
    *stop()    
endfor
sort_region (SelectedRegions, SortedRegions, 'character', 'true', 'row')

Rows :=[]
Cols :=[]
count_obj (SortedRegions, Number1)
for Index1 := 1 to Number1 by 1
    select_obj (SortedRegions, ObjectSelected1, Index1)
    area_center (ObjectSelected1, Area, Row, Column)
    if(Index1 == 1)
        Rows := [Rows,Row]
        Cols := [Cols,Column]
    elseif(Index1 ==3)
        Rows := [Rows,Row]
        Cols := [Cols,Column]
    elseif(Index1 == 5)
        Rows := [Rows,Row]
        Cols := [Cols,Column]
    elseif(Index1 == 19)
        Rows := [Rows,Row]
        Cols := [Cols,Column]    
    elseif(Index1 == 21)
        Rows := [Rows,Row]
        Cols := [Cols,Column]
    elseif(Index1 == 23)
        Rows := [Rows,Row]
        Cols := [Cols,Column]
    elseif(Index1 == 37)
        Rows := [Rows,Row]
        Cols := [Cols,Column]
     elseif(Index1 == 39)
        Rows := [Rows,Row]
        Cols := [Cols,Column]
     elseif(Index1 == 41)
        Rows := [Rows,Row]
        Cols := [Cols,Column]
    endif  
endfor

PLCrow :=[1,1,1,2,2,2,3,3,3]
PLCcol :=[1,2,3,1,2,3,1,2,3]
*标定
vector_to_hom_mat2d (Cols, Rows, PLCcol, PLCrow, HomMat2D)





*TestCol := 0
*TestRow := 0
TestCol :=[600,100,2000,300]
TestRow :=[120,240,360,480]
*找到对应的点
affine_trans_point_2d (HomMat2D, TestCol, TestRow, Qx, Qy)

arrow
arrow
    文章標籤
    Halcon
    全站熱搜

    Rh 發表在 痞客邦 留言(0) 人氣()