Skip to content

add python wrap for estimate_tag_pose#417

Merged
christian-rauch merged 2 commits into
AprilRobotics:masterfrom
chibai:master
Jan 8, 2026
Merged

add python wrap for estimate_tag_pose#417
christian-rauch merged 2 commits into
AprilRobotics:masterfrom
chibai:master

Conversation

@chibai

@chibai chibai commented Jan 5, 2026

Copy link
Copy Markdown

#415

Told you I'm going to try this
Please review

@christian-rauch

Copy link
Copy Markdown
Collaborator

Thanks. Can you show a side-by-side comparison of an C++ example and the equivalent Python example for detecting a tag and estimating its pose with the new wrapper?

@chibai

chibai commented Jan 6, 2026

Copy link
Copy Markdown
Author

Thanks. Can you show a side-by-side comparison of an C++ example and the equivalent Python example for detecting a tag and estimating its pose with the new wrapper?

I add test_tag_pose_erstimation case

For c interface

mkdir -p build
cd build
cmake -DBUILD_TESTING=ON ..
make -j12 
ctest -V 

For py interface

cd test
python3 test_tag_pose_estimation.py data/33369213973_9d9bb4cc96_c.jpg data/33369213973_9d9bb4cc96_c.txt
python3 test_tag_pose_estimation.py data/34085369442_304b6bafd9_c.jpg data/34085369442_304b6bafd9_c.txt
python3 test_tag_pose_estimation.py data/34139872896_defdb2f8d9_c.jpg data/34139872896_defdb2f8d9_c.txt

@chibai

chibai commented Jan 6, 2026

Copy link
Copy Markdown
Author

For case 33369213973_9d9bb4cc96_c
c interface log

4: Test command: /home/chibai/Documents/apriltag/build/test/test_tag_pose_estimation "data/33369213973_9d9bb4cc96_c.jpg" "data/33369213973_9d9bb4cc96_c.txt"
4: Working Directory: /home/chibai/Documents/apriltag/test
4: Test timeout computed to be: 10000000
4: Testing tag pose estimation with image: data/33369213973_9d9bb4cc96_c.jpg
4: Expected data file: data/33369213973_9d9bb4cc96_c.txt
4: pjepg: Unknown marker ed at offset 00d4
4: pjepg: Unknown marker ee at offset 044e
4: Found 12 detections in image
4: Processing detection 0: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [0.710686, 0.599256, 3.266221]
4:     Rotation matrix:
4:       [-0.207956, -0.029180, 0.977703]
4:       [-0.022419, -0.999150, -0.034588]
4:       [0.977881, -0.029112, 0.207125]
4:     Reprojection error: 0.000016
4: Processing detection 1: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [0.201183, 0.468489, 3.328680]
4:     Rotation matrix:
4:       [-0.945215, -0.025393, -0.325459]
4:       [0.059868, -0.993545, -0.096354]
4:       [-0.320911, -0.110560, 0.940634]
4:     Reprojection error: 0.000008
4: Processing detection 2: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [0.405928, 0.507896, 3.313878]
4:     Rotation matrix:
4:       [-0.002863, -0.560277, -0.828301]
4:       [0.939356, -0.285559, 0.189910]
4:       [-0.342931, -0.777526, 0.527117]
4:     Reprojection error: 0.000009
4: Processing detection 3: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [0.825321, 0.581845, 3.123319]
4:     Rotation matrix:
4:       [-0.968081, -0.035874, -0.248056]
4:       [0.055725, -0.995739, -0.073471]
4:       [-0.244364, -0.084949, 0.965956]
4:     Reprojection error: 0.000002
4: Processing detection 4: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [1.684277, 0.874643, 2.936456]
4:     Rotation matrix:
4:       [-0.591858, 0.234414, 0.771203]
4:       [0.213342, -0.877098, 0.430330]
4:       [0.777296, 0.419224, 0.469107]
4:     Reprojection error: 0.000004
4: Processing detection 5: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [1.291416, 0.896268, 3.029800]
4:     Rotation matrix:
4:       [-0.113611, -0.982020, -0.150762]
4:       [0.944908, -0.153688, 0.289015]
4:       [-0.306989, -0.109621, 0.945379]
4:     Reprojection error: 0.000018
4: Processing detection 6: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [0.056100, 0.471899, 3.389936]
4:     Rotation matrix:
4:       [-0.414027, -0.017697, -0.910093]
4:       [-0.301250, -0.940807, 0.155341]
4:       [-0.858970, 0.338481, 0.384188]
4:     Reprojection error: 0.000018
4: Processing detection 7: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [-0.320347, 0.515690, 3.311711]
4:     Rotation matrix:
4:       [-0.873806, -0.037693, 0.484811]
4:       [-0.012344, -0.994951, -0.099604]
4:       [0.486118, -0.093019, 0.868929]
4:     Reprojection error: 0.000001
4: Processing detection 8: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [1.239740, 0.641412, 3.141994]
4:     Rotation matrix:
4:       [0.044581, -0.998907, -0.014080]
4:       [0.999000, 0.044528, 0.004058]
4:       [-0.003427, -0.014247, 0.999893]
4:     Reprojection error: 0.000029
4: Processing detection 9: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [0.537262, 0.495875, 3.234766]
4:     Rotation matrix:
4:       [-0.018687, 0.932853, -0.359773]
4:       [-0.996540, -0.046523, -0.068868]
4:       [-0.080981, 0.357241, 0.930495]
4:     Reprojection error: 0.000001
4: Processing detection 10: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [-0.790749, 0.445185, 3.526140]
4:     Rotation matrix:
4:       [-0.953131, -0.094452, -0.287438]
4:       [0.044792, -0.983605, 0.174685]
4:       [-0.299225, 0.153623, 0.941735]
4:     Reprojection error: 0.000003
4: Processing detection 11: tag ID 0
4:   Estimated pose for tag 0:
4:     Translation: [0.330360, 0.425262, 3.426656]
4:     Rotation matrix:
4:       [0.008245, -0.429718, -0.902926]
4:       [0.945234, -0.291286, 0.147259]
4:       [-0.326290, -0.854690, 0.403782]
4:     Reprojection error: 0.000003
4: 
4: Pose estimation test results:
4:   Successful pose estimations: 12/12
4:   All pose estimations successful!
4/6 Test #4: test_tag_pose_estimation_33369213973_9d9bb4cc96_c ...   Passed    0.04 sec

py interface log

Testing tag pose estimation with image: data/33369213973_9d9bb4cc96_c.jpg
Expected data file: data/33369213973_9d9bb4cc96_c.txt
Found 12 detections in image
Processing detection 0: tag ID 0
  Estimated pose for tag 0:
    Translation: [0.710680, 0.599250, 3.266195]
    Rotation matrix:
      [-0.207949, -0.029178, 0.977704]
      [-0.022431, -0.999150, -0.034589]
      [0.977883, -0.029123, 0.207117]
    Reprojection error: 0.000016
Processing detection 1: tag ID 0
  Estimated pose for tag 0:
    Translation: [0.201181, 0.468485, 3.328650]
    Rotation matrix:
      [-0.945208, -0.025381, -0.325482]
      [0.059872, -0.993541, -0.096394]
      [-0.320933, -0.110599, 0.940622]
    Reprojection error: 0.000008
Processing detection 2: tag ID 0
  Estimated pose for tag 0:
    Translation: [0.405931, 0.507899, 3.313901]
    Rotation matrix:
      [-0.002869, -0.560281, -0.828298]
      [0.939359, -0.285555, 0.189903]
      [-0.342924, -0.777524, 0.527124]
    Reprojection error: 0.000009
Processing detection 3: tag ID 0
  Estimated pose for tag 0:
    Translation: [0.825331, 0.581851, 3.123357]
    Rotation matrix:
      [-0.968087, -0.035868, -0.248036]
      [0.055715, -0.995740, -0.073463]
      [-0.244344, -0.084938, 0.965961]
    Reprojection error: 0.000002
Processing detection 4: tag ID 0
  Estimated pose for tag 0:
    Translation: [1.684279, 0.874643, 2.936459]
    Rotation matrix:
      [-0.591862, 0.234414, 0.771200]
      [0.213337, -0.877099, 0.430330]
      [0.777295, 0.419222, 0.469112]
    Reprojection error: 0.000004
Processing detection 5: tag ID 0
  Estimated pose for tag 0:
    Translation: [0.056100, 0.471898, 3.389929]
    Rotation matrix:
      [-0.414023, -0.017701, -0.910094]
      [-0.301244, -0.940809, 0.155342]
      [-0.858974, 0.338476, 0.384184]
    Reprojection error: 0.000018
Processing detection 6: tag ID 0
  Estimated pose for tag 0:
    Translation: [1.291420, 0.896272, 3.029811]
    Rotation matrix:
      [-0.113621, -0.982021, -0.150746]
      [0.944903, -0.153694, 0.289026]
      [-0.306999, -0.109601, 0.945378]
    Reprojection error: 0.000018
Processing detection 7: tag ID 0
  Estimated pose for tag 0:
    Translation: [-0.320347, 0.515691, 3.311718]
    Rotation matrix:
      [-0.873807, -0.037689, 0.484810]
      [-0.012350, -0.994950, -0.099607]
      [0.486116, -0.093025, 0.868929]
    Reprojection error: 0.000001
Processing detection 8: tag ID 0
  Estimated pose for tag 0:
    Translation: [0.537261, 0.495874, 3.234762]
    Rotation matrix:
      [-0.018686, 0.932851, -0.359776]
      [-0.996541, -0.046522, -0.068867]
      [-0.080980, 0.357245, 0.930494]
    Reprojection error: 0.000001
Processing detection 9: tag ID 0
  Estimated pose for tag 0:
    Translation: [1.239855, 0.641470, 3.142284]
    Rotation matrix:
      [0.044544, -0.998912, -0.013775]
      [0.999000, 0.044488, 0.004365]
      [-0.003747, -0.013956, 0.999896]
    Reprojection error: 0.000029
Processing detection 10: tag ID 0
  Estimated pose for tag 0:
    Translation: [-0.790749, 0.445186, 3.526144]
    Rotation matrix:
      [-0.953086, -0.094397, -0.287603]
      [0.044778, -0.983645, 0.174462]
      [-0.299368, 0.153399, 0.941726]
    Reprojection error: 0.000003
Processing detection 11: tag ID 0
  Estimated pose for tag 0:
    Translation: [0.330364, 0.425268, 3.426708]
    Rotation matrix:
      [0.008234, -0.429721, -0.902924]
      [0.945238, -0.291281, 0.147247]
      [-0.326279, -0.854690, 0.403790]
    Reprojection error: 0.000003

Pose estimation test results:
  Successful pose estimations: 12/12
  All pose estimations successful!

@christian-rauch

Copy link
Copy Markdown
Collaborator

Most of your files are missing a new line at the end (see the red symbol in the change overview). Can you add these?

@chibai

chibai commented Jan 7, 2026

Copy link
Copy Markdown
Author

Most of your files are missing a new line at the end (see the red symbol in the change overview). Can you add these?

Sure

/usr/bin/clang  -I/__w/apriltag/apriltag -I/apriltag -O3 -DNDEBUG -Wall -Wextra -Wpedantic -Wno-gnu-zero-variadic-macro-arguments -Wno-strict-prototypes -Wno-static-in-inline -Wno-shift-negative-value -Werror -MD -MT test/CMakeFiles/test_tag_pose_estimation.dir/test_tag_pose_estimation.c.o -MF test/CMakeFiles/test_tag_pose_estimation.dir/test_tag_pose_estimation.c.o.d -o test/CMakeFiles/test_tag_pose_estimation.dir/test_tag_pose_estimation.c.o -c /__w/apriltag/apriltag/test/test_tag_pose_estimation.c
/__w/apriltag/apriltag/test/test_tag_pose_estimation.c:209:2: error: no newline at end of file [-Werror,-Wnewline-eof]
}
 ^

I never used clang as compiler, this is a new knowledge for me

@chibai

chibai commented Jan 7, 2026

Copy link
Copy Markdown
Author

I checked "Allowing edits by maintainers"

If I make format or other minor problem again, please help me update

@christian-rauch

Copy link
Copy Markdown
Collaborator

I never used clang as compiler, this is a new knowledge for me

This is just the style check and independent of the compiler.

@christian-rauch

Copy link
Copy Markdown
Collaborator

I checked "Allowing edits by maintainers"

If I make format or other minor problem again, please help me update

I managed to squash your EOL fixup commits and push to your PR branch.

@christian-rauch christian-rauch merged commit 31b29af into AprilRobotics:master Jan 8, 2026
46 of 54 checks passed
@christian-rauch

Copy link
Copy Markdown
Collaborator

Thanks.

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

Successfully merging this pull request may close these issues.

2 participants