halcon template creation

 1. Draw a regular graphic template

Create a custom function

The code is the code to generate a rectangle or square template

if (Open)
    rotate_image (Image, ImageRotate, 0.7, 'constant')
    emphasize (ImageRotate, ImageEmphasize, 7, 7, 1)
    rgb1_to_gray (ImageEmphasize, GrayImage)
    *自行根据实际情况调整
    gen_contour_polygon_xld (Contour, [350,0,0,350], [0,0,394,394])
    create_shape_model_xld (Contour, 4, rad(-5), rad(10), rad(0.1), 'auto', 'ignore_local_polarity', 10, ModelID)
    write_shape_model (ModelID, 'Pattern/Tab.shm')
endif

return ()

 Call functions

create_model (ImageBalance, false)

2. Draw irregular graphic templates

 if (true)
        dev_get_window (WindowHandle)
        *鼠标点击左键画轮廓,点击右键生成轮廓
        draw_xld (ContOut1, WindowHandle, 'true', 'true', 'true', 'true')
        draw_xld (ContOut2, WindowHandle, 'true', 'true', 'true', 'true')
        concat_obj (ContOut1, ContOut2, ObjectsConcat)
        create_shape_model_xld (ObjectsConcat, 4, rad(-5), rad(10), rad(0.1), 'point_reduction_medium', 'ignore_local_polarity', 10, ModelID)
        write_shape_model (ModelID, 'bus.shm')
    endif

Guess you like

Origin blog.csdn.net/qq_42711010/article/details/130425319