opencv(四):曲线拟合
发布时间
阅读量:
阅读量
import cv2 as cv
import numpy as np
def circle_fitness_demo():
# 创建图像, 绘制初始点
image = np.zeros((400, 400, 3), dtype=np.uint8)
x = np.array([30, 50, 100, 120])
y = np.array([100, 150, 240, 200])
for i in range(len(x)):
cv.circle(image, (x[i], y[i]), 3, (255, 0, 0), -1, 8, 0)
cv.imwrite("D:/curve.png", image)
# 多项式曲线生成
poly = np.poly1d(np.polyfit(x, y, 6))
print(poly)
# 绘制拟合曲线
for t in range(30, 250, 1):
y_ = np.int(poly(t))
cv.circle(image, (t, y_), 1, (0, 0, 255), 1, 8, 0)
cv.imshow("fit curve", ima
全部评论 (0)
还没有任何评论哟~
