Giter Club home page Giter Club logo

aruco-markers-pose-estimation-generation-python's Introduction

ArUCo-Markers-Pose-Estimation-Generation-Python

This repository contains all the code you need to generate an ArucoTag, detect ArucoTags in images and videos, and then use the detected tags to estimate the pose of the object. In addition to this, I have also included the code required to obtain the calibration matrix for your camera.

1. ArUCo Marker Generation

The file generate_aruco_tags.py contains the code for ArUCo Marker Generation. You need to specify the type of marker you want to generate.

The command for running is :-
python generate_aruco_tags.py --id 24 --type DICT_5X5_100 --output tags/

You can find more details on other parameters using python generate_aruco_tags.py --help

2. ArUCo Marker Detection

The files detect_aruco_images.py and detect_aruco_video.py contains the code for detecting ArUCo Markers in images and videos respectively. You need to specify the path to the image or video file and the type of marker you want to detect.

The command for running is :-
For inference on images
python detect_aruco_images.py --image Images/test_image_1.png --type DICT_5X5_100
For inference using webcam feed
python detect_aruco_video.py --type DICT_5X5_100 --camera True
For inference using video file
python detect_aruco_video.py --type DICT_5X5_100 --camera False --video test_video.mp4

You can find more details on other parameters using python detect_aruco_images.py --help and python detect_aruco_video.py --help

3. Calibration

The file calibration.py contains the code necessary for calibrating your camera. This step has several pre-requisites. You need to have a folder containing a set of checkerboard images taken using your camera. Make sure that these checkerboard images are of different poses and orientation. You need to provide the path to this directory and the size of the square in metres. You can also change the shape of the checkerboard pattern using the parameters given. Make sure this matches with your checkerboard pattern. This code will generate two numpy files calibration_matrix.npy and distortion_coefficients.npy. These files are required to execute the next step that involves pose estimation. Note that the calibration and distortion numpy files given in my repository is obtained specifically for my camera and might not work well for yours.

The command for running is :-
python calibration.py --dir calibration_checkerboard/ --square_size 0.024

You can find more details on other parameters using python calibration.py --help

4. Pose Estimation

The file pose_estimation.py contains the code that performs pose estimation after detecting the ArUCo markers. This is done in real-time for each frame obtained from the web-cam feed. You need to specify the path to the camera calibration matrix and distortion coefficients obtained from the previous step as well as the type for ArUCo marker you want to detect. Note that this code could be easily modified to perform pose estimation on images and video files.

The command for running is :-
python pose_estimation.py --K_Matrix calibration_matrix.npy --D_Coeff distortion_coefficients.npy --type DICT_5X5_100

You can find more details on other parameters using python pose_estimation.py --help

Output

Notes

The utils.py contains the ArUCo Markers dictionary and the other utility function to display the detected markers.

Feel free to reach out to me in case of any issues.
If you find this repo useful in any way please do star โญ๏ธ it so that others can reap it's benefits as well.

Happy Learning! Keep chasing your dreams!

References

  1. https://docs.opencv.org/4.x/d9/d6d/tutorial_table_of_content_aruco.html
  2. https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html

aruco-markers-pose-estimation-generation-python's People

Contributors

gsncodes avatar isevendays avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

aruco-markers-pose-estimation-generation-python's Issues

version problems

Hello!
May I ask what's your Python and Opencv version? Your code seems incompatible to the newest.

Algorithm

Hello! I would like to clarify which algorithm you used (formulas, description of the algorithm), what error does it give for coordinate values?

Pose Estimation Error

First: Thank you for the great write up. I am having one issue however.

my command:
python pose_estimation.py --K_Matrix /home/hybsys/Desktop/ArUCo-Markers-Pose-Estimation-Generation-Python-main/calibration_matrix.npy --D_Coeff /home/hybsys/Desktop/ArUCo-Markers-Pose-Estimation-Generation-Python-main/distortion_coefficients.npy --type DICT_5X5_100

my error:
Traceback (most recent call last):
File "/home/hybsys/Desktop/ArUCo-Markers-Pose-Estimation-Generation-Python-main/pose_estimation.py", line 78, in
output = pose_esitmation(frame, aruco_dict_type, k, d)
File "/home/hybsys/Desktop/ArUCo-Markers-Pose-Estimation-Generation-Python-main/pose_estimation.py", line 31, in pose_esitmation
corners, ids, rejected_img_points = cv2.aruco.detectMarkers(gray, cv2.aruco_dict,parameters=parameters,
cv2.error: OpenCV(4.6.0) ๐Ÿ‘Ž error: (-5:Bad argument) in function 'detectMarkers'

Overload resolution failed:

  • 'cameraMatrix' is an invalid keyword argument for detectMarkers()
  • 'cameraMatrix' is an invalid keyword argument for detectMarkers()

Any thoughts would be greatly appreciated, thank you.

calibration error

trying to calibrate my camera i have this message
Traceback (most recent call last):
File "/home/luca/Downloads/ArUCo-Markers-Pose-Estimation-Generation-Python-main/calibration.py", line 79, in
ret, mtx, dist, rvecs, tvecs = calibrate(dirpath, square_size, visualize=visualize, width=width, height=height)
File "/home/luca/Downloads/ArUCo-Markers-Pose-Estimation-Generation-Python-main/calibration.py", line 52, in calibrate
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)
cv2.error: OpenCV(4.5.1) ../modules/calib3d/src/calibration.cpp:3694: error: (-215:Assertion failed) nimages > 0 in function 'calibrateCameraRO'

i have 10 images in subfolder pose and i use this command
python3 calibration.py --dir pose/ --square_size 0.049

thanks
L

Calibration not working for fisheye camera

Hi, I was trying to use this repository for a project. I'm using a fisheye camera and have collected about 28 images in a folder called calib. For some reason running the calibration file does not work for me.
I get the following error, can someone help to identify what this means?

Traceback (most recent call last):
  File "calibration.py", line 102, in <module>
    ret, mtx, dist, rvecs, tvecs = calibrate(
  File "calibration.py", line 51, in calibrate
    ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(
cv2.error: OpenCV(4.2.0) ../modules/calib3d/src/calibration.cpp:3681: error: (-215:Assertion failed) nimages > 0 in function 'calibrateCameraRO'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.