opencv macOS上的Python open cv aruco

kfgdxczn  于 2023-05-18  发布在  Mac
关注(0)|答案(1)|浏览(241)
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()
xfb7svmp

xfb7svmp1#

不需要将变量marker_dictparameters传递给ArucoDetector。您在创建ArucoDetector对象时已经给出了这些信息。只需将图像传送到探测器。

marker_corners, marker_IDs, reject = detector.detectMarkers(gray_frame)

相关问题