跟我学机器视觉-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)              

跟我学机器视觉-HALCON学习例程中文详解-FUZZY检测用于开关引脚测量的更多相关文章

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

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

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

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

  3. 跟我学机器视觉-HALCON学习例程中文详解-QQ摄像头读取条码

    跟我学机器视觉-HALCON学习例程中文详解-QQ摄像头读取条码 第一步:插入QQ摄像头,安装好驱动(有的可能免驱动) 第二步:打开HDevelop,点击助手-打开新的Image Acquisitio ...

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

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

  5. 《TensorFlow学习指南深度学习系统构建详解》英文PDF+源代码+部分中文PDF

    主要介绍如何使用 TensorFlow 框架进行深度学习系统的构建.涉及卷积神经网络.循环神经网络等核心的技术,并介绍了用于图像数据和文本序列数据的模型.给出了分布式深度学习系统在TensorFlow ...

  6. Nginx配置文件nginx.conf中文详解(转)

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

  7. Nginx中文详解、配置部署及高并发优化

      一.Nginx常用命令: 1. 启动 Nginx          /usr/local/nginx/sbin/nginxpoechant@ubuntu:sudo ./sbin/nginx2. 停 ...

  8. iOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem

    http://blog.csdn.net/totogo2010/article/details/7681879 1.UINavigationController导航控制器如何使用 UINavigati ...

  9. [转]iOS学习之UINavigationController详解与使用(三)ToolBar

    转载地址:http://blog.csdn.net/totogo2010/article/details/7682641 iOS学习之UINavigationController详解与使用(二)页面切 ...

随机推荐

  1. 从一次面试经历谈PHP的普通传值与引用传值以及unset

    关于这个概念一般都会在PHP的第一堂课说变量的时候给介绍,并且我以前还给其他PHPer介绍这个概念.但是作为一个工作一段时间的PHPer的我,竟然在面试的时候一下子拿不定主意最后还答错了,很觉得丢脸( ...

  2. Linux使用者管理(2)---账号管理

    用户添加 新增用户 sudo useradd -m username 这里必须使用sudo 因为需要对/etc/shadow进行读写,在ubuntu环境下,必须使用-m设置,否则不会创建主文件夹. 在 ...

  3. Invoke与BeginInvoke

    一.为什么 Control类提供了 Invoke和 BeginInvoke机制? 关于这个问题的最主要的原因已经是 dotnet程序员众所周知的,我在此费点笔墨再次记录到自己的日志,以便日后提醒一下自 ...

  4. 值得珍藏的.NET源码,不保存就没机会了

    很早以前,我们通过http://referencesource.microsoft.com/netframework.aspx可以下载到.NET的各版本公开源码,但如今,微软对sscli项目进行了改版 ...

  5. openCv 图像顺时针、逆时针旋转

    通过下面这个函数调用 Rotate90(workImg,270); //顺时针旋转 Rotate90(workImg,90); //逆时针旋转 实现,其实用该函数旋转任意度数对正方形图都ok,只是长方 ...

  6. kail新手安装

    Kali Linux下载链接:http://mirrors.ustc.edu.cn/kali-images/kali-2.0/ (ps:建议用国内镜像源下载,速度有保证) Kali Linux安装之后 ...

  7. C语言中的宏展开

    #include<stdio.h> #define f(a,b) a##b #define g(a) #a #define h(a) g(a) int main() { printf(,) ...

  8. yeoman运行grunt serve 提示错误

    今天在使用 yeoman 的时候,当我运行 grunt serve 命令的时候,出现如下提示: 1.Error: Cannot find module 'load-grunt-tasks' $ gru ...

  9. TCP建立连接和释放的过程,及TCP状态变迁图

    一.TCP报文格式 下面是TCP报文格式图: 重要字段介绍: (1)序号:Seq序号,占32位,用来标识从TCP源端向目的端发送的字节流,发起方发送数据时对此进行标记. (2)确认序号:Ack序号,占 ...

  10. UVa 1252 (状压DP + 记忆化搜索) Twenty Questions

    题意: 有n个长为m的各不相同的二进制数(允许存在前导0),别人已经事先想好n个数中的一个数W,你要猜出这个数. 每次只可以询问该数的第K为是否为1. 问采用最优询问策略,则最少需要询问多少次能保证猜 ...