更新时间:2023-01-18 09:58:17
仅计算2分即可. opencv的Line可以用例如(-10,-10)表示一个点.
Just calculate for 2 points outside. opencv's Line is fine with e.g. (-10,-10) for a point.
import cv2 # python-opencv
import numpy as np
width, height = 800, 600
x1, y1 = 0, 0
x2, y2 = 200, 400
image = np.ones((height, width)) * 255
line_thickness = 2
cv2.line(image, (x1, y1), (x2, y2), (0, 255, 0), thickness=line_thickness)
http://docs.opencv.org /2.4/modules/core/doc/drawing_functions.html#cv2.line