import cv2
import cv2.aruco as aruco
marker_dict = aruco.getPredefinedDictionary(aruco.DICT_4X4_50)
parameters = cv2.aruco.DetectorParameters()
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
gray_frame = cv2.cvtColor (frame,cv2.COLOR_BGR2GRAY)
detector = cv2.aruco.ArucoDetector(marker_dict, parameters)
marker_corners, marker_IDs, reject = detector.detectMarkers(
gray_frame, marker_dict, parameters=parameters)
print(marker_IDs)
cv2. imshow ("frame", frame)
key = cv2.waitKey(1)
if key == ord("g"):
break
cap.release()
cv2.destroyAllWindows()
detectMarker错误参数
我认为函数参数类似于aruco的以前版本
marker_corners, marker_IDs, reject = detector.detectMarkers(
cv2.error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'detectMarkers'
> Overload resolution failed:
> - 'parameters' is an invalid keyword argument for aruco_ArucoDetector.detectMarkers()
> - 'parameters' is an invalid keyword argument for aruco_ArucoDetector.detectMarkers()
1条答案
按热度按时间xfb7svmp1#
不需要将变量
marker_dict
和parameters
传递给ArucoDetector
。您在创建ArucoDetector
对象时已经给出了这些信息。只需将图像传送到探测器。