halcon中如何生成椭圆_Halcon中关于角度计算和测量拟合的算子详解
角度计算算子简介
1、计算直线与水平轴之间的夹角
angle_lx( : : Row1, Column1, Row2, Column2 : Angle)
角度计算方式:将直线看作向量(有方向性),以直线与水平轴的交点为起点(旋转中心)。如果终点在水平轴上方,则夹角为逆时针旋转水平轴到向量的角度(带正号)。如果终点在水平轴下方,则夹角为顺时针旋转水平轴到向量的角度(带负号)。结果取决于定义线条的两点的顺序。
角度表示方式:弧度,-π<=Angle
2、计算两条直线之间的夹角
angle_ll( : : RowA1, ColumnA1, RowA2, ColumnA2, RowB1, ColumnB1, RowB2, ColumnB2 : Angle)
角度计算方式:该算子计算原理与angle_lx类似,只不过把水平轴替换为任意直线B
角度表示方式:弧度,-π<=Angle<=π
3、计算一条直线的方向
line_orientation( : : RowBegin, ColBegin, RowEnd, ColEnd : Phi)
角度计算方式:当直线(无方向性)大致位于1、3象限的方向,角度为正。当直线大致位于2、4象限的方向,角度为负。
角度表示方式:弧度,-π/2
4、计算一条直线的参数
line_position( : : RowBegin, ColBegin, RowEnd, ColEnd : RowCenter, ColCenter, Length, Phi)
角度计算方式:同算子 line_orientation。
角度表示方式:弧度,-π/2
5、计算区域等效椭圆的参数
elliptic_axis(Regions : : : Ra, Rb, Phi)
角度计算方式:该区域等效椭圆的主轴(无方向性)相对于水平轴(有方向性)的角度。
角度表示方式:弧度,-π/2
6、计算区域的最小仿射外接矩形的参数
smallest_rectangle2(Regions : : : Row, Column, Phi, Length1, Length2)
角度计算方式:同算子elliptic_axis
角度表示方式:弧度,-π/2
7、计算区域的方向
orientation_region(Regions : : : Phi)
角度计算方式:计算原理基于算子elliptic_axis。此外,还计算了轮廓上离重心最大距离的点。如果此点的列坐标小于重心的列坐标,则elliptic_axis计算得到的角度值需要加上π。
角度表示方式:弧度,-π<=Phi
8、计算contours 或 polygons的等效椭圆的参数
elliptic_axis_xld(XLD : : : Ra, Rb, Phi)
角度计算方式:计算原理同算子elliptic_axis。需要注意的是输入的contours 或 polygons不能自相交,如果他们不是闭合轮廓,那么在计算过程中会自动闭合,由此可能会产生自相交,从而导致最终的计算结果不准确。如果输入的轮廓存在自相交,可用elliptic_axis_points_xld算子代替。
角度表示方式:弧度,-π/2
9、计算contours 或 polygons的方向
orientation_xld(XLD : : : Phi)
角度计算方式:计算原理同算子orientation_region。需要注意的是输入的contours 或 polygons不能自相交,如果他们不是闭合轮廓,那么在计算过程中会自动闭合,由此可能会产生自相交,从而导致最终的计算结果不准确。如果输入的轮廓存在自相交,可用orientation_points_xld算子代替。
角度表示方式:弧度,-π
总结
计算角度时,如果有方向性,角度范围一般是(-π,π)。如果没有方向性,角度范围一般是(-π/2,π/2)
拟合/测量
*************************测量算子*******************************
*画仿射矩形
draw_rectangle2 (3600, Row5, Column4, Phi1, Length1, Length2)
gen_rectangle2 (Rectangle1, Row5, Column4, Phi1, Length1, Length2)
*获取测量句柄
gen_measure_rectangle2 (Row5, Column4, Phi1, Length1, Length2, 512, 512, 'nearest_neighbor', MeasureHandle)
*句柄,平滑参数,灰度差,极性,选择边缘点,边缘中心y,x坐标,幅度,距离
measure_pos (Image, MeasureHandle, 6.1, 65, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)
gen_cross_contour_xld (Cross, RowEdge, ColumnEdge, 6, Phi1)
close_measure (MeasureHandle)
*************************图像--区域--轮廓************************
*区域转轮廓
gen_contour_region_xld (SelectedRegions, Contours, 'border')
*轮廓点坐标
get_contour_xld (Contours, Row, Col)
gen_cross_contour_xld (Cross1, Row, Col, 6, Phi1)
*轮廓拟合圆
fit_circle_contour_xld (Contours, 'algebraic', -1, 0, 0, 3, 2, Row3, Column, Radius, StartPhi, EndPhi, PointOrder)
gen_circle_contour_xld (ContCircle, Row3, Column, Radius, 0, 6.28318, 'positive', 1)
*轮廓拟合椭圆或椭圆弧
fit_ellipse_contour_xld (Contours, 'fitzgibbon', -1, 0, 0, 200, 3, 2, Row4, Column3, Phi, Radius1, Radius2, StartPhi1, EndPhi1, PointOrder1)
gen_ellipse_contour_xld (ContEllipse, Row4, Column3, Phi, Radius1, Radius2, 0, 6.28318, 'positive', 1.5)
**************************图像--轮廓**************************
*提取亚像素精度边缘轮廓
edges_sub_pix (ImageReduced, Edges, 'canny', 1, 20, 40)
*筛选出指定轮廓
select_contours_xld (Edges, SelectedContours, 'contour_length', 0, 50, -0.5, 0.5)
dev_set_color ('green')
*拟合直线
fit_line_contour_xld (SelectedContours, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
disp_line (3600, RowBegin, ColBegin, RowEnd, ColEnd)
****************************拟合矩形****************************
*生成感兴趣的区域
read_image (Image, 'fabrik')
draw_rectangle1 (3600, Row11, Column11, Row2, Column2)
gen_rectangle1 (Rectangle, Row11, Column11, Row2, Column2)
reduce_domain (Image, Rectangle, ImageReduced)
*提取轮廓,拟合矩形
edges_sub_pix (ImageReduced, Edges, 'canny', 1, 20, 40)
select_contours_xld (Edges, SelectedContours, 'contour_length', 80, 800, -0.5, 0.5)
fit_rectangle2_contour_xld (SelectedContours, 'regression', -1, 0, 0, 3, 2, Row1, Column1, Phi1, Length11, Length21, PointOrder)
gen_rectangle2 (Rectangle1, Row1, Column1, Phi1, Length11, Length21)
***********************************计算垂足、夹角***************************************
read_image (Image, 'fabrik')
draw_rectangle1 (3600, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
reduce_domain (Image, Rectangle, ImageReduced)
edges_sub_pix (ImageReduced, Edges, 'canny', 1, 20, 40)
sort_contours_xld (Edges, SortedContours, 'upper_left', 'true', 'row')
*取轮廓上的点
select_obj (SortedContours, ObjectSelected, 2)
get_contour_xld (ObjectSelected, Row, Col)
*取轮廓上的线
select_obj (SortedContours, ObjectSelected1, 10)
fit_line_contour_xld (ObjectSelected1, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
*计算点到线的垂足
projection_pl (Row[0],Col[0],RowBegin, ColBegin, RowEnd, ColEnd ,RowProj, ColProj)
*显示点、直线、垂足、垂线
gen_cross_contour_xld (Cross,Row[0],Col[0], 6, 0.785398)
disp_line (3600, RowBegin, ColBegin, RowEnd, ColEnd)
gen_cross_contour_xld (Cross1,RowProj, ColProj, 6, 0.785398)
disp_line (3600, Row[0],Col[0],RowProj, ColProj)
*计算两条直线的夹角
angle_ll ( RowBegin, ColBegin, RowEnd, ColEnd, Row[0],Col[0],RowProj, ColProj, Angle)
*弧度转角度deg,角度转弧度rad
Ang:=deg(Angle)
*计算直线和水平轴x的夹角
angle_lx (RowBegin, ColBegin, RowEnd, ColEnd, Angle1)
Ang1:=deg(Angle1)
angle_lx (Row[0],Col[0],RowProj, ColProj, Angle2)
Ang2:=deg(Angle2)
项目案例
halcon学习笔记——实例篇(2)长度和角度测量
halcon中如何生成椭圆_Halcon中关于角度计算和测量拟合的算子详解相关推荐
- html圆形圆心坐标,halcon找圆心坐标(拟合圆算子详解)
Contours(in):输入轮廓 Algorithm(in):拟合圆的算法 MaxNumPoints(in):用于计算的最大轮廓点个数 MaxClosureDist(in):一个轮廓的末尾点最大间距 ...
- halcon中如何生成椭圆_Halcon拟合系列(2)直线/圆/椭圆/矩形拟合算子
fit_line_contour_xld.hdev fit_line_contour_xld(Contours : : Algorithm, MaxNumPoints, ClippingEndPoin ...
- word中自动生成的目录中,编号和文本间距过大
问题: word中自动生成的目录中,编号和文本间距过大,如下图所示: 解决办法: 在正文中,调整列表缩进--更多--编号之后--设置为"空格". 如果经过1步骤后,正文中的编号和后 ...
- 第7.26节 Python中的@property装饰器定义属性访问方法getter、setter、deleter 详解
第7.26节 Python中的@property装饰器定义属性访问方法getter.setter.deleter 详解 一. 引言 Python中的装饰器在前面接触过,老猿还没有深入展开介绍装饰 ...
- Halcon矩阵(Matrix)算子详解
Halcon矩阵(Matrix)算子详解 创建(Creation) create_matrix copy_matrix repeat_matrix clear_matrix 访问(Access) ge ...
- Halcon 解码算子详解 一
Halcon 解码算子详解 一 create_data_code_2d_model SymbolType (输入参数) GenParamName(输入参数) GenParamValue(输入参数) D ...
- Halcon中关于角度计算的算子详解
1.计算直线与水平轴之间的夹角 angle_lx( : : Row1, Column1, Row2, Column2 : Angle) 角度计算方式:将直线看作向量(有方向性),以直线与水平轴的交点为 ...
- 中yeti不能加载_第二十章_类的加载过程详解
类的加载过程详解 概述 在 Java 中数据类型分为基本数据类型和引用数据类型.基本数据类型由虚拟机预先定义,引用数据类型则需要进行类的加载 按照 Java 虚拟机规范,从 Class 文件到加载到内 ...
- android opencv中图像分割,opencv在android平台下的开发【4】-图像滤波详解
前言 在上一篇opencv-android-图像平滑处理文章中,简单介绍了几种图像平滑,也就是图像模糊的方法,使用了几个简单的滤波器,这都属于图像的滤波操作. opencv针对图像的处理提供了imgp ...
最新文章
- mysql挂科了咋办_大一挂科很难受怎么办?
- MySQL:一个死锁分析 (未分析出来的死锁)
- 新员工安全生产知识学习读本
- 简单工厂模式--加减乘除运算
- leetcode 925. 长按键入
- winserver下oracle好运维吗,在Windows 客户端下备份远程Linux服务器上的Oracle数据库...
- cuda-convnet2编译
- 循环队列及C语言实现二
- python动态映射_Python Django框架url反向解析实现动态生成对应的url链接示例
- dwr框架查看外放方法_先睹为快!IntelliJ IDEA v2019.3带来的新框架和新技术
- 深入探究VC —— 资源编译器rc.exe(3)
- 回顾线性系统和非线性系统
- 手撕包菜BT搜索引擎带爬虫自动抓取安装
- 大数开根 高精度 平方根
- linux echo 时间
- 计算机硬件故障智能检测软件,电脑硬件故障检测方法和检测工具推荐
- DCL 对话框 多级窗口开发示例
- 智联招聘如何设置公司屏蔽
- 热电阻 热电偶 测量电路_热控宝典之热电偶、热电阻原理及常见故障处理
- checkra1n越狱错误79_苹果越狱工具checkra1n获0.10.1 beta更新:支持iOS 13.4.1