gpt4 book ai didi

python - 值错误: too many values to unpack opencv-python

转载 作者:行者123 更新时间:2023-12-01 02:51:37 24 4
gpt4 key购买 nike

使用 opencv-python 进行跟踪项目。我在调用 estiamte 单一标记时收到此错误..有什么想法吗?

cv2 版本 3.2.0-dev

Python版本2.7.12

Traceback (most recent call last):
File "test_aruco_detect.py", line 53, in <module>
rvecs , tvecs = aruco.estimatePoseSingleMarkers(corners, 0.1765, cameraMatrix, distCoeffs)
ValueError: too many values to unpack

代码:

import numpy as np
import cv2
import cv2.aruco as aruco

with np.load('/home/odroid/camera_calibration/testfile.npz') as X:
cameraMatrix,distCoeffs = [X[i] for i in ('arr_0','arr_1')]


cap = cv2.VideoCapture(0)

while(True):
# Capture frame-by-frame
ret, frame = cap.read()
#print(frame.shape) #480x640
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250)
parameters = aruco.DetectorParameters_create()


#lists of ids and the corners beloning to each id
corners, ids, rejectedImgPoints = aruco.detectMarkers(gray, aruco_dict, parameters=parameters)


if ids != None: #if atleast one id is detected
gray = aruco.drawDetectedMarkers(gray, corners,ids)
rvecs , tvecs = aruco.estimatePoseSingleMarkers(corners, 0.1765, cameraMatrix, distCoeffs)
aruco.drawAxis(gray, cameraMatrix, distCoeffs, rvecs, tvecs)


cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break


cap.release()
cv2.destroyAllWindows()

最佳答案

rvecs , tvecs, _objPoints = aruco.estimatePoseSingleMarkers(...) 

编辑:

根据文档( http://docs.opencv.org/trunk/d9/d6a/group__aruco.html#ga84dd2e88f3e8c3255eb78e0f79571bd1 )我缺少 _objPoints

关于python - 值错误: too many values to unpack opencv-python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44701956/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com