1D mesauring

is called the profile








get_image_size(Fuse,Width,Height)
Row := 297
Column := 545
Lenght1 :=80
Lenght2 :=10
Angle :=rad(90)
*Length1 为矩形宽 Length2为矩形高
'bilinear',MeasureHandle)
* ColumnEdgeFirst,\
* ColumEdgeSecond 数组中
ColumnEdgeFirst,AmpliudeFirst,RowEdgeSecond,\
ColumEdgeSecond,AmpliudeSecond,IntraDistance,\
InterDistance)
*gen_contour_polygon_xld(Edge,[0,1,2,2,2],[0,0,0,1,2]) 可以得到这样的图形
gen_contour_polygon_xld (EdgeFirst, \
[-sin(Angle+rad(90))*Lenght2+RowEdgeFirst[i],\
-sin(Angle-rad(90))*Lenght2+RowEdgeFirst[i]],\
[cos(Angle+rad(90))*Lenght2+ColumnEdgeFirst[i], \
cos(Angle-rad(90))*Lenght2+ColumnEdgeFirst[i]])
gen_contour_polygon_xld (EdgeSecond, \
[-sin(Angle+rad(90))*Lenght2+RowEdgeSecond[i],\
-sin(Angle-rad(90))*Lenght2+RowEdgeSecond[i]],\
[cos(Angle+rad(90))*Lenght2+ColumEdgeSecond[i], \
cos(Angle-rad(90))*Lenght2+ColumEdgeSecond[i]])
dev_set_color ('cyan')
dev_display (EdgeFirst)
dev_set_color ('magenta')
dev_display (EdgeSecond)
dev_set_color ('blue')
endfor

read_image(Zeiss1,'zeiss1')
get_image_size(Zeiss1,Width,Height)
dev_close_window()
dev_open_window(0,0,Width/2,Height/2,'black',WindowHandle)
dev_display(Zeiss1)
Row := 275
Column :=335
Radius :=107
AngleStart :=-rad(55)
AngleExtent :=rad(170)
*获取椭圆指定角度的点坐标
get_points_ellipse(AngleStart+AngleExtent,Row,Column,0,Radius,Radius,\
RowPoint,ColPoint )
dev_set_draw('fill')
dev_set_color('green')
dev_set_line_width(1)
disp_arc (WindowHandle, Row, Column, AngleExtent,RowPoint, ColPoint)
*生成测量圆弧
gen_measure_arc(Row,Column,Radius,AngleStart,AngleExtent,10,\
Width,Height,'nearest_neighbor',MeasureHandle)
*测量
measure_pos(Zeiss1,MeasureHandle,1,10,'all','all',RowEdge,\
ColumnEdge,Amplitude,Distance)
*计算距离
distance_pp(RowEdge[1],ColumnEdge[1],RowEdge[2],ColumnEdge[2],IntermeDist)
dev_set_color('red')
dev_set_line_width(3)
disp_line(WindowHandle,RowEdge[1],ColumnEdge[1],RowEdge[2],ColumnEdge[2])
disp_message(WindowHandle,'Distance: ' + IntermeDist , 'image',\
250,8,'yellow','false')
close_measure(MeasureHandle)
例子:Measuring Leads of a Moving IC 测量电路板的针脚边缘
dev_update_pc('off')
dev_update_window('off')
dev_update_var('off')
open_framegrabber ('File', 1, 1, 0, 0, 0, 0, 'default', -1, \
'default', 'default', 'default', 'board/board.seq', 'default',\
-1, -1, FGHandle)
grab_image(Image,FGHandle)
get_image_size(Image,Width,Height)
dev_close_window()
dev_open_window(0,0,Width,Height,'black',WindowHandle)
dev_set_window(WindowHandle)
dev_display(Image)
Row1 :=188
Column1 :=182
Row2 :=298
Column2 :=412
gen_rectangle1(Rectangle,Row1,Column1,Row2,Column2)
area_center(Rectangle,Area,Row,Column)
dev_display(Rectangle)
Rect1Row :=-102
Rect1Col :=5
Rect2Row :=107
Rect2Col :=5
RectPhi :=0
RectLength1 :=170
RectLength2 :=5
gen_rectangle2 (Rectangle1, Row+Rect1Row, Column+Rect1Col, RectPhi, RectLength1, RectLength2)
gen_rectangle2 (Rectangle2, Row+Rect2Row, Column+Rect2Col, RectPhi, RectLength1, RectLength2)
dev_display(Rectangle1)
dev_display(Rectangle2)
*创建模型
reduce_domain(Image,Rectangle,ImageReduced)
create_shape_model (ImageReduced,'auto', 0, rad(360), rad(1), 'none', 'use_polarity', 30, 'auto', ModelID)
*获取模型轮廓 shapeModel 在下面有用到哦
*shapeMode 是基准 ,这里shapemodel 的中心点 是原点(0,0) 也就是图像的左上角
get_shape_model_contours(ShapeModel,ModelID,1)
*这段代码没用 囧 ~~ 例子里写这段干嘛 不嫌长啊
*
*创建变换矩阵
*hom_mat2d_identity(HomMat2DIndentity)
*平移矩阵
*hom_mat2d_translate(HomMat2DIndentity,Row,Column,HomMat2DTranslate)
*shapeModel平移 ,这样就到了原来的位置
*因为没有旋转,所以不需要旋转变换了
*affine_trans_contour_xld(ShapeModel,ShapeMOdelTrans,HomMat2DTranslate)
disp_message(WindowHandle,['Press left button to start','and stop the demo'],\
'image',12,12,'black','true')
get_mbutton(WindowHandle,Row3,Column3,Button1)
Button :=0
while(Button #1)
dev_set_window(WindowHandle)
dev_set_part(0,0,Height-1,Width-1)
grab_image(ImageCheck,FGHandle)
dev_display(ImageCheck)
*得到匹配模型的位置和旋转角度
find_shape_model (ImageCheck, ModelID, rad(0), rad(360), 0.7, 1, 0.5, 'least_squares', 4, 0.7,\
RowCheck, ColumnCheck, AngleCheck, Score)
if(|Score| > 0)
dev_set_color('green')
*这里对shapeModel(基准shapemodel 是在图像原点的) 做平移和旋转操作.
hom_mat2d_identity(HomMat2DIndentity)
hom_mat2d_translate(HomMat2DIndentity,RowCheck,ColumnCheck,HomMat2DTranslate)
hom_mat2d_rotate(HomMat2DTranslate,AngleCheck,RowCheck,ColumnCheck,HomMat2DRotate)
affine_trans_contour_xld(ShapeModel,ShapeModelTrans,HomMat2DRotate)
dev_display(ShapeModelTrans)
*这里是对测量区域做校准,图像变换后,测量区域也是要跟着变的饿
*根据新的变换矩阵,以 测量区域 Rect1Row等 求出变换后的 新Rect1RowCheck
*这样就可以创建新的 测量区域了
affine_trans_pixel(HomMat2DRotate,Rect1Row,Rect1Col,Rect1RowCheck,Rect1ColCheck)
affine_trans_pixel(HomMat2DRotate,Rect2Row,Rect2Col,Rect2RowCheck,Rect2ColCheck)
gen_rectangle2(Rectangle1Check,Rect1RowCheck,Rect1ColCheck,AngleCheck,RectLength1,RectLength2)
gen_rectangle2(Rectangle2Check,Rect2RowCheck,Rect2ColCheck,AngleCheck,RectLength1,RectLength2)
dev_set_color('blue')
dev_set_draw('margin')
dev_set_line_width(3)
dev_display(Rectangle1Check)
dev_display(Rectangle2Check)
gen_measure_rectangle2 (Rect1RowCheck, Rect1ColCheck, AngleCheck, RectLength1, RectLength2,\
Width, Height, 'nearest_neighbor', MeasureHandle1)
gen_measure_rectangle2 (Rect2RowCheck, Rect2ColCheck, AngleCheck, RectLength1, RectLength2,\
Width, Height, 'nearest_neighbor', MeasureHandle2)
measure_pairs (ImageCheck, MeasureHandle1, 2, 90, 'positive', 'all', RowEdgeFirst1, \
ColumnEdgeFirst1, AmplitudeFirst1, RowEdgeSecond1, ColumnEdgeSecond1, AmplitudeSecond1, IntraDistance1, InterDistance1)
measure_pairs (ImageCheck, MeasureHandle2, 2, 90, 'positive', 'all', RowEdgeFirst2, \
ColumnEdgeFirst2, AmplitudeFirst2, RowEdgeSecond2, ColumnEdgeSecond2, AmplitudeSecond2, IntraDistance2, InterDistance2)
close_measure(MeasureHandle1)
close_measure(MeasureHandle2)
dev_set_color('red')
dev_set_draw('fill')
disp_line (WindowHandle, RowEdgeFirst1-RectLength2*cos(AngleCheck), ColumnEdgeFirst1-RectLength2*sin(AngleCheck), RowEdgeFirst1+RectLength2*cos(AngleCheck), ColumnEdgeFirst1+RectLength2*sin(AngleCheck))
disp_line (WindowHandle, RowEdgeSecond1-RectLength2*cos(AngleCheck), ColumnEdgeSecond1-RectLength2*sin(AngleCheck), RowEdgeSecond1+RectLength2*cos(AngleCheck), ColumnEdgeSecond1+RectLength2*sin(AngleCheck))
disp_line (WindowHandle, RowEdgeFirst2-RectLength2*cos(AngleCheck), ColumnEdgeFirst2-RectLength2*sin(AngleCheck), RowEdgeFirst2+RectLength2*cos(AngleCheck), ColumnEdgeFirst2+RectLength2*sin(AngleCheck))
disp_line (WindowHandle, RowEdgeSecond2-RectLength2*cos(AngleCheck), ColumnEdgeSecond2-RectLength2*sin(AngleCheck), RowEdgeSecond2+RectLength2*cos(AngleCheck), ColumnEdgeSecond2+RectLength2*sin(AngleCheck))
wait_seconds(2)
endif
* get_mposition (WindowHandle, R, C, Button)
endwhile



图3 sigma =3.0

*************************************************************
dev_close_window()
read_image(Image,'ic_pin')
get_image_size(Image,Width,Height)
dev_open_window(0,0,Width/2,Height/2,'black',WindowHandle)
dev_display(Image)
Row :=47
Column :=485
Phi :=0
Length1 :=420
Length2 :=10
dev_set_color('green')
dev_set_draw('margin')
dev_set_line_width(3)
gen_rectangle2(Rectangle,Row,Column,Phi,Length1,Length2)
gen_measure_rectangle2(Row,Column,Phi,Length1,Length2,Width,Height,\
'nearest_neighbor',MeaserHandle)
* If Transition = 'negative', the edge points with a light-to-dark transition
*in the direction of the major axis of the rectangle are returned in RowEdgeFirst
*and ColumnEdgeFirst. In this case, the corresponding edges with a drak-to-light
*transition are returned in RowEdgeSecond and ColumnEdgeSecond
measure_pairs (Image, MeaserHandle, 1.5, 30, 'negative', 'all', RowEdgeFirst,\
ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond,\
AmplitudeSecond, PinWidth, PinDistance)
disp_line (WindowHandle, RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond,\
ColumnEdgeSecond)
avgPinWidth :=sum(PinWidth)/|PinWidth|
avgPinDistance :=sum(PinDistance)/|PinDistance|
numPins :=|PinWidth|
dev_set_color('yellow')
disp_message(WindowHandle,'Number of pins :'+numPins,'image',200,100,'yellow','false')
disp_message(WindowHandle,'Average Pin Width:' +avgPinWidth,'image',260,100,'yellow','false')
*来个特写
stop()
Row1 := 0
Column1 := 600
Row2 := 100
Column2 := 700
dev_set_color ('blue')
disp_rectangle1 (WindowHandle, Row1, Column1, Row2, Column2)
dev_set_part(Row1,Column1,Row2,Column2)
dev_display(Image)
dev_set_color('green')
dev_display(Rectangle)
dev_set_color('red')
disp_line (WindowHandle, RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond,\
ColumnEdgeSecond)
close_measure(MeaserHandle)
stop()
dev_set_part(0,0,Height-1,Width-1)
dev_display(Image)
dev_set_line_width(3)
Row := 508
Column := 200
Phi := -rad(90)
Length1 := 482
Length2 := 35
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
gen_measure_rectangle2 (Row, Column, Phi, Length1, Length2, Width, Height, 'nearest_neighbor', MeasureHandle)
measure_pos (Image, MeasureHandle, 1.5, 30, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)
disp_line(WindowHandle,RowEdge,ColumnEdge-Length2,RowEdge,ColumnEdge+Length2)
PinHeight1 :=RowEdge[1] - RowEdge[0]
PinHeight2 :=RowEdge[3] - RowEdge[2]
disp_message(WindowHandle,'Pin Height:'+PinHeight1,'image',\
RowEdge[1],ColumnEdge[1]+100,'yellow','false')
disp_message(WindowHandle,'Pin Height:'+PinHeight2,'image',\
RowEdge[3]-50,ColumnEdge[3]+100,'yellow','false')
close_measure(MeasureHandle)
Suppress Clutter ro Noise 抑制噪声
In many applications there is clutter or noise that must be suppressed. The measure operators offer
multiple approaches to achieve this. The best one is to increase the threshold for the edge extraction to
eliminate faint edges. In addition, the value for the smoothing parameter can be increased to smooth
irrelevant edges away.
When grouping edges to pairs, noise edges can lead to an incorrect grouping if they are in the vicinity of
the “real” edge and have the same polarity. In such a case you can suppress the noise edges by selecting
only the strongest edges of a sequence of consecutive rising and falling edges.
If no alignment is needed, the measure object can, for example, be created offline and reused for each
image. If the alignment involves only a translation, translate_measure can be used to correct the
position.

threshold by using the operator measure_thresh. Here, all positions where the gray value crosses the
given threshold are selected.
In case there are extra edges that do not belong to the measurement, HALCON offers an extended
version of measuring: fuzzy measuring. This tool allows to define so-called fuzzy rules, which describe
the features of good edges. Possible features are, e.g., the position, the distance, the gray values, or the
amplitude of edges. These functions are created with create_funct_1d_pairs and passed to the tool
with set_fuzzy_measure. Based on these rules, the tool will select the most appropriate edges.
The advantage of this approach is the flexibility to deal with extra edges even if a very low min-
imum threshold or smoothing is used. An example for this approach is the example program
fuzzy_measure_pin.hdev on page 53.
Please refer to the Solution Guide III-A, chapter 4 on page 33, for more information.
To have full control over the evaluation of the gray values along the measurement line or arc, you can use
measure_projection. The operator returns the projected gray values as an array of numbers, which
can then be further processed with HALCON operators for tuple or function processing (see the chapters
“Tuple” and “Tools . Function” in the Reference Manual). Please refer to the Solution Guide III-A,
section 3.4 on page 22, for more information.
1D mesauring的更多相关文章
- 解决: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19
错误信息:C:\Python27\lib\site-packages\sklearn\utils\validation.py:395: DeprecationWarning: Passing 1d a ...
- sklearn中报错ValueError: Expected 2D array, got 1D array instead:
from sklearn.linear_model import LinearRegression lr = LinearRegression() print(tr_x.shape,tr_y.shap ...
- CUDA编程模型——组织并行线程2 (1D grid 1D block)
在”组织并行编程1“中,通过组织并行线程为”2D grid 2D block“对矩阵求和,在本文中通过组织为 1D grid 1D block进行矩阵求和.一维网格和一维线程块的结构如下图: 其中,n ...
- Halcon 1D测量
1.产生测量句柄,准备提取与矩形(圆弧)主轴垂直的值边缘. gen_measure_rectangle2或gen_measure_arc 2.测量边缘对 ,测量的直线与矩形或者圆弧垂直 measu ...
- 1D Blending
[1D Blending] BlendTree有类型之分,分为1D.2D.本文记录1D. 1D Blending blends the child motions according to a sin ...
- 网桥 以及 IEEE802.1D 生成树协议
(一)网桥 网桥是一个layer 2设备,能够连接两个不同的网段. 如图
- 算法优化》关于1D*1D的DP的优化
关于这一主题的DP问题的优化方法,我以前写过一篇博客与其有关,是关于对递推形DP的前缀和优化,那么这种优化方法就不再赘述了. 什么叫1D*1D的DP捏,就是一共有N种状态,而每种状态都要N种决策,这就 ...
- 解决如下出错:DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19.
背景:在Spyder中写几行脚本,目的是应用sklearn自带的svm(支持向量机)算法,来对其自带的digits(手写体数字)数据集进行分类,过程包括训练阶段和预测阶段.将手写体数字数据的特征数据d ...
- I - 一次元リバーシ / 1D Reversi(水题)
Problem Statement Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is playe ...
随机推荐
- Jmeter数据库mysql测试说明
主要分3个步骤,详细操作步骤如下: 一.环境准备 1.下载mysql驱动,下载地址:https://dev.mysql.com/downloads/connector/j/,Select Operat ...
- TOSCA自动测试工具跟QTP 和 Selenium的简单对比
1. 一个课程里的,可以做个简单的参考,有些地方不是很准确
- FFmpeg 入门(2):输出视频到屏幕
本文转自:FFmpeg 入门(2):输出视频到屏幕 | www.samirchen.com SDL 我们这里使用 SDL 来渲染视频到屏幕.SDL 是 Simple Direct Layer 的缩写, ...
- 在Pycharm中配置Github
Pycharm是当前进行python开发,尤其是Django开发最好的IDE.GitHub是程序员的圣地,几乎人人都在用. 本文假设你对pycharm和github都有一定的了解,并且希望在pycha ...
- Jquery中val、text、html的区别
html就是你可以添加像<a></a>.<p></p>等标记text只能写文本如果写了上面的标记则会以文本形式输出val是属性,只有有该属性的对象才能调 ...
- 优雅的处理你的Java异常
本文介绍 本文仅按照业务系统开发角度描述异常的一些处理看法.不涉及java的异常基础知识,可以自行查阅 <Java核心技术 卷I> 和 <java编程思想> 可以得到更多的基础 ...
- 20145333《Java程序设计》课程总结
每周读书笔记链接汇总 第一周学习总结 第二周学习总结 第三周学习总结 第四周学习总结 第五周学习总结 第六周学习总结 第七周学习总结 第八周学习总结 第九周学习总结 第十周学习总结 实验报告链接汇总 ...
- 20144303 《Java程序设计》第三周学习总结
20144303 <Java程序设计>第三周学习总结 教材学习内容总结 •对象是存在的具体实体,具有明确的状态和行为,类是具有相同属性和行为的一组对象的集合,用于组合各个对象所共有操作和属 ...
- Centos7服务器搭建VNC Server环境
在企业级项目的开发中,尤其是分布式项目,经常直接在服务器上进行开发工作,操作系统环境一般是Centos 7.普遍状况是,在服务器上安装IDE 开发工具,通过 Xshell等工具远程启动,本地通过虚拟桌 ...
- elasticsearch系列(三)库表理解
首先ES没有库和表的概念,只有index,type,document(详细术语可以看ES的系列一 http://www.cnblogs.com/ulysses-you/p/6736926.html), ...