c语言sscanf函数的用法是什么
266
2022-09-12
opencv练习18椭圆、直线拟合
使用的函数为 cv2.ellipse(),返回值其实就是旋转边界矩形的内切圆。
ellipse = cv2.fitEllipse(cnt)im = cv2.ellipse(im,ellipse,(0,255,0),2)
直线拟合
我们可以根据一组点拟合出一条直线,同样我们也可以为图像中的白色点拟合出一条直线。
rows,cols = img.shape[:2]#cv2.fitLine(points, distType, param, reps, aeps[, line ]) → line#points – Input vector of 2D or 3D points, stored in std::vector<> or Mat.#line#4 elements (likeVec4f) - (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#distType=CV_DIST_L2#ρ(r) = r2 /2 (the simplest and the fastest least-squares method)#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.[vx,vy,x,y] = cv2.fitLine(cnt, cv2.DIST_L2,0,0.01,0.01)lefty = int((-x*vy/vx) + y)righty = int(((cols-x)*vy/vx)+y)img = cv2.line(img,(cols-1,righty),(0,lefty),(0,255,0),2)
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~