dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
read_image (Image20160713, 'C:/Users/gwd/Desktop/20160713.png')
get_image_size (Image20160713, Width, Height)
gen_rectangle1 (ROI_0, 97.3428, 119.137, 219.979, 488.137)
text_line_orientation (ROI_0, Image20160713, 25, -0.523599, 0.523599, OrientationAngle)
vector_angle_to_rigid (Height/2, Width/2, OrientationAngle, Height/2, Width/2, 0, HomMat2D)
affine_trans_image (Image20160713, ImageAffineTrans, HomMat2D, 'constant', 'false')
dots_image (ImageAffineTrans, DotImage, 5, 'dark', 0)
reduce_domain (DotImage, ROI_0, ImageReduced)
invert_image (ImageReduced, ImageInvert)
binary_threshold (ImageReduced, Region, 'max_separability', 'light', UsedThreshold)
dilation_rectangle1 (Region, RegionDilation, 3.5, 6.5)
connection (RegionDilation, ConnectedRegions)
shape_trans (ConnectedRegions, RegionTrans, 'rectangle1')
select_shape (RegionTrans, SelectedRegions, 'area', 'and', 182.59, 2000)
intersection (SelectedRegions, Region, RegionIntersection)
sort_region (RegionIntersection, SortedRegions, 'character', 'true', 'row')
*此处用halcon自带的点状库
read_ocr_class_mlp ('DotPrint_0-9A-Z_NoRej.omc', OCRHandle)
do_ocr_multi_class_mlp (SortedRegions, ImageInvert, OCRHandle, Class, Confidence)
dev_display (ImageAffineTrans)
smallest_rectangle1 (SortedRegions, Row1, Column1, Row2, Column2)
count_obj (SortedRegions, Number)
for i:=1 to Number by 1
*显示
disp_message (WindowHandle, Class[i-1], 'Image2016', Row2[i-1]+30, Column1[i-1], 'red', 'true')
endfor
第二个点状图片:
read_image (Image11, 'C:/Users/gwd/Desktop/2.bmp')
get_image_size (Image, Width, Height)
gen_rectangle1 (ROI_0, 258.5, 348.25, 572.5, 1095.75)
text_line_orientation (ROI_0, Image, 25, -0.523599, 0.523599, OrientationAngle)
vector_angle_to_rigid (Height/2, Width/2, OrientationAngle, Height/2, Width/2, 0, HomMat2D)
affine_trans_image (Image, ImageAffineTrans, HomMat2D, 'constant', 'false')
dots_image (ImageAffineTrans, DotImage, 5, 'dark', 0)
reduce_domain (DotImage, ROI_0, ImageReduced)
invert_image (ImageReduced, ImageInvert)
binary_threshold (ImageReduced, Region, 'max_separability', 'light', UsedThreshold)
dilation_rectangle1 (Region, RegionDilation, 5, 13.5)
connection (RegionDilation, ConnectedRegions)
shape_trans (ConnectedRegions, RegionTrans, 'rectangle1')
select_shape (RegionTrans, SelectedRegions, 'area', 'and', 499.15, 5000)
intersection (SelectedRegions, Region, RegionIntersection)
sort_region (RegionIntersection, SortedRegions, 'character', 'true', 'row')
read_ocr_class_mlp ('DotPrint_0-9A-Z_NoRej.omc', OCRHandle)
do_ocr_multi_class_mlp (SortedRegions, ImageInvert, OCRHandle, Class, Confidence)
dev_display (ImageAffineTrans)
smallest_rectangle1 (SortedRegions, Row1, Column1, Row2, Column2)
count_obj (SortedRegions, Number)
for i:=1 to Number by 1
disp_message (200000, Class[i-1], 'Image2016', Row2[i-1]+30, Column1[i-1], 'red', 'true')