find_local_deformable_model_three_squirrel.hdev代码尝试修改

dev_update_off ()
read_image (ModelImage, 'ref2.tif')
rgb1_to_gray (ModelImage,ModelImage )
dev_close_window ()
dev_open_window_fit_image (ModelImage, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
* 
* Create and display the local deformable model
create_local_deformable_model (ModelImage, 'auto', rad(-15), rad(30), 'auto', 1, 1, 'auto', 1, 1, 'auto', 'none', 'use_polarity', [15,35], 'auto', [], [], ModelID)
get_deformable_model_contours (ModelContours, ModelID, 1)
area_center (ModelImage, Area, Row, Column)
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_translate (HomMat2DIdentity, Row, Column, HomMat2DTranslate)
affine_trans_contour_xld (ModelContours, ContoursAffinTrans, HomMat2DTranslate)
dev_set_line_width (2)
dev_set_color ('yellow')
dev_display (ModelImage)
dev_display (ContoursAffinTrans)
disp_message (WindowHandle, 'Model image and contours', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
* 
Smoothness := 19
NumImages := 5
for Index := 2 to NumImages by 1
    read_image (Image, Index+'.tif')
    dev_resize_window_fit_image (Image, 0, 0, -1, -1)
    dev_display (Image)
    disp_message (WindowHandle, 'Search ...', 'window', 12, 12, 'black', 'true')
    count_seconds (S1)
    * Find the model in the deformed search image.
    * As result, the rectified image, the respective
    * vector field, and the found contours are queried.
    find_local_deformable_model (Image, ImageRectified, VectorField, DeformedContours, ModelID, rad(-5), rad(18), 1, 1, 1, 1, 0.78, 0, 0, 0, 0.45, ['image_rectified','vector_field','deformed_contours'], ['deformation_smoothness','expand_border','subpixel'], [Smoothness,0,0], Score, Row, Column)
    count_seconds (S2)
    Time := S2 - S1
    * Visualize the deformation as a mesh generated from
    * the returned vector field
    gen_warped_mesh (VectorField, WarpedMesh, Smoothness / 2)
    dev_set_line_width (1)
    dev_set_color ('yellow')
    dev_display (WarpedMesh)
    Found[Index] := |Score|
    dev_set_line_width (2)
    dev_set_color ('green')
    dev_display (DeformedContours)
    disp_message (WindowHandle, |Score| + ' matches found in ' + Time$'1.2f' + ' s', 'window', 12, 12, 'black', 'true')
    for J := 0 to |Score| - 1 by 1
        disp_message (WindowHandle, 'Score: ' + Score[J]$'.2f', 'image', 350, Column[J] - 80, 'black', 'true')
    endfor
    if (Index < NumImages)
        disp_continue_message (WindowHandle, 'black', 'true')
        stop ()
    endif
endfor
* 
* Clean up
clear_deformable_model (ModelID)

by SRT

find_local_deformable_model_three_squirrel.hdev代码尝试修改_第1张图片

从这个可以看出将要处理的图片

create_local_deformable_model (ModelImage, 'auto', rad(-15), rad(30), 'auto', 1, 1, 'auto', 1, 1, 'auto', 'none', 'use_polarity', [15,35], 'auto', [], [], ModelID)

find_local_deformable_model (Image, ImageRectified, VectorField, DeformedContours, ModelID, rad(-5), rad(18), 1, 1, 1, 1, 0.78, 0, 0, 0, 0.45, ['image_rectified','vector_field','deformed_contours'], ['deformation_smoothness','expand_border','subpixel'], [Smoothness,0,0], Score, Row, Column)

 

仍然以这两个为主要代码

下面上图,参数调整了很多但速度还是不快,图片一张4.8MB比较大了,我考虑回头加上小波压缩这类压缩算法看看结果。

find_local_deformable_model_three_squirrel.hdev代码尝试修改_第2张图片find_local_deformable_model_three_squirrel.hdev代码尝试修改_第3张图片find_local_deformable_model_three_squirrel.hdev代码尝试修改_第4张图片

 

你可能感兴趣的:(halcon例程学习)