enter image description here我这里有一个跟踪激光点的代码。我想要的是获取激光点的x和y坐标并将其存储到单独的变量中。这是代码:
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while (1):
# Take each frame
ret, frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_red = np.array([0, 0, 255])
upper_red = np.array([255, 255, 255])
mask = cv2.inRange(hsv, lower_red, upper_red)
cv2.imshow('mask', mask)
cv2.imshow('Track Laser', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()