先读取你先要抓取边缘的图片,然后绘制矩形区域,方向垂直于边缘,参数我都备注了。
read_image (Image, ‘D:/users/S200722103/桌面/57自动线U型胶缺陷检测/泡棉缺陷检测完成版本2021.2.18/泡棉缺陷检测完成版本2021.2.18/泡棉原图/0 (7).jpg’)
get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width/4, Height/4, ‘black’, WindowHandle)
dev_display (Image)
dev_set_draw (‘margin’)
dev_set_line_width (2)
dev_set_color (‘blue’)
stop ()
draw_rectangle2 (WindowHandle, Row, Column, Phi, Length1, Length2)
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
*smallest_rectangle2 (Rectangle, Row3, Column3, Phi1, Length11, Length21)
*测量矩形中线2 平行于边缘
hom_mat2d_identity (HomMat2DIdentity1)
hom_mat2d_rotate (HomMat2DIdentity1, Phi-rad(90), Row, Column, HomMat2DRotate1)
affine_trans_pixel (HomMat2DRotate1, Row, Column+Length2, RowTrans, ColTrans)
affine_trans_pixel (HomMat2DRotate1, Row, Column-Le