Python 3.x 提取轮廓上形成最长直线的点
我已经提取了叶子边界的轮廓,我想提取叶子的直径,其中直径是叶子闭合轮廓上任意两点之间的最长距离 我已经写了一些代码,不知道它是否正确,任何帮助将不胜感激Python 3.x 提取轮廓上形成最长直线的点,python-3.x,machine-learning,image-processing,numpy-ndarray,opencv-python,Python 3.x,Machine Learning,Image Processing,Numpy Ndarray,Opencv Python,我已经提取了叶子边界的轮廓,我想提取叶子的直径,其中直径是叶子闭合轮廓上任意两点之间的最长距离 我已经写了一些代码,不知道它是否正确,任何帮助将不胜感激 _, contours, _ = cv2.findContours(imgClosed, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) cnt = contours[0] dist = 0 for i in range(len(cnt)): for j in range(len(cnt)):
_, contours, _ = cv2.findContours(imgClosed, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
cnt = contours[0]
dist = 0
for i in range(len(cnt)):
for j in range(len(cnt)):
if (i != j):
temp = np.linalg.norm(cnt[i] - cnt[j])
if (temp > dist):
dist = temp
dist