基于Halcon的条码定位与识别【包含 一维码 和 二维码 】

1.针对一维码问题,先列代码:

dev_update_off ()
dev_close_window ()
dev_open_window (0, 0, 600, 819, 'black', WindowHandle)
dev_set_draw ('margin')
*读图
read_image (Image, '20221213-174036.png')

*获取一维码区域对原图进行抠图
gen_rectangle1 (ROI_0, 2169.33, 1835.88, 2259.55, 2327.62)
gen_rectangle1 (TMP_Region, 2288.74, 1765.13, 2378.96, 2317.01)
union2 (ROI_0, TMP_Region, ROI_0)
reduce_domain (Image, ROI_0, ImageReduced)
crop_domain (ImageReduced, ImagePart)

*创建一维码模型
create_bar_code_model ('element_size_min',1, BarCodeHandle)

*要设置其他参数时候使用
set_bar_code_param (BarCodeHandle, 'element_size_min', 5)

*利用寻码模型解码
find_bar_code (ImageReduced, SymbolRegions, BarCodeHandle, 'auto', DecodedDataStrings1)

get_bar_code_result (BarCodeHandle, 'all', 'orientation', Orientation)
area_center (SymbolRegions, Area, Row, Col)
gen_arrow_contour_xld (Arrow, Row + sin(rad(Orientation)) * 70, Col - cos(rad(Orient

猜你喜欢

转载自blog.csdn.net/weixin_50016546/article/details/129479995