zoukankan      html  css  js  c++  java
  • 模板匹配

    dev_close_window ()
    dev_open_window (0, 0, 512, 512, 'black', WindowHandle)

    read_image (Image00228, 'D:/TestImg/图像00228.BMP')

    dev_set_draw ('margin')

    *第一种方法:用一个半径为18的圆去匹配图像

    *此处创建了一个半径为18的轮廓圆
    gen_circle_contour_xld (ROI_0, 0, 0, 18, 0, 6.28318, 'positive', 1)

    *根据xld创建模板
    create_shape_model_xld (ROI_0, 'auto',rad(-180), rad(360), 'auto', 'auto', 'ignore_local_polarity', 5, ModelID)


    *获取模板轮廓
    get_shape_model_contours (ModelContours, ModelID, 1)

    *模板匹配
    find_shape_model (Image00228, ModelID,rad(-180), rad(360), 0.5, 30, 0.5, 'least_squares', 0, 0.9, Row, Column, Angle, Score)

    if( |Row|>0 )

    dev_display (Image00228)
    disp_message (WindowHandle, '零件个数=' + |Row|, 'window', 50, 50, 'black', 'true')
    dev_display_shape_matching_results (ModelID, 'red', Row, Column, Angle, 1, 1, 0)

    else
    disp_message (WindowHandle, '一个都没有找到!', 'window', 50, 50, 'black', 'true')
    endif


    disp_continue_message (WindowHandle, 'black', 'true')
    stop()

    *第二种方法:用图像轮廓去匹配图像

    dev_clear_window ()
    dev_display (Image00228)
    gen_circle (ROI_0, 232.275, 480.52, 35.9315)
    reduce_domain (Image00228, ROI_0, ImageReduced)
    create_shape_model (ImageReduced, 'auto', rad(-180), rad(360), 'auto', 'auto', 'use_polarity', 'auto', 'auto', ModelID1)
    get_shape_model_contours (ModelContours1, ModelID1, 1)
    find_shape_model (Image00228, ModelID1, rad(-180), rad(360), 0.5, 30, 0.5, 'least_squares', 0, 0.9, Row1, Column1, Angle1, Score1)
    if( |Row1| > 0 )
    dev_display_shape_matching_results (ModelID1, 'red', Row1, Column1, Angle1, 1, 1, 0)
    endif

  • 相关阅读:
    Cookie和Session的作用和工作原理
    df和du显示的磁盘空间使用情况不一致问题
    haproxy配置详解
    使用LVS实现负载均衡原理及安装配置详解
    四层、七层负载均衡的区别
    Linux内核参数之arp_ignore和arp_announce
    Megacli查看Dell服务器Raid状态
    Visual Studio 2015中使用gdb远程调试linux程序
    编译Qt-mingw使用的opencv
    [webrtc] 强制使用tcp传输
  • 原文地址:https://www.cnblogs.com/LongHuaiYu/p/5626833.html
Copyright © 2011-2022 走看看