Halcon识别瓶盖字体,极坐标转换
read_image (Image, 'D:/image/bilibili/photo/检测字符.png')
***转为灰度图
rgb1_to_gray (Image, GrayImage)
threshold (GrayImage, Regions, 115, 255)
get_image_size (GrayImage, Width, Height)
*****填充
fill_up (Regions, RegionFillUp1)
opening_circle (RegionFillUp1, RegionOpening1, 3.5)
connection (RegionOpening1, ConnectedRegions2)
select_shape (ConnectedRegions2, SelectedRegions, 'area', 'and', 41009.2, 66330.3)
smallest_circle (SelectedRegions, Row, Column, Radius)
gen_circle (Circle, Row, Column, Radius)
gen_circle (Circle1, Row, Column, Radius-40)
difference (Circle, Circle1, RegionDifference)
************************************将图像中的环形弧转换为极坐标
polar_trans_image_ext (GrayImage, PolarTransImage, Row, Column, 0, rad(360),\
Radius, Radius-40, Width, 40, 'nearest_neighbor')
***旋转180
rotate_image (PolarTransImage, ImageRotate, -180, 'constant')
**镜像
mirror_image (ImageRotate, ImageMirror, 'row')
threshold (ImageMirror, Regions1, 25, 93)
connection (Regions1, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions1, ['column','area','row'], 'and', [185.78,72.02,6.009], [500,436.24,50])
****识别字符
sort_region (SelectedRegions1, SortedRegions, 'first_point', 'true', 'column')
read_ocr_class_mlp ('Document_0-9A-Z_NoRej.omc', OCRHandle)
do_ocr_multi_class_mlp (SortedRegions, ImageMirror, OCRHandle, Class, Confidence)