跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量
* 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)
p_reopen_window_fit (0, 0, Width, Height, 640, WindowHandle)
p_set_font (WindowHandle)
dev_display (Image)
************************显示图像如下:注意中间引脚反光**********************
                       
* Define the rectangular ROI within which the edges will be detected
* and create the measure.
Row := 290
Column := 170
Phi := rad(-130)
Length1 := 60
Length2 := 10
Interpolation := 'nearest_neighbor'
*************************生成测量矩形ROI,注意角度为-130度*********************
 
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 := 0.9
Threshold := 10
Transition := 'all'
 
 
Select := 'all'
**************进行测量,并显示检测结果,可以看出,中间的引脚检测结果不正确****
measure_pairs (Image, MeasureHandle, Sigma, Threshold, Transition, Select, RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
*
* 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)
*
***************************放大后图像如下**************************************
 
*******************************检测框角度为-130时,Threshold怎么变都不行,*******************************Transition改为*****negative_strongest也不行*******
*****************Any question,  Contact Q:        1613985351*******************
************************解决方法一:检测角度为50度时,检测结果正常**********
********解决方法二:使用FUZZY检测,已知引脚宽度为9个像素左右****************
stop ()
* 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.
 
*************************创建SIZE范围函数**********************************
create_funct_1d_pairs ([7,9,11], [0.0,1.0,0.0], 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)
*
************设为Fuzzy检测时,中间引脚找到第一条边时,再找另一条边,宽度必须在8-10之间,因此中间那条边界被忽略,刚好找的正确边缘,否则找不到****************
* Finally, determine all edge pairs that have a negative transition and approximately the given size.
Sigma := 0.9
AmpThresh := 12
FuzzyThresh := 0.5
Transition := 'negative'
Select := 'all'
******************************fuzzy检测,使用创建的测量句柄*******************
fuzzy_measure_pairs (Image, MeasureHandle, Sigma, AmpThresh, FuzzyThresh, Transition, RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, RowEdgeCenter, ColumnEdgeCenter, 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)
*
* Free the memory that has been allocated for the measure.
close_measure (MeasureHandle)              
作者:☆Chita☆ 出处:http://www.cnblogs.com/chita/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

HALCON-FUZZY检测用于开关引脚测量的更多相关文章

  1. 跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量

    跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量 * This example program demonstrates the basic usage of a fuzz ...

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

    跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量 This example program demonstrates the basic usage of a measure object. ...

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

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

  4. halcon——缺陷检测常用方法总结(特征训练)

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

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

    跟我学机器视觉-HALCON学习例程中文详解-IC引脚测量 Lead Measurement: Example for the application of the measure object in ...

  6. halcon——缺陷检测常用方法总结(光度立体)

    引言 机器视觉中缺陷检测分为一下几种: blob+特征(官方示例surface_scratch.hdev) blob+差分+特征(官方示例pcb_inspection.hdev) 光度立体 特征训练 ...

  7. halcon——缺陷检测常用方法总结(模板匹配(定位)+差分)

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

  8. 跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距

    跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距 This example program demonstrates the basic usage of a circular meas ...

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

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

随机推荐

  1. c++ primer 5th 练习3.43

    #include <iostream> using namespace std; int main() { ][]={,,,,,,,,,,,}; /* for(int (&i)[4 ...

  2. Android IOS WebRTC 音视频开发总结(七三)-- 我为什么走上了创业这条不归路?

    本文主要介绍自己为什么选择创业,文章最早发表在我们的微信公众号上,支持原创,详见这里, 欢迎关注微信公众号blackerteam,更多详见www.rtc.help 2016.06.01对公司来说是个很 ...

  3. 百度Ueditor

    最近用到了百度Ueditor,也来写一写百度Ueditor的使用教程: 一.从官网下载百度Ueditor,http://ueditor.baidu.com/website/download.html, ...

  4. 'telnet' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

    在telnet与ftp服务器相连时出现的问题: 原因:windows自带telnet,只是没有安装 解决如下: 然后关机重启

  5. (http://fonts.googleapis.com/css?)打开很慢解决方案

    把fonts.googleapis.com替换为fonts.useso.com即可

  6. php文章内容分页并生成相应的htm静态页面代码

    代码如下: <?php $url='test.php?1=1'; $contents="fjka;fjsa;#page#批量生成分成文件并且加上分页代码"; $ptext = ...

  7. Web API - window - 获取滑动位置

    这两个属性都可以获取当前页面的滑动高度 虽然取到了同样的数据,但是我相信底层还是有区别的 不然不会用浪费api吧!

  8. windows10-桌面图标不见了,资源管理器的桌面中可以看到??

    问题描述: 1. 桌面的图标,在桌面上看不到, 但是在通过资源管理器可以看到, 图标仍然在桌面 2. 桌面仍然可以右击, 就是看不见新建或者拷贝到桌面的所有图标 解决方案: Google 后请参考: ...

  9. springMVC + Spring + MyBatis 整合

    整理下SSM(基于注解)的整合 1. web.xml 配置文件 <?xml version="1.0" encoding="UTF-8"?> < ...

  10. UNIX环境高级编程--10. 信号

    第十章        信号    信号是软中断,提供了一种处理异步事件的方法.例如,终端用户键入终端键,会通过信号机制停止一个进程,或及早终止管道中的下一个程序.    每个信号都有一个名字,SIG开 ...