1.一维码自定义函数
一维码识别自定义函数:
lib_find_1D_barcode (Image, Contour, Roi, Row, Column, Barcode)
函数对应参数如下图:
函数内容:
try
gen_empty_obj (Contour)
Row := []
Column := []
Barcode := 'NA'
gen_rectangle1 (Rectangle, Roi[0], Roi[1], Roi[2], Roi[3])
reduce_domain (Image, Rectangle, ImageReduced)
*创建条码模型
create_bar_code_model ([], [], BarCodeHandle)
*设置参数
* set_bar_code_param (BarCodeHandle, 'element_size_min', 4)
* set_bar_code_param (BarCodeHandle, 'element_size_max', 32)
* set_bar_code_param (BarCodeHandle, 'check_char', 'present')
* set_bar_code_param (BarCodeHandle, 'persistence', 1)
* set_bar_code_param (BarCodeHandle, 'num_scanlines', 10)
* set_bar_code_param (BarCodeHandle, 'start_stop_tolerance', 'high')
* set_bar_code_param (BarCodeHandle, 'orientation', 0)
* set_bar_code_param (BarCodeHandle, 'orientation_tol', 20)
* set_bar_code_param (BarCodeHandle, 'element_height_min', 100)
* set_bar_code_param (BarCodeHandle, 'stop_after_result_num', 0)
*解码
find_bar_code (ImageReduced, Contour, BarCodeHandle, ['Code 128','Code 39'], BarCodeStrings)
* get_bar_code_param (BarCodeHandle, 'element_size_min', GenParamValue)
* get_bar_code_object (BarCodeObjects, BarCodeHandle, 'all', 'candidate_regions')
* get_bar_code_result (BarCodeHandle, 'all', 'decoded_types', BarCodeResults)
* get_bar_code_result (BarCodeHandle, 0, 'quality_isoiec15416', Quality)
if( BarCodeStrings != [])
Barcode := BarCodeStrings[0]
area_center_xld (Contour, Area, Row, Column, PointOrder)
gen_cross_contour_xld (CrossCenter, Row, Column, sqrt(Area)/2, 0)
concat_obj (Contour, CrossCenter, Contour)
endif
catch (Exception)
endtry
try
*清除条码模型
clear_bar_code_model (BarCodeHandle)
catch (Exception)
endtry
return ()
2.二维码自定义函数
二维码识别自定义函数:
lib_find_2D_barcode(Image, Contour, Roi, Row, Column, Barcode)
函数对应参数如下图:
函数内容:
try
gen_empty_obj (Contour)
Row := []
Column := []
Barcode := 'NA'
gen_rectangle1 (Rectangle, Roi[0], Roi[1], Roi[2], Roi[3])
reduce_domain (Image, Rectangle, ImageReduced)
* create_data_code_2d_model ('Data Matrix ECC 200', 'default_parameters', 'enhanced_recognition', DataCodeHandle)
* find_data_code_2d (ImageReduced, Contour, DataCodeHandle, [], [], ResultHandles, DecodedDataStrings)
create_data_code_2d_model ('Data Matrix ECC 200', 'default_parameters', 'enhanced_recognition', DataCodeHandle)
find_data_code_2d (ImageReduced, Contour, DataCodeHandle, 'train', 'all', ResultHandles, DecodedDataStrings)
if (DecodedDataStrings != [])
Barcode := DecodedDataStrings[0]
area_center_xld (Contour, Area, Row, Column, PointOrder)
gen_cross_contour_xld (CrossCenter, Row, Column, sqrt(Area)/2, 0)
concat_obj (Contour, CrossCenter, Contour)
endif
catch (Exception)
endtry
try
clear_data_code_2d_model (DataCodeHandle)
catch (Exception)
endtry
return ()
以上就是我自定义创建的函数,方便后面调用。