juerg
juerg

Reputation: 519

opencv aruco estimatePoseSingleMarkers python

I am trying to find aruco markers using w10, python 3.6, opencv2.

I can detect markers but fail on this step

rvec, tvec = aruco.estimatePoseSingleMarkers(corners, markerLength, camera_matrix, dist_coeffs) # For a single marker

I get this python exception:

ValueError: too many values to unpack (expected 2)

leaving out tvec in the result list does not throw the error but then I do not have the translation info.

Upvotes: 3

Views: 9248

Answers (2)

Nusri Nalir
Nusri Nalir

Reputation: 63

use only one variable to get what is returned by aruco.estimatePoseSingleMarkers . then take only the first two values like in the below code.

ret = aruco.estimatePoseSingleMarkers(corners,marker_size,cameraMatrix=cameraMatrix,distCoeffs=cameraDistortion)
(rvec, tvec) = (ret[0][0, 0, :], ret[1][0, 0, :])

Upvotes: 0

Sahil Anand
Sahil Anand

Reputation: 61

I had the same issue, it seems like there are 3 arrays that need to be unpacked, so try this

rvec, tvec, _ = aruco.estimatePoseSingleMarkers(corners, markerLength, camera_matrix, dist_coeffs)

Not sure what the third array is about.

Upvotes: 6

Related Questions