以直线卡尺为例,其他卡尺更改相应参数即可。

Code

直线卡尺

* 获取图像及图像尺寸
dev_close_window ()
read_image (Image, 'fabrik')
get_image_size (Image, Width, Height)
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
dev_set_line_width (1)
dev_display (Image)* 标记测量位置
draw_line (WindowHandle, Row1, Column1, Row2, Column2)
LineParams := [Row1, Column1, Row2, Column2]* 创建测量句柄
create_metrology_model (MetrologyHandle)
* 添加测量对象
set_metrology_model_image_size (MetrologyHandle, Width, Height)
add_metrology_object_generic (MetrologyHandle, 'line', LineParams, 20, 3, 1, 30, [], [], Index)* 设置测量对象的参数
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_transition', 'negative')
* set_metrology_object_param (MetrologyHandle, 'all', 'num_measures',10)
* set_metrology_object_param (MetrologyHandle, 'all', 'num_instances', 1)
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_sigma', 1)
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_length1', 20)
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_length2', 5)
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_threshold',30)
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_interpolation', 'bicubic')
* set_metrology_object_param (MetrologyHandle, 'all', 'measure_select', 'all')
* set_metrology_object_param (MetrologyHandle, 'all', 'min_score', 0.7)* 执行测量,获取边缘点集
dev_set_color ('yellow')
apply_metrology_model (Image, MetrologyHandle)
get_metrology_object_measures (Contours, MetrologyHandle, 'all', 'all', Row, Column)
dev_set_color ('red')
gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)* 获取最终测量数据和轮廓线
dev_set_color ('green')
dev_set_line_width (2)
get_metrology_object_result (MetrologyHandle, 'all', 'all', 'result_type', 'all_param', Parameter)
get_metrology_object_result_contour (Contour, MetrologyHandle, 'all', 'all', 1.5)* 释放测量句柄
clear_metrology_model (MetrologyHandle)

Result

Explanation

set_metrology_model_image_size( : : MetrologyHandle, Width, Height : )

使用 set_metrology_model_image_size 该算子设置测量区域,而且该算子必须在 add_metrology_object_generic 这类添加测量对象的算子之前调用,否则在使用 apply_metrology_model 执行测量时会重新计算测量区域,降低效率。

add_metrology_object_generic( : : MetrologyHandle, Shape, ShapeParam, MeasureLength1, MeasureLength2, MeasureSigma, MeasureThreshold, GenParamName, GenParamValue : Index)

参数 Shape 和 ShapeParam 是联动的:

  • Shape = circle 时,ShapeParam=[Row, Column, Radius]
  • Shape = rectangle2 时,ShapeParam=[Row, Column, Phi, Length1, Length2]
  • Shape = ellipse 时,ShapeParam=[Row, Column, Phi, Radius1, Radius2]
  • Shape = line 时,ShapeParam=[RowBegin, ColumnBegin, RowEnd, ColumnEnd]

set_metrology_object_param( : : MetrologyHandle, Index, GenParamName, GenParamValue : )

创建测量区域的相关参数

  • measure_length1:The value of this parameter specifies the half length of the measure regions perpendicular to the metrology object boundary.
  • measure_length2:The value of this parameter specifies the half length of the measure regions tangential to the metrology object boundary.
  • measure_distance:The value of this parameter specifies the desired distance between the centers of two measure regions.
  • num_measures:The value of this parameter specifies the desired number of measure regions.

提取边缘的相关参数

  • measure_sigma:The parameter specifies the sigma for the Gaussian smoothing.
  • measure_threshold:The parameter specifies the minimum edge amplitude.
  • measure_select:The parameter specifies the selection of end points of the edges.
  • measure_transition:The parameter specifies the use of dark/light or light/dark edges.
  • measure_interpolation:The parameter specifies the type of interpolation to be used.

拟合几何形状的相关参数

  • min_score: The parameter determines what score a potential instance must at least have to be regarded as a valid instance of the metrology object.
  • num_instances: The parameter specifies the maximum number of successfully fitted instances of each metrology object after which the fitting will stop.
  • distance_threshold: apply_metrology_model uses a randomized search algorithm (RANSAC) to fit the geometric shapes.
  • max_num_iterations: The RANSAC algorithm estimates the number of iterations necessary for fitting the requested geometric shape.
  • rand_seed: The parameter specifies the seed for the random number generator for the RANSAC algorithm that is used by the selection of the edges the in operator apply_metrology_model.
  • instances_outside_measure_regions: The parameter specifies the validation of the results of measurements.

转载于:https://www.cnblogs.com/zdfffg/p/11572249.html

Halcon - 定位 - 卡尺相关推荐

  1. halcon 定位_HALCON高级篇:单个相机的尺寸测量

    点击上方"新机器视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 转自:AI图像 用单个相机在指定平面上的尺寸测量 在HALCON中 ...

  2. Halcon学习笔记之测量系列-卡尺测量

    介绍完简单的一维测量之后,下面我们来介绍下常用的卡尺测量.Halcon中的Metrology方法即为卡尺工具,可用来拟合线,圆,这种方法对于目标比背景很明显的图像尺寸测量是很方便的,不需要用blob进 ...

  3. Halcon圆查找功能简介

    版权声明:本文为博主原创文章,未经博主允许不得转载. Halcon基于卡尺的圆查找功能主要会用到:create_metrology_model.add_metrology_object_circle_ ...

  4. Halcon 算子一 Halcon中Matching图形匹配

    Halcon中Matching图形匹配 图像 步骤 Halcon 算子 Halcon 进阶 一 C#实现Halcon中Matching图形匹配 图像 步骤 打开matching助手 选择从图像创建,模 ...

  5. Halcon例程详解(基于卡尺工具的匹配测量方法) —— measure_stamping_part.hdev

    前言 1卡尺工具介绍 Halcon中的Metrology方法即为卡尺工具,可用来拟合线,圆,这种方法对于目标比背景很明显的图像尺寸测量是很方便的,不需要用blob进行边缘提取等,但缺点也很明显,需要目 ...

  6. Halcon基于形状的几何定位函数说明

    Halcon基于形状的几何定位函数说明 1. create_shape_model(Template: : //reduce_domain后的模板图像 NumLevels,//金字塔的层数,可设为&q ...

  7. Halcon自定义直线卡尺rake

    拟合直线 rake工具 1. 为什么要开发rake工具 2. rake工具封装的三个函数 2.1 创建ROI的函数:draw_rake 2.2 边缘测量的函数:rake 2.3 拟合直线的函数:pts ...

  8. C#圆形卡尺测量程序基于halcon

    废话不多说上源码 觉得帖子有用给点个赞哈 先来个效果图 下边的是源码,自己新建一个文件粘贴进去,包含到您现在的项目 中.这串源码后边是使用方法. using System; using System. ...

  9. Halcon卡尺测量

    通过卡尺测量实现定位圆 素材图片[素材来源于iHalcon]: 处理效果如下: 代码: read_image (Image, 'C:/Users/Sawyer/Desktop/10_39545_034 ...

最新文章

  1. 关于年长程序员的5个误传
  2. 两个asp.net发送邮件类
  3. WIndows 下安装mysql (non-install版本,即绿色版,或称为 源码包)
  4. php辅助框架,【PHP开发框架】Laravel框架中辅助函数:optional ()函数的介绍
  5. 【今日CV 视觉论文速览】22 Nov 2018
  6. mysql禁止自动优化_MySQL必须调整的10项配置优化
  7. dubbo原理_dubbo的底层原理
  8. java09数组的使用
  9. 如果粒子运动只受力影响,那么意识从何而来
  10. AutoCAD各版本注册表参数
  11. 苹果手机连接Wifi认证机制
  12. Java编程思想第十章内部类的10.7至10.8小节的笔记和练习题
  13. python之dataframe写excel合并单元格_python之DataFrame实现excel合并单元格
  14. 网站优化策略有哪几种方法
  15. 华三防火墙透明模式典型组网配置实例
  16. 浅谈编程能力的培养与提高——写给编程初学者的话
  17. linux 6.5光驱是什么意思,linux 6和5有什么不同
  18. JAV spi 和扩展方式
  19. 手把手教你开发photoshop面板插件(附demo和工具)
  20. [导入]把域名转到了GoDaddy下

热门文章

  1. 【直播提醒】荷小鱼:K12 在线教育应用的开发实践
  2. Java经典面试题整理及答案详解(二)
  3. Springboot中艾特Controller和艾特RestController之间的区别
  4. The world at your fingertips — 天涯明月刀幕后(后记)
  5. 用unity制作简单的太空游戏(1):简单飞船控制
  6. 阿里云——ECS——Linux服务器购买流程——超级细致
  7. preg_filter用法
  8. Python小游戏(贪吃蛇)
  9. AIX 7.1 使用installp安装python的方法
  10. The requested URL /nagios/cgi-bin/statusmap.cgi was not found on this server