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: 线性拟合的更多相关文章

  1. 用python的numpy作线性拟合、多项式拟合、对数拟合

    转自:http://blog.itpub.net/12199764/viewspace-1743145/ 项目中有涉及趋势预测的工作,整理一下这3种拟合方法:1.线性拟合-使用mathimport m ...

  2. 深度学习原理与框架-Tensorflow基本操作-实现线性拟合

    代码:使用tensorflow进行数据点的线性拟合操作 第一步:使用np.random.normal生成正态分布的数据 第二步:将数据分为X_data 和 y_data 第三步:对参数W和b, 使用t ...

  3. 跟我学算法-tensorflow 实现线性拟合

    TensorFlow™ 是一个开放源代码软件库,用于进行高性能数值计算.借助其灵活的架构,用户可以轻松地将计算工作部署到多种平台(CPU.GPU.TPU)和设备(桌面设备.服务器集群.移动设备.边缘设 ...

  4. 机器学习-TensorFlow建模过程 Linear Regression线性拟合应用

    TensorFlow是咱们机器学习领域非常常用的一个组件,它在数据处理,模型建立,模型验证等等关于机器学习方面的领域都有很好的表现,前面的一节我已经简单介绍了一下TensorFlow里面基础的数据结构 ...

  5. MeteoInfoLab脚本示例:线性拟合

    MeteoInfoLab提供一个线性拟合函数linregress,参数是参与拟合的两个数据序列,返回拟合的斜率.截距和相关系数.有了上述拟合参数可以用polyval函数生成拟合数据(直线).然后可以将 ...

  6. [Python] 波士顿房价的7种模型(线性拟合、二次多项式、Ridge、Lasso、SVM、决策树、随机森林)的训练效果对比

    目录 1. 载入数据 列解释Columns: 2. 数据分析 2.1 预处理 2.2 可视化 3. 训练模型 3.1 线性拟合 3.2 多项式回归(二次) 3.3 脊回归(Ridge Regressi ...

  7. Java 使用 Apache commons-math3 线性拟合、非线性拟合实例(带效果图)

    Java 使用 CommonsMath3 的线性和非线性拟合实例,带效果图 例子查看 GitHub Gitee 运行src/main/java/org/wfw/chart/Main.java 即可查看 ...

  8. OpenCV 线性混合(4)

      带滚动条的线性混合示例:   #include "stdafx.h" #include<iostream> #include<thread> #incl ...

  9. OpenCV 最小二乘拟合方法求取直线倾角

    工业相机拍摄的图像中,由于摄像质量的限制,图像中的直线经过处理后,会表现出比较严重的锯齿.在这种情况下求取直线的倾角(其实就是直线的斜率),如果是直接选取直线的开始点和结束点来计算,或是用opencv ...

随机推荐

  1. Linux系统下手把手完成无人值守安装服务

    刚入职的运维新手经常会被要求去做一些安装操作系统的工作,如果按照用镜像光盘安装操作系统,效率会相当低下.那么如何提升效率,搭建出一套可以批量安装Linux系统的无人值守的安装系统? PXE+TFTP+ ...

  2. Centos安装python3

    安装环境 系统:阿里云服务器centos7.5系统 看见好多博客对centos安装python3的方式各不相同且都不完整,今天我来完整的演示安装python3 1.下载python3源码包 命令 wg ...

  3. Civil 3D 二次开发 翻转曲面高程分析颜色

    不解释,直接上代码及截图. [CommandMethod("RvsSEA")] public void ReverseSurfaceElevationAnalysis() { Ci ...

  4. 使用poi将Excel文件转换为data数据

    pom <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http:// ...

  5. SpringBoot部署jar与war

    jar部署与启动/关闭 1.打包 clean 清理已有target目录 package 重新打包 获取打包路径,通过 scp命令发送到服务器端,scp -P ${port} ${.jar} ${use ...

  6. 大学jsp实验3include指令的使用

    1.include指令的使用 (1)编写一个名为includeCopyRight.jsp的页面,页面的浏览效果如下: 要求“2016”这个值可以实现动态更新.请写出页面代码: <%@ page ...

  7. OpenCv的CV2一些函数总结

  8. Power Stations HDU - 3663

    我为什么T了.... Power Stations Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  9. Leetcode 202.快乐数 By Python

    编写一个算法来判断一个数是不是"快乐数". 一个"快乐数"定义为:对于一个正整数,每一次将该数替换为它每个位置上的数字的平方和,然后重复这个过程直到这个数变为 ...

  10. 09 Zabbix4.0系统clone、mass update使用

    点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 09 Zabbix4.0系统clone.mass update使用 1. clone使用: clo ...