我正在从cv2.findContours打印轮廓。它会打印出这样的东西: [[370 269]] 我想要的是得到370并将其存储到一个变量中。在
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while True:
_, frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower = np.array([0,0,255])
upper = np.array([255,255,255])
imgThreshHigh = cv2.inRange(hsv, lower, upper)
thresh = imgThreshHigh.copy()
_,contours,_ = cv2.findContours(thresh,
cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)
print(contours)
cv2.imshow('frame',frame)
cv2.imshow('Object',thresh)
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
为了存储单个轮廓的所有
x
和y
坐标,我计算出了以下方法:我相信一定有更快的方法!!在
你知道解构吗?在
或者,如果数据是列表列表:
^{pr2}$相关问题 更多 >
编程相关推荐