版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距This example program demonstrates the basic usage of a circular measure object.Here, the task is to determine the width of the cogs.*首先读取图像,获取图像的宽度和高度First, read in the image and initialize the program.read_image (Image, rings_and_nuts) dev_close_window ()dev_open_wind
2、ow_fit_image (Image, 0, 0, 640, 640, WindowHandle)set_display_font (WindowHandle, 14, mono, true, false)get_image_size (Image, Width, Height)*读到的图像如下:* Extract the rings.*自动阈值分割,此时为一个区域,如图*bin_threshold (Image, Region)*进行连通区域划分,不同的区域用不同的颜色表示,如图:* connection (Region, ConnectedRegions)填充区域内的孔洞,效果如图fil
3、l_up (ConnectedRegions, RegionFillUp)kp kp *通过紧性特征进行区域筛选,在1.5到2.5之间的为需要测量的圆环*for i := 0 to |Compactness|-1 by 1if (Compactnessi 1.5 and Compactnessi 2.5)select_obj (RegionFillUp, ObjectSelected, i+1)* Determine the size and position of the rings.*计算选择区域的最小外接圆和最大内接圆,存储圆心和半径* *两个半径的均值作为测量圆弧半径,AnnulusR
4、adius为测量圆弧宽度*smallest_circle (ObjectSelected, Row, Column, RadiusMax) inner_circle (ObjectSelected, CenterRow, CenterCol, RadiusMin) Radius := (RadiusMax+RadiusMin)/2.0AnnulusRadius := (RadiusMax-RadiusMin)/4.0*Determine the position between two cogs.This position is then used as the start angle for
5、 the circular ROI.*多边形近似逼近区域,存储多边形角点的坐标值,机器视觉算法与应用第252页 get_region_polygon (ObjectSelected, AnnulusRadius, RowsBorder, ColumnsBorder)*计算每个角点到最大内接圆圆心的距离,然后进行排序*SqrDistanceBorder(RowsBorder-CenterRow)*(RowsBorder-CenterRow) +SqrDistanceBorder(ColumnsBorder-CenterCol)*(ColumnsBorder-CenterCol)kl. kp *计
6、算直线的角度,圆心和到圆心最近的多边形角点所确定的直线*将 该角度作为测量圆弧的起始角度 *line_orientation (CenterRow, CenterCol, RowsBorderIndices0,ColumnsBorderIndices0, AngleStart)kl. kp kl. kp AngleStart := rad(0)AngleExtent := rad(360) * Create the measure for a circular ROI.Interpolation := bilinear& kL. kL- + + + + + + + + + + + + + +
7、+ + + e kL- kP *生成测量圆弧,& kL. kL- + + + + + + + + + + + + + + + + + e kL- kP gen_measure_arc (CenterRow, CenterCol, Radius, AngleStart, AngleExtent, AnnulusRadius, Width, Height, Interpolation, MeasureHandle)*Determine all edge pairs that have a negative transition, i.e., edge pairsthat enclose dark
8、regions.Note that the output parameters IntraDistance and InterDistance are given as arclengths.Sigma := 1.0Threshold := 30Transition := negativeSelect := all* 进 行 边 缘 对 测 量,RowEdgeFirst, ColumnEdgeFirst , RowEdgeSecond,*ColumnEdgeSecond为检测圆弧检测到的边界的中心点的坐标,IntraDistance,*InterDistance分别为边缘对间的距离和边缘对的弧
9、线距离*如有疑问,请咨询 *如有疑问,请咨询 qiuqiu:1613985351*measure_pairs (Image, MeasureHandle, Sigma, Threshold, Transition, Select,RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond,AmplitudeSecond, IntraDistance, InterDistance)* Determine the number of cogs. NumCogs := |RowEdgeFirst|* D
10、etermine the linear distance between the two edges of each edge pair (Linear cogsize)* as well as the angular distance of the edge pairs (Angular cog size).*计算边缘对的直线距离和弧度 *distance_pp (RowEdgeFirst, ColumnEdgeFirst, RowEdgeSecond, ColumnEdgeSecond, LinearDistance)AngularDistance := deg(IntraDistance
11、/Radius)Visualize the determined edges.*将边缘对的起始终止点画出,并显示测量结果Visualize the determined edges.*将边缘对的起始终止点画出,并显示测量结果gen_empty_obj (Crosses) for i := 0 to IRowEdgeFirstl-1 by 1 gen_cross_contour_xld (Cross, RowEdgeFirsti, ColumnEdgeFirsti, AnnulusRadius*2.0, atan2(RowEdgeFirsti-CenterRow,ColumnEdgeFirsti
12、-CenterCol) concat_obj (Crosses, Cross, Crosses) gen_cross_contour_xld (Cross, RowEdgeSecondi, ColumnEdgeSecondi,AnnulusRadius*2.0, atan2(RowEdgeSecondi-CenterRow,ColumnEdgeSecondi-CenterCol) concat_obj (Crosses, Cross, Crosses) endfor dev_display (Image) dev_set_line_width (4) dev_set_color (black)
13、 dev_display (Crosses) dev_set_line_width (1) dev_set_color (white) dev_display (Crosses) * Display the measured size of the cogs.disp_message (WindowHandle, Number of cogs: +|RowEdgeFirst|+ ,window, 260, 10, black, true)disp_message (WindowHandle, Mean cog size:, window, 286,10, black, true)disp_me
14、ssage (WindowHandle, - Arc length: +mean(IntraDistance)$.2f+ +/- +deviation(IntraDistance)$.2f+ pixel, window, 310, 10, black, true)disp_message (WindowHandle, - Linear:+mean(LinearDistance)$.2f+ +/-+deviation(LinearDistance)$.2f+ pixel, window, 334, 10, black, true)disp_message (WindowHandle, - Angular:+mean(AngularDistance)$.2f+ +/-+deviation(AngularDistance)$.2f+ deg , window, 358, 10, bla
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026云南大理州弥渡县紧密型医共体总医院招聘编制外卫生专业技术人员9人备考题库带答案详解(新)
- 2026内蒙古鄂尔多斯伊金霍洛旗高级中学分校招聘1人备考题库附参考答案详解(黄金题型)
- 2026上半年贵州事业单位联考贵州民族大学招聘52人备考题库带答案详解(综合卷)
- 2026云南临沧市朋阳颐养院失智失能照护中心招聘9人备考题库带答案详解(轻巧夺冠)
- 2026广西北海市第二中学(北京八中北海分校)临聘教师招聘2人备考题库附答案详解(研优卷)
- 2026广东珠海高新区招聘区投资促进中心事业编制人员1人备考题库附参考答案详解(能力提升)
- 2026云南保山市天立学校后勤员工招聘备考题库及完整答案详解一套
- 2026四川成都龙泉驿区洪河爱尚幼儿园招聘教师1人备考题库含答案详解(综合题)
- 2026广东佛山市顺德区龙潭小学招聘语文、心理临聘教师3人备考题库含答案详解(考试直接用)
- 2026广东韶关市始兴县招聘教师52人备考题库(编制)附参考答案详解(突破训练)
- 水利水电工程单元工程施工质量验收标准(2025版)解读课件
- 2026届江苏省连云港市赣榆区高二上数学期末综合测试试题含解析
- 艺考合同包过合同范本
- 2025年大学学院教学岗教辅岗招聘考试笔试试题(含答案)
- 环卫垃圾清运车知识培训课件
- 巡察流程工作培训
- 2025年福建高考数学试题及答案
- 湖南省多测合一收费指导标准(试行)2024年版
- 治疗性低温技术临床应用进展
- GB/T 16288-2024塑料制品的标志
- 2024年版《输变电工程标准工艺应用图册》
评论
0/150
提交评论