zoukankan      html  css  js  c++  java
  • 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     最小二乘法

      
ho (r) = r^2/2  quad 	ext{(the simplest and the fastest least-squares method)}

    • distType=CV_DIST_L1

      
ho (r) = r

    • distType=CV_DIST_L12

      
ho (r) = 2  cdot ( sqrt{1 + frac{r^2}{2}} - 1)

    • distType=CV_DIST_FAIR

      
ho left (r 
ight ) = C^2  cdot left (  frac{r}{C} -  log{left(1 + frac{r}{C}
ight)} 
ight )  quad 	ext{where} quad C=1.3998

    • distType=CV_DIST_WELSCH

      
ho left (r 
ight ) =  frac{C^2}{2} cdot left ( 1 -  exp{left(-left(frac{r}{C}
ight)^2
ight)} 
ight )  quad 	ext{where} quad C=2.9846

    • distType=CV_DIST_HUBER

      
ho (r) =  fork{r^2/2}{if $r < C$}{C cdot (r-C/2)}{otherwise} quad 	ext{where} quad C=1.345

    注:  该博文为扩展型;

  • 相关阅读:
    Docker For Windows | Setting Up Docker On Windows
    10款游戏的设计分析
    游戏中的沉浸(Flow in Games)
    游戏中运用了人工智能、机器学习等智能算法的思考
    虚幻4的智能指针
    linux下查看已安装的软件与卸载
    Centos7.2下安装mysql5.7,使用rpm包安装
    VMware 安装 CentOS7
    并发之痛 Thread,Goroutine,Actor
    Creating and using a blendspace in c++
  • 原文地址:https://www.cnblogs.com/yinwei-space/p/9025390.html
Copyright © 2011-2022 走看看