跟我学机器视觉-HALCON学习例程中文详解-IC引脚测量

  • Lead Measurement: Example for the application of the measure object

  • including a lot of visualization operators.

  • First, the length of the leads is measured, then, their width and distance from each other.

  • First, read in the image and initialize the program

read_image (Image, 'ic_pin')

*****************取得图像第一通道的指针,同时得到图像宽度高度*********

get_image_pointer1 (Image, Pointer, Type, Width, Height)

dev_close_window ()

dev_open_window_fit_image (Image, 0, 0, 509, 509, WindowHandle)

set_display_font (WindowHandle, 14, 'mono', 'true', 'false')

dev_display (Image)

****************显示图像如下:****************************************

dev_set_draw ('margin')

dev_set_line_width (3)

  • Define and display the rectangular ROIs within which the edges will be detected

Row := 55

RowBottom := 955

Column := 200

Phi := rad(-90)

Length1 := 50

Length2 := 35

dev_set_color ('gray')

gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)

gen_rectangle2 (Rectangle, RowBottom, Column, Phi, Length1, Length2)

*************************测量位置如绿色矩形所示下:**************************

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

stop ()

  • Create a measure object for the ROI at the top of the image.

******获取一阶灰度剖面图的插值方法,测量矩形框与图像坐标系之间有角度时生效******

Interpolation := 'nearest_neighbor'

****************************生成测量矩形框,先测上部****************************

gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, Interpolation, MeasureHandle)

  • Determine all edges and calculate the lead height at the top of the image

Sigma := 1.0

Threshold := 30

Transition := 'all'

Select := 'all'

**************************************进行测量********************************

measure_pos (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdge, ColumnEdge, Amplitude, Distance)

LeadLength1 := Distance

  • Display the results

dev_set_color ('white')

***********************************将测量结果画出*****************************

disp_line (WindowHandle, RowEdge, ColumnEdge-Length2, RowEdge, ColumnEdge+Length2)

disp_message (WindowHandle, 'Lead Length: '+LeadLength1$'.2f', 'window', RowEdge[1]+40, ColumnEdge[1]+100, 'yellow', 'false')

  • Shift the measure object and determine the lead height at the bottom of the image

************************转移测量框至新的参考坐标点,及测量下部******************

translate_measure (MeasureHandle, RowBottom, Column)

**************************************进行测量********************************

measure_pos (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdge, ColumnEdge, Amplitude, Distance)

LeadLength2 := Distance

  • Display the results

dev_set_color ('white')

***********************************将测量结果画出*****************************

disp_line (WindowHandle, RowEdge, ColumnEdge-Length2, RowEdge, ColumnEdge+Length2)

disp_message (WindowHandle, 'Lead Length: '+LeadLength2$'.2f', 'window', 360, ColumnEdge[1]+100, 'red', 'false')

  • Close the measure

close_measure (MeasureHandle)

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

stop ()

  • Now, define and display a rectangular ROI perpendicular to the leads and create the measure

dev_display (Image)

Row := 47

Column := 485

Phi := 0

Length1 := 420

Length2 := 8

Interpolation := 'nearest_neighbor'

dev_set_color ('black')

*******************创建新的测量矩形ROI,如图蓝色矩形:*******************

gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)

gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, Interpolation, MeasureHandle)

  • Determine all edge pairs that have a negative transition, i.e., edge pairs

  • that enclose dark regions.

Sigma := 1.0

Threshold := 30

Transition := 'negative'

Select := 'all'

******************************进行测量计算并显示结果*************************

measure_pairs (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)

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

stop ()

dev_set_color ('white')

disp_line (WindowHandle, RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond)

avgLeadWidth := sum(IntraDistance)/|IntraDistance|

avgLeadDistance := sum(InterDistance)/|InterDistance|

numLeads := |IntraDistance|

disp_message (WindowHandle, 'Number of Leads: '+numLeads, 'window', 200, 100, 'yellow', 'false')

disp_message (WindowHandle, 'Average Lead Width: '+avgLeadWidth$'.2f', 'window', 260, 100, 'yellow', 'false')

disp_message (WindowHandle, 'Average Lead Distance: '+avgLeadDistance$'.2f', 'window', 320, 100, 'yellow', 'false')

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

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

stop ()

  • Zoom in to visualize the measurement results in more detail.

  • First, define and display the zoom window.

Row1 := 0

Column1 := 600

Row2 := 100

Column2 := 700

dev_set_color ('blue')

**************************设置放大区域矩形并显示,图中绿色矩形*****************

disp_rectangle1 (WindowHandle, Row1, Column1, Row2, Column2)

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

stop ()

  • Then, zoom the image and display the results.

*********************设置图像放大区域并显示**********************************

dev_set_part (Row1, Column1, Row2, Column2)

dev_display (Image)

dev_set_color ('black')

**********************画出测量矩形ROI和测得的边缘如图*************************

dev_display (Rectangle)

p_disp_edge_marker (RowEdgeFirst, ColumnEdgeFirst, Phi, 5, 'white', 3, WindowHandle)

p_disp_edge_marker (RowEdgeSecond, ColumnEdgeSecond, Phi, 5, 'white', 3, WindowHandle)

  • Close the measure

close_measure (MeasureHandle)

  • Reset the display parameters.

dev_set_part (0, 0, Height-1, Width-1)

dev_set_draw ('fill')

dev_set_line_width(1)

跟我学机器视觉-HALCON学习例程中文详解-IC引脚测量的更多相关文章

  1. 跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量

    跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量 This example program demonstrates the basic usage of a measure object. ...

  2. 跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量

    跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量 * This example program demonstrates the basic usage of a fuzz ...

  3. 跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距

    跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距 This example program demonstrates the basic usage of a circular meas ...

  4. 跟我学机器视觉-HALCON学习例程中文详解-QQ摄像头读取条码

    跟我学机器视觉-HALCON学习例程中文详解-QQ摄像头读取条码 第一步:插入QQ摄像头,安装好驱动(有的可能免驱动) 第二步:打开HDevelop,点击助手-打开新的Image Acquisitio ...

  5. 《TensorFlow学习指南深度学习系统构建详解》英文PDF+源代码+部分中文PDF

    主要介绍如何使用 TensorFlow 框架进行深度学习系统的构建.涉及卷积神经网络.循环神经网络等核心的技术,并介绍了用于图像数据和文本序列数据的模型.给出了分布式深度学习系统在TensorFlow ...

  6. Nginx配置文件nginx.conf中文详解(转)

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

  7. Nginx中文详解、配置部署及高并发优化

      一.Nginx常用命令: 1. 启动 Nginx          /usr/local/nginx/sbin/nginxpoechant@ubuntu:sudo ./sbin/nginx2. 停 ...

  8. iOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem

    http://blog.csdn.net/totogo2010/article/details/7681879 1.UINavigationController导航控制器如何使用 UINavigati ...

  9. [转]iOS学习之UINavigationController详解与使用(三)ToolBar

    转载地址:http://blog.csdn.net/totogo2010/article/details/7682641 iOS学习之UINavigationController详解与使用(二)页面切 ...

随机推荐

  1. javascript调用外部wpf的方法

    今天因为项目需要在wpf嵌入web页面,然后在web页面调用wpf的方法,于是突击学习了一下,记下备忘.^_^ 1.wpf中新建一个类WpfForScriptingHelper namespace w ...

  2. about Q&A in installing linux[centos6,7]

    keywords:grub1,grub2,gnome,kde, question describe:install centos7 by U disk,出现问题, 解决办法: install cent ...

  3. Java 中正确使用 hashCode 和 equals 方法

    在这篇文章中,我将告诉大家我对hashCode和equals方法的理解.我将讨论他们的默认实现,以及如何正确的重写他们.我也将使用Apache Commons提供的工具包做一个实现. 目录: hash ...

  4. 3224: Tyvj 1728 普通平衡树

    Description 您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作: 1. 插入x数 2. 删除x数(若有多个相同的数,因只删除一个) 3. 查询x数的排名(若有多个相 ...

  5. Pair Project: Elevator Scheduler [电梯调度算法的实现和测试][关于电梯调度算法的附加思考]:刘耀先-11061183,罗凡-11061174

    本文为对于电梯调度算法的三个附加题思考 1.改进电梯调度的interface 设计, 让它更好地反映现实, 更能让学生练习算法, 更好地实现信息隐藏和信息共享. <1>进一步提高API定义 ...

  6. VS Extension: Create a txt file and set the content

    使用 Visual Studio Extension 创建一个文本文件,并填入内容. 需要引用 EnvDTE C:\Program Files (x86)\Microsoft Visual Studi ...

  7. mysql数据库乱码

    问题:mysql数据库的编码都设置为utf8的情况下,用jdbc往数据库中插入数据时仍然乱码, 解决方法:在jdbc的中加上参数characterEncoding=utf8&useUnicod ...

  8. sql 锁相关(转)

    锁是数据库中的一个非常重要的概念,它主要用于多用户环境下保证数据库完整性和一致性. 我们知道,多个用户能够同时操纵同一个数据库中的数据,会发生数据不一致现象.即如果没有锁定且多个用户同时访问一个数据库 ...

  9. 用JavaScript探测页面上的广告是否被AdBlock屏蔽了的方法

    每个人都讨厌广告.看电视.看电影.看优酷.看网页时,对满天飞的广告也是深恶痛绝.广告是一个不招人喜欢的东西.但是,对一个中小网站站长/博客主来说,广告几乎是唯一的能成支持网站/博客正常运转的资金来源. ...

  10. Oracle常用查看表结构命令

    获取表: select table_name from user_tables; //当前用户的表 select table_name from all_tables; //所有用户的表 select ...