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

摘要:
向我学习机器视觉-HALCON学习例程中文解释-IC引脚测量LeadMeasurement:测量对象应用示例,包括可视化操作员。首先,测量引线的长度,然后测量它们的宽度和彼此之间的电阻

跟我学机器视觉-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)

显示图像如下:************************
跟我学机器视觉HALCON学习例程中文详解IC引脚测量第1张

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)

测量位置如绿色矩形所示下:*
跟我学机器视觉HALCON学习例程中文详解IC引脚测量第2张

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')

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

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

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')

******将测量结果画出
跟我学机器视觉HALCON学习例程中文详解IC引脚测量第4张

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,如图蓝色矩形:
跟我学机器视觉HALCON学习例程中文详解IC引脚测量第5张

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'

*****进行测量计算并显示结果
跟我学机器视觉HALCON学习例程中文详解IC引脚测量第6张

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')

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

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

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

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

stop ()

  • Then, zoom the image and display the results.

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

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

dev_set_part (Row1, Column1, Row2, Column2)

dev_display (Image)

dev_set_color ('black')

画出测量矩形ROI和测得的边缘如图***
跟我学机器视觉HALCON学习例程中文详解IC引脚测量第9张

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引脚测量》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇针式PKM帮助三:知识点的新增、删除及文件关联和设置颜色使用Linux最常见的十大问题下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

WebRTC学习(三)WebRTC设备管理

一:WebRTC设备管理 (一)重要API,用于获取音视频设备 其中返回的ePromise结果,是一个Promise对象。 Promise对象的结构体:MediaDevicesInfo  deviceID:是设备唯一标识符ID label:是设备的名字(可读的) kind:设备的种类(音频输入/输出两种,视频输入/输出两类) groupID:同一个设备...

2020系统综合实践 第7次实践作业 11组

目录 1.在树莓派中安装opencv库 1.1 安装依赖 1.2 下载OpenCV源码 1.3 安装pip 1.4 安装Python虚拟机 1.5 编译OpenCV 1.6 安装OpenCV 2.使用opencv和python控制树莓派的摄像头 3.利用树莓派的摄像头实现人脸识别 facerec_on_raspberry_pi.py face...

TSQL取时间的年月日

经常保存在SQL Server的datetime格式的数据都是带有时、分、秒等的。但是在页面读取的时候,通知只需要年月日, 今天用到的读取时间年月日的方法如下: view plaincopy to clipboardprint? convert(varchar(12),时间列名,111)   如在数据表table1中的列 operdate是dat...

halcon案例学习之cbm_label_simple

*cbm_label_simple 程序说明:*这个示例程序展示了如何使用基于组件的匹配来定位复合对象。在这种情况下,应该在图像中找到一个标签,用户既不知道其中的组件,也不知道它们之间的关系。因此,创建组件模型需要三个操作符:* 1) gen_initial_components* 2) train_model_components* 3) create_...

QueryWrapper获取另一个表的字段

QueryWrapper<StFloodcollR> queryWrapper = new QueryWrapper<>(); queryWrapper.select("*,(SELECT u1.real_name FROM `user` u1 WHERE CREATEDBY = u1.id ) AS creat...

oracle-查询执行速度慢的sql

Oracle 查询每天执行慢的SQL 2014-12-11 18:00:04 分类: Oracle 链接:http://blog.itpub.net/28602568/viewspace-1364844/ 标题: Oracle 查询每天执行慢的SQL 作者:lōττéry©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责...