您的位置:首页 > 其它

二维码读取之2d_data_codes_rectify_symbol.hdev

2020-08-28 23:11 761 查看

*这个实例展示了如何读取一个经过修正的倾斜的条码

  • This program demonstrates how to read a slanted
  • 2d data code by preprocessing with rectification
  • 关闭更新
    dev_update_off ()
    *关闭窗体
    dev_close_window ()
    *获取图像并且显示
  • Get the image and display it
    read_image (Image_slanted, ‘datacode/ecc200/ecc200_to_preprocess_001’)
    *打开适合图像尺寸的窗体
    dev_open_window_fit_image (Image_slanted, 0, 0, -1, -1, WindowHandle)
    *设置显示字体
    set_display_font (WindowHandle, 14, ‘mono’, ‘true’, ‘false’)
    *设置显示颜色
    dev_set_color (‘green’)
    *设置线宽
    dev_set_line_width (3)
    *信息
    Message := ‘This program demonstrates how to preprocess’
    Message[1] := ‘a slanted 2d data code with rectification’
    Message[2] := ‘before reading the data code symbol.’
    *显示Message
    disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
    *右下角显示’Press F5 TO continue’
    disp_continue_message (WindowHandle, ‘black’, ‘true’)
    stop ()
    *初始化坐标
  • Initialize coordinates
    XCoordCorners := [130,225,290,63]
    YCoordCorners := [101,96,289,269]
  • 显示倾斜图像四角坐标
  • Display the slanted image and the corners of the symbol
    gen_cross_contour_xld (Crosses, XCoordCorners, YCoordCorners, 6, 0.785398)
    *显示图像
    dev_display (Image_slanted)
    *显示十字叉
    dev_display (Crosses)
    *显示图像
    disp_message (WindowHandle, ‘Slanted image’, ‘window’, 12, 12, ‘black’, ‘true’)
    Message := ‘The marked corners are used to generate a’
    Message[1] := ‘homogeneous transformation matrix which’
    Message[2] := ‘defines the projective transformation for’
    Message[3] := ‘the rectification of the symbol.’
    *显示信息
    disp_message (WindowHandle, Message, ‘window’, 380, 12, ‘black’, ‘true’)
    *右下角显示’Press F5 TO continue’
    disp_continue_message (WindowHandle, ‘black’, ‘true’)
    stop ()
  • 第一步,用条码四角现有的点生成一个从四角点到修正后的条码正方形的变换矩阵
  • First generate a transformation matrix using the given points
  • of the corners of the data code symbol and the corresponding points
  • of a quare.
    *求投影矩阵变换
    hom_vector_to_proj_hom_mat2d (XCoordCorners, YCoordCorners, [1,1,1,1], [70,270,270,70], [100,100,300,300], [1,1,1,1], ‘normalized_dlt’, HomMat2D)
  • 通过投影变换纠正倾斜图像
  • Now rectifiy the slanted image by applying the projective transformation
    projective_trans_image (Image_slanted, Image_rectified, HomMat2D, ‘bilinear’, ‘false’, ‘false’)
  • 创建二维码读取器,并且在纠正图像中读取二维码
  • Create the data code model and search
  • for the data code in the rectified image
    *创建一维码读取器
    create_data_code_2d_model (‘Data Matrix ECC 200’, [], [], DataCodeHandle)
    *读取二维码
    find_data_code_2d (Image_rectified, SymbolXLDs, DataCodeHandle, [], [], ResultHandles, DecodedDataStrings)
  • 显示结果
  • Display result
    dev_display (Image_slanted)
    *显示元图像
    dev_display (Image_rectified)
    *显示二维码区域
    dev_display (SymbolXLDs)
    *显示信息
    disp_message (WindowHandle, 'Decoding successful ', ‘window’, 12, 12, ‘black’, ‘true’)
    *设置显示字体
    set_display_font (WindowHandle, 12, ‘mono’, ‘true’, ‘false’)
    *显示信息
    disp_message (WindowHandle, DecodedDataStrings, ‘window’, 350, 70, ‘forest green’, ‘true’)
  • 清除句柄,释放内存
  • Clear the data code model
    clear_data_code_2d_model (DataCodeHandle)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: