create_text_model_reader

* read_image (Image, 'D://10.bmp')
*draw_rectangle2 (3600, Row, Column, Phi, Length1, Length2)
* rgb1_to_gray (Image, GrayImage)
* gen_rectangle2 (Rectangle, 60.518, 301.901, 0, 74.1184, 22.560)
* reduce_domain (GrayImage,Rectangle , ImageReduced)
* scale_image_max (ImageReduced, ImageScaleMax)
* char_threshold (ImageScaleMax, Rectangle, Characters, 0, 100, Threshold)
* connection (Characters, ConnectedRegions3)
* region_features (ConnectedRegions3, 'width', Value2)
* partition_dynamic (Characters, Partitioned, 27, 40)
* connection (Partitioned, ConnectedRegions2)
* region_features (ConnectedRegions2, 'width', Value)
* region_features (ConnectedRegions2, 'height', Value1)

create_text_model_reader ('manual', [], TextModel)
* set_text_model_param (TextModel, 'is_dotprint', 'false')
set_text_model_param (TextModel, 'char_width', 29)
set_text_model_param (TextModel, 'char_height', 24)
set_text_model_param (TextModel, 'stroke_width',9.3)
* set_text_model_param (TextModel, 'return_punctuation', 'false')
* set_text_model_param (TextModel, 'return_separators', 'false')
set_text_model_param (TextModel, 'uppercase_only', 'true')
* set_text_model_param (TextModel, 'fragment_size_min', 24)
* set_text_model_param (TextModel, 'add_fragments', 'false')
* set_text_model_param (TextModel, 'base_line_tolerance', 0.2)
set_text_model_param (TextModel, 'max_line_num', 1)

read_image (Image, 'D:1-2.bmp')
gen_rectangle2 (Rectangle, 135.812, 738.993, 0.0068, 69.1218, 16.0398)
rgb1_to_gray (Image, GrayImage)

reduce_domain (GrayImage, Rectangle, ImageReduced)

scale_image_max (ImageReduced, ImageScaleMax)

read_ocr_class_mlp ('D://1-6bmp.omc', OcrHandle)
find_text (ImageScaleMax, TextModel, TmpCtrl_ResultHandle_OCR_01_0)
* OCR 01: 
* OCR 01: Read text (classification step)
get_text_object (Symbols_OCR_01_0, TmpCtrl_ResultHandle_OCR_01_0, 'all_lines')
* clear_text_result (TmpCtrl_ResultHandle_OCR_01_0)
* dev_display (ImageReduced)
* dev_set_draw ('fill')
* dev_set_colored (3)
* dev_display (Symbols_OCR_01_0)
do_ocr_multi_class_mlp (Symbols_OCR_01_0, ImageScaleMax, OcrHandle, SymbolNames_OCR_01_0, Confidences_OCR_01_0)

* threshold (ImageReduced, Region, 0, 200)
* connection (Region, ConnectedRegions)
* sort_region (ConnectedRegions, SortedRegions, 'character', 'true', 'column')
* count_obj (SortedRegions, Number)
* read_ocr_class_mlp ('C:/Program Files/MVTec/HALCON-12.0/ocr/DotPrint.omc', OCRHandle)

* threshold (GrayImage, Region1, 0, 200)
* connection (Region1, ConnectedRegions1)
* sort_region (ConnectedRegions1, SortedRegions1, 'character', 'true', 'column')
* count_obj (SortedRegions1, Number1)
* do_ocr_multi_class_mlp (SortedRegions1, GrayImage, OCRHandle, Class, Confidence)
*显示结果
* dev_clear_window ()
* dev_display (Image)
* dev_set_color ('black')
* disp_message(3600, '识别结果:', 'image', 550, 50, 'black', 'false')
* for i:=1 to Number1 by 1
*     disp_message(3600, Class[i-1], 'image', 0, 0, 'red', 'false')
* endfor


* read_image (Image, 'E:/ocr/lot_number_02.png')
* draw_rectangle2 (3600, Row, Column, Phi, Length1, Length2)
* rgb1_to_gray (Image, GrayImage)
* gen_rectangle2 (Rectangle, 247.776, 304.262, 0, 55.5228, 51.9557)
* reduce_domain (GrayImage,Rectangle , ImageReduced)
* threshold (ImageReduced, Region, 48, 157)
* connection (Region, ConnectedRegions)
* sort_region (ConnectedRegions, SortedRegions, 'character', 'true', 'column')
* count_obj (SortedRegions, Number)


* read_image (Image, 'E:/ocr/lot_number_12.png')
* draw_rectangle2 (3600, Row, Column, Phi, Length1, Length2)
* rgb1_to_gray (Image, GrayImage)
* binary_threshold (GrayImage, Region1, 'max_separability', 'dark', UsedThreshold) 
* opening_rectangle1 (Region1, RegionOpen, 10, 50)  
* closing_rectangle1 (Region1, RegionClosing, 10, 10)
* connection (Region1, ConnectedRegions)
* select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 150, 3999)
* sort_region (SelectedRegions, SortedRegions, 'character', 'true', 'column')
* count_obj (SortedRegions, Number)

明天回家了

你可能感兴趣的:(笔记,开发语言)