Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apriltag Built in Pose vastly superior to SolvePnp? #212

Open
henryjliu opened this issue Feb 23, 2022 · 1 comment
Open

Apriltag Built in Pose vastly superior to SolvePnp? #212

henryjliu opened this issue Feb 23, 2022 · 1 comment

Comments

@henryjliu
Copy link

henryjliu commented Feb 23, 2022

I did some tests and here is some basic python code using dt_apriltags in python. I believe the solvepnp to be equivalent eg uses the center of the tag and IPPE_SQUARE but it gives terrible results compared to the builtin AprilTag estimatepose function. Is there an implementation that mimicks the behavior of the Apriltag function but can be used with multiple tags / grid of tags? I need to dig deeper into the code of apriltag_pose.c but again I'm not sure why results are so different than the below code which uses exact same corners and tag parameters. Any ideas?

Snippet:

cameraMatrix = mtx #need mtx from calibration
camera_params = ( cameraMatrix[0,0], cameraMatrix[1,1], cameraMatrix[0,2], cameraMatrix[1,2] )
print(cameraMatrix)
img = cv2.imread(ab_path, cv2.IMREAD_GRAYSCALE) #needs grayscale
#cv2.imshow('img',img);

tags = at_detector.detect(img, True, camera_params, .001944)

print("tap[0] ", tags[0].pose_t)
print("tap[1] ", tags[1].pose_t)
#print(tags[0].pose_R)
#print(tags[1].pose_R)

ts=.01944/2
worldpoints=np.array([[-ts, ts, 0],
                    [ts,ts,0],
                    [ts,-ts,0],
                    [-ts,-ts,0]],dtype=numpy.float)
#check tag corners
SOLVEPNP_IPPE_SQUARE=7
#compare to solve pnp    
(_, rvec, tvec)=cv2.solvePnP(worldpoints, tags[0].corners, mtx, dist, useExtrinsicGuess=tru, flags=SOLVEPNP_IPPE_SQUARE)
(_, rvec2, tvec2)=cv2.solvePnP(worldpoints, tags[1].corners, mtx, dist, useExtrinsicGuess=False, flags=SOLVEPNP_IPPE_SQUARE)
print("tvec[0] ", tvec)
print("tvec[1] " , tvec2)
@jrepp
Copy link
Contributor

jrepp commented Feb 23, 2022

What are these extra parameters you're passing to detect()?
Is the request to get access to the estimate pose functionality of apriltag from python? I don't see those APIs exposed currently to python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants