opencv: 线性拟合
opencv提供了fitline函数用于直线拟合,原型为:
C++: void fitLine(InputArray points, OutputArray line, int distType, double param, double reps, double aeps) Python: cv2.fitLine(points, distType, param, reps, aeps) → line C: void cvFitLine(const CvArr* points, int distType, double param, double reps, double aeps, float* line) Python: cv.FitLine(points, distType, param, reps, aeps) → line Parameters:
points – Input vector of 2D or 3D points, stored in std::vector<> or Mat.
line – Output line parameters. In case of 2D fitting, it should be a vector of 4 elements (like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector collinear to the line and (x0, y0) is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line and (x0, y0, z0) is a point on the line.
distType – Distance used by the M-estimator (see the discussion below).
param – Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value is chosen.
reps – Sufficient accuracy for the radius (distance between the coordinate origin and the line).
aeps – Sufficient accuracy for the angle. 0.01 would be a good default value for reps and aeps.
支持2D,3D的点集拟合,点集使用std::vector<>来存储,如果为3Dpoint,那么line使用Vec6f, 2D points,使用Vec4f;
拟合方式提供了下面几种方法:
distType=CV_DIST_L2 最小二乘法

distType=CV_DIST_L1

distType=CV_DIST_L12

distType=CV_DIST_FAIR

distType=CV_DIST_WELSCH

distType=CV_DIST_HUBER

注: 该博文为扩展型;
opencv: 线性拟合的更多相关文章
- 用python的numpy作线性拟合、多项式拟合、对数拟合
转自:http://blog.itpub.net/12199764/viewspace-1743145/ 项目中有涉及趋势预测的工作,整理一下这3种拟合方法:1.线性拟合-使用mathimport m ...
- 深度学习原理与框架-Tensorflow基本操作-实现线性拟合
代码:使用tensorflow进行数据点的线性拟合操作 第一步:使用np.random.normal生成正态分布的数据 第二步:将数据分为X_data 和 y_data 第三步:对参数W和b, 使用t ...
- 跟我学算法-tensorflow 实现线性拟合
TensorFlow™ 是一个开放源代码软件库,用于进行高性能数值计算.借助其灵活的架构,用户可以轻松地将计算工作部署到多种平台(CPU.GPU.TPU)和设备(桌面设备.服务器集群.移动设备.边缘设 ...
- 机器学习-TensorFlow建模过程 Linear Regression线性拟合应用
TensorFlow是咱们机器学习领域非常常用的一个组件,它在数据处理,模型建立,模型验证等等关于机器学习方面的领域都有很好的表现,前面的一节我已经简单介绍了一下TensorFlow里面基础的数据结构 ...
- MeteoInfoLab脚本示例:线性拟合
MeteoInfoLab提供一个线性拟合函数linregress,参数是参与拟合的两个数据序列,返回拟合的斜率.截距和相关系数.有了上述拟合参数可以用polyval函数生成拟合数据(直线).然后可以将 ...
- [Python] 波士顿房价的7种模型(线性拟合、二次多项式、Ridge、Lasso、SVM、决策树、随机森林)的训练效果对比
目录 1. 载入数据 列解释Columns: 2. 数据分析 2.1 预处理 2.2 可视化 3. 训练模型 3.1 线性拟合 3.2 多项式回归(二次) 3.3 脊回归(Ridge Regressi ...
- Java 使用 Apache commons-math3 线性拟合、非线性拟合实例(带效果图)
Java 使用 CommonsMath3 的线性和非线性拟合实例,带效果图 例子查看 GitHub Gitee 运行src/main/java/org/wfw/chart/Main.java 即可查看 ...
- OpenCV 线性混合(4)
带滚动条的线性混合示例: #include "stdafx.h" #include<iostream> #include<thread> #incl ...
- OpenCV 最小二乘拟合方法求取直线倾角
工业相机拍摄的图像中,由于摄像质量的限制,图像中的直线经过处理后,会表现出比较严重的锯齿.在这种情况下求取直线的倾角(其实就是直线的斜率),如果是直接选取直线的开始点和结束点来计算,或是用opencv ...
随机推荐
- java数据库导入excel数据
导入数据会将表格分为xls和xlsx两种格式,网上有很多案例 1.excel数据表中的数据不全,数据库中又是必填选项:---从sql语句入手:判断有无 来改变语句 //设置可有可无 字段 加一个必有字 ...
- Nginx 当上游服务器返回失败时的处理办法
陶辉95课 Syntax: proxy_next_upstream error | timeout | invalid_header | http_500 | http_502 | http_503 ...
- Linux 集锦(持续更新中)
// 获取文件夹下的代码总行数 find . -name "*.*" | xargs wc -l // ls 排序 ls -lt 按照最后修改时间降序 ls -lrt 按照时间升序 ...
- LIRE图片识别搜索demo--Ubuntu开发
Ubuntu安装shadowsocks客户端/服务端教程 1.安装shadowsocks sudo apt-get update sudo apt-get install python-pip sud ...
- BZOJ3105 新Nim游戏 【拟阵】
题目分析: 我不知道啥是拟阵啊,但有大佬说线性基相关的都是拟阵,所以直接贪心做了. 题目代码: #include<bits/stdc++.h> using namespace std; ; ...
- 【BZOJ1578】【USACO2009Feb】股票市场 背包DP
题目大意 告诉你\(n\)只股票在这\(m\)天内的价格,给你\(s\)元的初始资金,问你\(m\)天后你最多拥有多少钱. \(n\leq 50,m\leq 10,s\leq 200000,\)答案\ ...
- 【BZOJ1211】【HNOI2004】树的计数 prufer序列
题目描述 给你\(n\)和\(n\)个点的度数,问你有多少个满足度数要求的生成树. 无解输出\(0\).保证答案不超过\({10}^{17}\). \(n\leq 150\) 题解 考虑prufer序 ...
- 【HDU - 4348】To the moon(主席树在线区间更新)
BUPT2017 wintertraining(15) #8G 题意 给一个数组a,有n个数,m次操作.\(N, M ≤ 10^5, |A i| ≤ 10^9, 1 ≤ l ≤ r ≤ N, |d| ...
- Wannafly挑战赛 22
爆零祭 T1 这题第一反应gcd啊 所以就把每个a[i]对m取模 然后求它们的gcd 即res = gcd(a[1] % m, a[2] % m, ... , a[n] % m) ans = 1 + ...
- Write less code
If you find yourself writing a lot of code to do something simple, you're probably doing it wrong. A ...