* This program shows how to detect the edges of a diamond
* with subpixel accuracy and calculate the angle between them.
*
* In contrast to the example measure_diamond.hdev,
* this example uses a metrology model to measure the edges.
*
* First, the top of the diamond is roughly segmented
* to align the metrology objects.
* Then, the metrology model is applied and returns the
* parameters of the fitted lines.
* Finally, the angle between the two lines is computed.
*
* Display initializations
dev_update_off ()
dev_close_window ()
read_image (Image, 'diamond/diamond_01')
dev_open_window_fit_image (Image, , , -, -, WindowHandle)
set_display_font (WindowHandle, , 'mono', 'true', 'false')
get_image_size (Image, Width, Height)
*
* Create the metrology model data structure
create_metrology_model (MetrologyHandle)
* The image size is set in advance to speed up the
* first call of apply_metrology_model.
set_metrology_model_image_size (MetrologyHandle, Width, Height)
* Define the parameters of the metrology line objects
LineRow1 := [,]
LineColumn1 := [,]
LineRow2 := [,]
LineColumn2 := [,]
Tolerance :=
*
* Create two metrology line objects and set parameters
add_metrology_object_line_measure (MetrologyHandle, LineRow1, LineColumn1, LineRow2, LineColumn2, Tolerance, , , , [], [], Index1)
* Create region of interest for the alignment
gen_rectangle1 (Rectangle, LineRow1[] - , LineColumn1[] - , LineRow1[] + , LineColumn1[] + )
* Change the reference coordinate system in which the
* metrology model is given to be situated at the top of the diamond
reduce_domain (Image, Rectangle, ImageReduced)
dev_display(Image)
dev_display(Rectangle)
stop()
threshold (ImageReduced, Region, , )
get_region_points (Region, Rows, Columns)
set_metrology_model_param (MetrologyHandle, 'reference_system', [Rows[],Columns[],])
*
* Main loop
*
for I := to by
read_image (Image, 'diamond/diamond_' + I$'')
* Roughly segment the diamond's position
reduce_domain (Image, Rectangle, ImageReduced)
threshold (ImageReduced, Region, , )
* Extract the top of the diamond
get_region_points (Region, Rows, Columns)
*
* Use the top of the diamond to align the metrology model in
* the current image
*
align_metrology_model (MetrologyHandle, Rows[], Columns[], )
*
*
* Perform the measurement for both lines in one call
*
apply_metrology_model (Image, MetrologyHandle)
*
* Access results
*
get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', LineParameter)
angle_ll (LineParameter[], LineParameter[], LineParameter[], LineParameter[], LineParameter[], LineParameter[], LineParameter[], LineParameter[], Angle)
Angle := deg(Angle)
*
* Display results
*
* Create line contours
get_metrology_object_result_contour (ResultContour, MetrologyHandle, 'all', 'all', 1.5)
intersection_lines (LineParameter[], LineParameter[], LineParameter[], LineParameter[], LineParameter[], LineParameter[], LineParameter[], LineParameter[], Row, Column, IsOverlapping1)
* Calculate the orientation of the two lines
line_orientation (LineParameter[], LineParameter[], LineParameter[], LineParameter[], Orientation1)
if (Orientation1 > )
Orientation1 := Orientation1 - rad()
endif
line_orientation (LineParameter[], LineParameter[], LineParameter[], LineParameter[], Orientation2)
*
* Visualize the angle between the lines
gen_circle_contour_xld (ContCircle, Row, Column, , Orientation1, Orientation2, 'positive', )
* Get the used measure regions and the measured points
* for visualization
get_metrology_object_measures (Contour, MetrologyHandle, 'all', 'all', MRow, MColumn)
gen_cross_contour_xld (Cross, MRow, MColumn, , rad())
* Display everything
dev_display (Image)
dev_set_line_width ()
dev_set_color ('yellow')
dev_display (Contour)
dev_display (Cross)
dev_set_line_width ()
dev_set_color ('green')
dev_display (ResultContour)
dev_set_color ('blue')
dev_display (ContCircle)
disp_message (WindowHandle, 'Angle = ' + Angle$'.5' + '°', 'window', , , 'black', 'true')
if (I < )
disp_continue_message (WindowHandle, 'black', 'true')
endif
stop ()
endfor
* Clean up memory
clear_metrology_model (MetrologyHandle)

Halcon 2D测量的更多相关文章

  1. Halcon一维测量官方案例解析

    下面的例子简要介绍了如何使用HALCON的一维测量工具.最长的部分是预处理和后处理:测量本身只包括两个操作符调用. 测量保险丝-fuse 预处理主要是测量线的生成.在示例程序中,这个步骤是通过将测量对 ...

  2. Halcon一维测量1D Measuring解析

    一维测量(也叫一维计量或卡尺)的概念非常直观.沿着一个预定的区域(主要是垂直于RIO感兴趣区域的方向) 边缘的位置.这里的边缘为从暗到亮或从亮到暗的过渡. 基于提取的边缘,可以测量零件的尺寸.例如,可 ...

  3. Halcon 1D测量

    1.产生测量句柄,准备提取与矩形(圆弧)主轴垂直的值边缘. gen_measure_rectangle2或gen_measure_arc 2.测量边缘对   ,测量的直线与矩形或者圆弧垂直 measu ...

  4. halcon 特征测量

    Features 1. line_orientation   功能:计算线的方位. 2. line_position   功能:计算一条线的重心.长度和方位. 3. partition_lines   ...

  5. halcon——缺陷检测常用方法总结(测量拟合)

    引言 机器视觉中缺陷检测分为一下几种: blob分析+特征 模板匹配(定位)+差分:halcon--缺陷检测常用方法总结(模板匹配(定位)+差分) - 唯有自己强大 - 博客园 (cnblogs.co ...

  6. 分析一则halcon抓边拟合直线的小案例

    例图: 完整算法: read_image (Image, 'C:/Users/Administrator/Desktop/1.png') threshold (Image, Regions, , ) ...

  7. 提取线条的lines_color、lines_facet、 lines_gauss算子

    Halcon中线条提取的算子主要有: lines_color(Image : Lines : Sigma, Low, High, ExtractWidth, CompleteJunctions : ) ...

  8. 1D mesauring

              The Basics of Measure Objects   2.1 the process of 1D Edge extraction       Then, the mean ...

  9. 《zw版·Halcon-delphi系列原创教程》 Halcon分类函数009,Measure,测量函数

    <zw版·Halcon-delphi系列原创教程> Halcon分类函数009,Measure,测量函数 为方便阅读,在不影响说明的前提下,笔者对函数进行了简化: :: 用符号“**”,替 ...

随机推荐

  1. Playmaker全面实践教程之playMaker编辑器

    Playmaker全面实践教程之playMaker编辑器 playMaker编辑器 playMaker编辑器是制作状态机的主要视图,如图1-23所示.只有熟悉此视图,读者才能更加快捷的使用Playma ...

  2. SQLserver 字符串转换日期,日期转换成为字符串

    sqlserver 日期与字符串之间的转换   该文章摘自:http://www.cnblogs.com/windphoenix/archive/2013/04/26/3044784.html 字符转 ...

  3. android monitor 汉化

    作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:313134555@qq.com E-mail: 313134555 @qq.com === == ============= = ...

  4. Python3正则表达式(1)

    正则表达式 作用:处理字符串.形式上检查格式 应用:文本编辑与处理.网页爬虫 特点:可以快速.准确地完成复杂的查找.替换 操作: step1:预定义模式 step2:采用预定义的模式匹配具有共同特征的 ...

  5. centos 7 安装 php 5.5 5.6 7.0

    查看当前安装的PHP包 [root@node1 ~]# yum list installed | grep php php56w.x86_64 -.w7 @webtatic php56w-cli.x8 ...

  6. unity3d 摄像机抖动效果 CameraShake

    unity3d 摄像机抖动效果 ,利用脚本直接控制:当然也可以选择使用dotween插件,但到不至于为了使用仅一个功能,就导入了一个插件: 脚本示例: using UnityEngine; using ...

  7. Codeforces Round #410 (Div. 2) 题解 【ABCD】

    A 题意:问你恰好修改一个字符,能不能使得字符串变成回文串 题解:显然直接for一遍,如果长度为偶数,那么不一样的必须是1个:如果长度为奇数,那么不一样的也可以是0个 #include<bits ...

  8. Filebeat 快速开始

    Filebeat可以做什么 条目 filebeat 编写语言 GO 是否支持多输出 支持 是否支持多输入 支持 是否支持修改日志内容 支持 是否会丢数据 不会 对多行文件的合并 支持 对多层目录的模糊 ...

  9. iOS:NSFileHandle和NSFileManger的使用

    一.介绍 利用NSFilehandle类提供的方法,允许更有效地使用文件. 一般而言,处理文件时都要经历以下三个步骤: 1.打开文件,并获取一个NSFileHandle对象,以便在后面的I/O操作中引 ...

  10. Morris图表使用小记

    挺好用的,碰到几个问题,有的是瞎试解决了的: 1.我想折线图能够响应单击事件,即点击某个节点后,就能加载进一步的信息,帮助没找到,参照另外一个地方的写法,居然支持事件 Morris.Line({ el ...