• halcon入门学习-ball.hdev


    近期学习机器视觉语言,进行简短备注以便自己理解内容

    dev_update_window ('off')
    dev_close_window ()
    dev_open_window (0, 0, 728, 512, 'black', WindowID)
    read_image (Bond, 'die/die_03')
    dev_display (Bond)
    set_display_font (WindowID, 14, 'mono', 'true', 'false')
    disp_continue_message (WindowID, 'black', 'true')
    stop ()
    显示图像

    threshold (Bond, Bright, 100, 255)
    shape_trans (Bright, Die, 'rectangle2')
    dev_set_color ('green')
    dev_set_line_width (3)
    dev_set_draw ('margin')
    dev_display (Die)
    disp_continue_message (WindowID, 'black', 'true')
    stop ()
    显示绿色矩形   rectangle2矩形

    stop停止执行,相当于断点,在HDevelop中按F5执行到此条停止,需要再此按F5程序继续执行
    reduce_domain (Bond, Die, DieGrey)
    threshold (DieGrey, Wires, 0, 50)
    fill_up_shape (Wires, WiresFilled, 'area', 1, 100)
    dev_display (Bond)
    dev_set_draw ('fill')
    dev_set_color ('red')
    dev_display (WiresFilled)
    disp_continue_message (WindowID, 'black', 'true')
    stop ()
    显示红色区域

    opening_circle (WiresFilled, Balls, 15.5)
    dev_set_color ('green')
    dev_display (Balls)
    disp_continue_message (WindowID, 'black', 'true')
    stop ()
    显示圆圈绿色部分区域

    connection (Balls, SingleBalls)
    select_shape (SingleBalls, IntermediateBalls, 'circularity', 'and', 0.85, 1.0)
    sort_region (IntermediateBalls, FinalBalls, 'first_point', 'true', 'column')
    dev_display (Bond)
    dev_set_colored (12)
    dev_display (FinalBalls)
    disp_continue_message (WindowID, 'black', 'true')
    stop ()
    显示不同颜色圆圈


    smallest_circle (FinalBalls, Row, Column, Radius)
    NumBalls := |Radius|
    Diameter := 2 * Radius
    meanDiameter := sum(Diameter) / NumBalls
    mimDiameter := min(Diameter)
    dev_display (Bond)
    disp_circle (WindowID, Row, Column, Radius)
    dev_set_color ('white')
    for i := 1 to NumBalls by 1
        if (fmod(i,2) == 1)
            disp_message (WindowID, 'D: ' + Diameter[i - 1], 'image', Row[i - 1] - 2.7 * Radius[i - 1], max([Column[i - 1] - 60,0]), 'white', 'false')
        else
            disp_message (WindowID, 'D: ' + Diameter[i - 1], 'image', Row[i - 1] + 1.2 * Radius[i - 1], max([Column[i - 1] - 60,0]), 'white', 'false')
        endif
    endfor
    * dump_window (WindowID, 'tiff_rgb', './ball')
    dev_set_color ('green')
    dev_update_window ('on')
    disp_continue_message (WindowID, 'black', 'true')
    stop ()
    dev_close_window ()
    显示不同直径

  • 相关阅读:
    什么品牌的蓝牙耳机音质最好?音质好的蓝牙耳机推荐
    Android kotlin系列讲解(进阶篇)解析XML格式数据
    蓝桥杯 map
    Spring Data JPA与Mybatis的对比
    提升效率必备:电脑文件批量重命名的实用技巧大放送
    【Flink实战】玩转Flink里面核心的Source Operator实战
    Python 最有用的25个代码段
    怎么从零开始搭建配置Windows云服务器的新手入门教程
    阿里巴巴任庚:数字城市建设的“两核三转和四横五纵”
    Python基础入门篇【31】--面向对象:类中的私有函数与私有变量
  • 原文地址:https://blog.csdn.net/qq_30807313/article/details/127647484