* 此例程来自halcon自带例程,请打开 halcon-》ctrl+E 打开例程-》搜索框中输入ball added by xiejl
* ball.hdev: Inspection of Ball Bonding
*
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, , 'mono', 'true', 'false')
disp_continue_message (WindowID, 'black', 'true')
stop ()
threshold (Bond, Bright, , )
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 ()
reduce_domain (Bond, Die, DieGrey)
threshold (DieGrey, Wires, , )
fill_up_shape (Wires, WiresFilled, 'area', , )
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 := *Radius
meanDiameter := sum(Diameter)/NumBalls
mimDiameter := min(Diameter)
dev_display (Bond)
disp_circle (WindowID, Row, Column, Radius)
dev_set_color ('white')
for i := to NumBalls by
if (fmod(i,)=)
disp_message (WindowID, 'D: '+Diameter[i-], 'image', Row[i-]-2.7*Radius[i-], max([Column[i-]-,]), 'white', 'false')
else
disp_message (WindowID, 'D: '+Diameter[i-], 'image', Row[i-]+1.2*Radius[i-], max([Column[i-]-,]), '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 ()

  可以看到 图像的处理就是红色之外的代码,没有几句。

  先来看看红色部分的代码:

  dev_update_window:帮助文档上是这么说的---此算子决定 所有由其他某一个算子返回的所有图形对象是否显示在活动的图形窗口之上(‘on'为默认参数,代表打开此更新,'off'表示关闭此更新,所有更新由我们手动打开)。参数的选择对于我们输出对象在某一单步执行时是没有影响的,执行之后,图形输出对象依然可以显示在活动的图形窗口之上。参数选择应该被置为'off',只有在我们选择的图形对象应该被显示在图形窗口之上时,我们应该手动调用算子:dev_display算子显示此对象(包括 image, xld, region等其他图形对象)。理解了吗?呵呵

  dev_close_window:这是halcon中比较简单的内部函数,就是将图形显示窗口关闭。当然我们可以通过HDevelop的菜单栏-》窗口-》打开图形窗口,打开多个图形窗口。

  dev_open_window:这没什么好说的,就是将上面关闭的图形窗口重新打开。

  dev_display:如果我们通过调用dev_update_window(’off')语句,关闭窗口的更新,我们必须手动调用dev_display()内部操作来显示对象(比如imag,region,xld等其他图形对象)。

  stop: 这是应该是halcon中最简单的语句了,相当于C中的system("pause"),让程序暂停执行,此时我们可以通过观察变量窗口(显示图形变量及控制变量),调试程序等。

  dev_set_color: 在讲这句的意义之前,我们可以通过HDevelop的菜单栏-》可视化-》颜色  来达到与此句相同的效果,这可能会帮助你理解dev_set_color的意义,其实就是设置图形显示窗口中图形(image,region,xld等)的图像显示颜色。此内部操作和下面讲到的dev_set_colored相辅相成。调试非常有用。

  dev_set_colored:和上面一样,我们可以通过HDevelop的菜单栏-》可视化-》彩色数量  来达到与此句相同的效果。在我们调试程序时,通过connection算子处理后,求取region的连通域,将region分成各不同的region块,即可以通过此功能完成对各region着不同的颜色,方便我们调试、观察。

  dev_set_line_width:和上面一样,可以通过HDevelop的菜单栏-》可视化-》线宽来设置线条的宽度,调试用,比如观察xld时。

  dev_continue_message:在图形窗口上显示继续信息

  Halcon的内部操作暂时讲这么多。至于算子和外部函数稍的再讲 by xiejl

 

最新文章

  1. [LeetCode] Reverse Nodes in k-Group 每k个一组翻转链表
  2. 5-26课堂作业——组员投票Alpha版存在的问题
  3. 转载--linux filesystem structures
  4. makefile变量赋值
  5. A Horrible Poem(bzoj 2795)
  6. p4 是否能自动merge
  7. JavaScript for...in 语句
  8. [CSS][转载]内层div的margin-top影响外层div
  9. 配置mybatis错误总结
  10. 最简单的CRC32源码-查表法
  11. GitHub超详细图文攻略 - Git客户端下载安装 GitHub提交修改源码工作流程 Git分支 标签 过滤 Git版本工作流
  12. Highlight On Mouseover Effect With JQuery
  13. 各位Coder看过来
  14. 简译《Dissecting SQL Server Execution Plans》——连载总入口
  15. 测者的性能测试手册:快速安装LoadRunner Linux上的Generator
  16. Lucky 7 (容斥原理 + 中国剩余定理)
  17. python(30)——【random模块】【if __name__ =='__main__'】【os模块】
  18. 按值传递 vs. 按指针传递
  19. 查看图片插件--Viewer(类似于qq和微信聊天 的查看图片)
  20. 大数据工具篇之flume1.4-安装部署指南

热门文章

  1. redis相关操作命令
  2. 6年DotNet码农的盲目经历
  3. [转载]Oracle中动态SQL详解
  4. poj1584(判断凸包+求点到线段的距离)
  5. Redis服务监控之RedisLive安装部署(亲测可用)
  6. 学习Python类的心得
  7. 笔记-7:mysql视图
  8. S03_CH12_基于UDP的QSPI Flash bin文件网络烧写
  9. 工具——eclipse debug小技巧
  10. win10系统ping另一台电脑上虚拟机的IP