halcon例程 -- 逐字细究(二)

* This example program demonstrates the basic usage of a fuzzy 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.
read_image (Image, 'bin_switch/bin_switch_2')
*读入图像
get_image_size (Image, Width, Height)
*获取图像信息:返回宽度,和高度
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
*创建大小适合的窗体
dev_resize_window_fit_size (0, 0, Width, Height, -1, 640)
**按指定图像的尺寸来打开一个窗口
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
**设置显示的字体
dev_display (Image)
**显示图像

* Define the rectangular ROI within which the edges will be detected
* and create the measure.


Row := 290 
*输入矩形中心点的y值坐标
Column := 170
*输入矩形中心点的x值坐标
Phi := rad(-130)
*输入矩形长轴针对水平方向的角度
Length1 := 60
*输入矩形长轴半径
Length2 := 10
*输入矩形短轴半径(Length2<=Length1)
Interpolation := 'nearest_neighbor'
*提取边沿的最近点作为参考像素
gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, Interpolation, MeasureHandle)
**提取与矩形垂直中心轴线的直线边缘,设定ROI,返回输出MeasureHandle,即输出被测量尺寸物体对应的句柄

* Determine all edge pairs that have a negative transition, i.e., edge pairs
* that enclose dark regions.


Sigma := 0.9
*高斯滤波系数,范围:0.4 <= sigma <= 100
Threshold := 12
*灰度阈值,范围:1 <= Threshold <= 255
Transition := 'negative'
*选择检测过渡边沿的灰度值方式,其中negative是从白到黑
Select := 'all'
*返回所有边缘对,其中all是全部返回
measure_pairs (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
**提取与矩形或环状弧垂直的直线边缘。
*Image 输入图像
*MeasureHandle 输入测量句柄
*RowEdgeFirst 输出匹配边沿起点的y值坐标
*ColumnEdgeFirst 输出匹配边沿起点的x值坐标
*AmplitudeFirst 输出匹配边沿起点的幅值
*RowEdgeSecond 输出匹配边沿终点的y值坐标
*ColumnEdgeSecond 输出匹配边沿终点的x值坐标
*AmplitudeSecond 输出匹配边沿终点的幅值
*IntraDistance  输出匹配起点和终点的距离
*InterDistance  输出匹配终点到下一匹配起点之间的距离 
* Visualize the results


dev_display (Image)
*显示图像
dev_set_draw ('margin')
*设置一个区域的有效填充
*DrawMode:有效的填充类型,fill,即填满;margin,即只显示边沿,可能会受设置线宽和类型的影响
dev_set_color ('black')
*设置一个颜色用在某个显示区域,图形或XLD,该颜色也可以用于今后打开的图形窗口,它的有效时间为直到下次该函数定义的其他有效颜色
*ColorName 有效的颜色名称,默认为‘white’
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
*创建任意矩形区域
*Rectangle 输出矩形区域
*Row 输入矩形中心点的y值坐标
*Column 输入矩形中心点的x值坐标
*Phi 输入矩形长轴针对水平方向的角度 ,限制在(-PI/2)< Phi && Phi <= (PI/2)范围
*Length1 输入矩形长轴半径
*Length2 输入矩形短轴半径(Length2<=Length1)
p_disp_dimensions (RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond, IntraDistance, InterDistance, Phi, Length2, WindowHandle)
* 显示所测量的相临边缘对之间的距离尺寸
disp_message (WindowHandle, 'Standard measure results', 'window', 12, 12, 'black', 'true')
* 在此程序写入一个文本消息,内容为'Standard measure results'
disp_continue_message (WindowHandle, 'black', 'true')
*此过程显示Press Run (F5) to continue 在右下角,作为提示信息
stop ()
*程序停止运行,按F5可以继续往下运行
* Due to the reflections on the middle pin, its width cannot be determined correctly.

* As we know that the pins appear approximately 9 pixels wide, it is very easy to expand the measure to a
* fuzzy measure that will only return pairs that have a width of approximately the given size.

* First, create a fuzzy function that returns 1.0 for the given pair size and 0.0 for values that
* deviate more than 2 pixels from the given pair size.
create_funct_1d_pairs ([7,9,11], [0.0,1.0,0.0], SizeFunction)
*从(X,Y)的集合中创建一个函数
*XValues 创建该函数对应的x值
*YValues 创建该函数对应的y值
*SizeFunction 输出该函数

* Then, expand the measure to a fuzzy measure that will return only pairs of approximately the given size.
SetType := 'size'
set_fuzzy_measure (MeasureHandle, SetType, SizeFunction)
* 指定一个模糊元函数
*MeasureHandle 输入测量尺寸句柄
*SetType 设置模糊的类型
*SizeFunction 输入模糊成员函数


* Finally, determine all edge pairs that have a negative transition and approximately the given size.
Sigma := 0.9
*高斯滤波系数,范围:0.4 <= sigma <= 100
AmpThresh := 12
*最小的边沿灰度调整,范围:1 <= AmpThresh <= 255
FuzzyThresh := 0.5
*最小的模糊测量配对值 范围: 0.0 <= FuzzyThresh <= 1.0
Transition := 'negative'
*选择检测过渡边沿的灰度值方式,其中negative是从白到黑
Select := 'all'
*返回所有边缘对,其中all是全部返回
fuzzy_measure_pairs (Image, MeasureHandle, Sigma, AmpThresh, FuzzyThresh, Transition, RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, RowEdgeCenter, ColumnEdgeCenter, FuzzyScore, IntraDistance, InterDistance)
* 模糊测量配对,提取与矩形或环状弧垂直的直线边缘的起点、终点、中间点的坐标值,并提供起点和终点两点之间的间距,终点至下一配对起点的间距
*Image 输入图像
*MeasureHandle 输入测量句柄
*RowEdgeFirst 输出匹配边沿起点的y值坐标
*ColumnEdgeFirst 输出匹配边沿起点的x值坐标
*AmplitudeFirst 输出匹配边沿起点的幅值
*RowEdgeSecond 输出匹配边沿终点的y值坐标
*ColumnEdgeSecond 输出匹配边沿终点的x值坐标
*AmplitudeSecond 输出匹配边沿终点的幅值
*RowEdgeCenter 输出匹配边沿中点的y值坐标
*ColumnEdgeCenter 输出匹配边沿中点的x值坐标
*FuzzyScore 输出匹配边沿的模糊评估值
*IntraDistance  输出匹配起点和终点的距离
*InterDistance  输出匹配终点到下一匹配起点之间的距离 
* And again, visualize the results
dev_display (Image)
dev_set_draw ('margin')
dev_set_color ('black')
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
p_disp_dimensions (RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond, IntraDistance, InterDistance, Phi, Length2, WindowHandle)
disp_message (WindowHandle, 'Fuzzy measure results', 'window', 12, 12, 'black', 'true')

* Free the memory that has been allocated for the measure.
close_measure (MeasureHandle)
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Halcon 10.0 是一款强大的机器视觉开发软件,支持在Windows系统上运行。halcon10.0-windows.exe 是Halcon 10.0 软件的可执行文件,用于在Windows系统上安装和运行该软件。 通过运行 halcon10.0-windows.exe 文件,用户可以开始安装Halcon 10.0 软件。安装过程中,用户需要按照提供的安装向导进行操作,包括选择安装路径、设置组件和功能、以及输入必要的许可证信息等。完成安装后,用户可以在自己的计算机上打开Halcon 10.0 软件。 Halcon 10.0 软件提供了丰富的功能和工具,用于开发和实现机器视觉应用。它支持图像处理、图像分析、模式匹配、三维视觉、相机校准等多项功能。用户可以通过Halcon 10.0 软件进行图像的预处理、特征提取、目标识别和测量等操作,从而实现各种视觉检测和测量任务。 除了功能强大的视觉算法和工具,Halcon 10.0 软件还提供了友好的用户界面和丰富的编程接口,使得用户可以根据自己的需求进行定制化开发和编程。用户可以通过编写脚本或使用常见的编程语言如C++、C#等来编写自己的机器视觉应用程序。 总而言之,halcon10.0-windows.exe 是Halcon 10.0 软件的安装文件,通过安装和运行该软件,用户可以方便地进行机器视觉应用的开发和实现。 ### 回答2: Halcon 10.0-windows.exe是一种软件程序,它是由MVTec Software GmbH开发的一款专业机器视觉软件。Halcon被广泛应用于各种工业领域,如制造业、物流、医疗等,用于图像处理、检测、识别和测量等方面的任务。 Halcon 10.0-windows.exe是Halcon 10.0版本的Windows操作系统的可执行文件。这意味着它可以在Windows操作系统上运行,并且可以直接从该可执行文件启动Halcon 10.0软件。 Halcon 10.0是Halcon软件最新的一个重要版本,它引入了许多新功能和改进,以提供更好的机器视觉解决方案。该版本具有更高的性能、更强大的图像处理能力和更便捷的用户界面。用户可以使用Halcon 10.0进行图像分析、模式识别、目标检测、形状测量等任务。此外,Halcon 10.0还支持多种编程语言和平台,并提供了丰富的开发工具和函数库,以便用户根据自己的需求进行定制和扩展。 对于使用Halcon进行机器视觉应用的用户来说,Halcon 10.0-windows.exe是一个非常重要的文件,它提供了启动Halcon 10.0软件的能力。用户只需双击该文件,就可以快速启动Halcon 10.0,并开始使用其功能进行图像处理和分析。对于那些希望在Windows操作系统上进行机器视觉开发和应用的用户来说,Halcon 10.0-windows.exe无疑是一个不可或缺的工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值