Halcon 矫正图像 图像矫正
目录
原图
矫正后的图像
编辑
示例代码
原图
矫正后的图像
示例代码
找ROI部分代码暂无法分享
HomMat2DInvert := []Row_T := []Col_T := []region_features (ROI, 'rectangularity', Value)if (Value > RectY)HomMat2DInvert := []smallest_rectangle1 (ROI, Row_T, Col_T, Row2, Column2)reduce_domain (Image, ROI, ImageReduced)crop_domain (ImageReduced, ImagePart)move_region (ROI, ROIM, -Row_T, -Col_T)else* 矫正boundary (ROI, RegionBorder, 'inner')gen_contour_region_xld (RegionBorder, Contours, 'border')segment_contours_xld (Contours, ContoursSplit, 'lines', 15, 4, 2)area_center (ROI, Area, Row, Column)select_shape_xld (ContoursSplit, XLD1, 'rect2_phi', 'and', rad(-20), rad(20))* 标记UT := 0DT := 0LT := 0RT := 0* 上select_shape_xld (XLD1, XLD, 'row1', 'and', -1, Row)length_xld (XLD, Length)tuple_median (Length, Median)select_shape_xld (XLD, XLD, 'contlength', 'and', max2(200,Median), 999999999)count_obj (XLD, Num)if (Num == 1)copy_obj (XLD, XLDUp, 1, 1)fit_line_contour_xld (XLDUp, 'tukey', -1, 0, 5, 2, RowBeginUp, ColBeginUp, RowEndUp, ColEndUp, Nr, Nc, Dist)elseUT := 1sort_contours_xld (XLD, SortedContours, 'upper_left', 'true', 'column')select_obj (SortedContours, XLDUp_1, 1)select_obj (SortedContours, XLDUp_2, Num)fit_line_contour_xld (XLDUp_1, 'tukey', -1, 0, 5, 2, RowBeginUp1, ColBeginUp1, RowEndUp1, ColEndUp1, Nr, N