首页 > 其他 > 详细

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

时间:2014-03-26 10:20:46      阅读:550      评论:0      收藏:0      [点我收藏+]

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

  • This example program demonstrates the basic usage of a measure object.

  • Here, the task is to determine the width of and the distance between the

  • pins of a switch.

*本例程演示了如何使用测量工具测量开关的引脚宽度和间距

  • First, read in the image and initialize the program.

*******打开图像**********

readimage (Image, ‘binswitch/binswitch1‘)

getimagesize (Image, Width, Height)

devclosewindow ()

devopenwindowfitimage (Image, 0, 0, 640, 640, WindowHandle)

setdisplayfont (WindowHandle, 14, ‘mono‘, ‘true‘, ‘false‘)

dev_display (Image)

*显示图片如下

  • Define the rectangular ROI within which the edges will be detected

    • and create the measure.bubuko.com,布布扣

Row := 390

Column := 380

Phi := rad(-60)

Length1 := 60

Length2 := 10

Interpolation := ‘nearest_neighbor‘

*******生成测量矩形ROI************ genmeasurerectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, Interpolation, MeasureHandle)

*测量矩形位置尺寸如下: bubuko.com,布布扣

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

  • that enclose dark regions.

Sigma := 0.9

Threshold := 12

Transition := ‘negative‘

Select := ‘all‘

***********测量边缘对*********

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

  • Visualize the results

dev_display (Image)

devsetdraw (‘margin‘)

devsetcolor (‘black‘)

**显示测量矩形ROI***************

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

显示测量的边缘对的尺寸,length1要用ROI的宽度**********

pdispdimensions (RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond, IntraDistance, InterDistance, Phi, Length2, WindowHandle)

*结果如下: bubuko.com,布布扣

  • Free the memory that has been allocated for the measure. close_measure (MeasureHandle)

跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量,布布扣,bubuko.com

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

原文:http://www.cnblogs.com/chita/p/3620919.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!