This repository contains the bare minimum code for simple pose estimation using ArUco markers in Python
- OpenCV
- Numpy
- Download the repository:
git clone https://github.com/Jshulgach/ArUco_Pose_Estimation.git cd ArUco_Pose_Estimation
- Install dependencies according to your OS:
It's best to install dependencies in a virtual environment. Using either Anaconda or Python venv, prepare your environment:
Install using the
python -m venv aruco python=3.10 call aruco\Scripts\activate pip install -r requirements.txt
apt install
command:sudo apt install python3-opencv python3-yaml
Make sure to have a checkerboard printed if you want to have accurate pose calibration. You can find a multitude of patterns from Mark Hedley Jones. Once you print out the one you like, make sure to update the calibration_settings.yaml
file with the correct dimensions of the squares on the checkerboard.
The files are named in the order of operations:
1_save_frames.py
: Used to save frames from the camera feed.2_calibrate.py
: Performs the calibration routine with a single camera, computes distortion matrix.3_main.py
: Detects ArUco markers in the camera feed.
You can find more details on parameters for each script using python my-script-to-run.py --help
. Ideally all of these should be run without much to change
-
Save Calibration Frames
Run
1_save_frames.py
to initialize the camera feed. Press the space bar when prompted to start collecting images of your checkerboard. Make sure to move the checkerboard around to get different poses and orientations.python 1_save_frames.py
-
Calibration
Run2_calibrate.py
to read the checkerboard images in your directory and generate acalibration_matrix.npy
anddistortion_coefficients.npy
file.python 2_calibrate.py
- Note: If you're connected to another device via ssh (like a raspberry pi) and need to transfer the
.npy
files, you can copy them to your local WSL environment with the command:For copying to your host windows maching:scp myusername@192.168.1.164:/home/myusername/github/ArUco_Pose_Estimation/distortion_coefficients.npy /home/myusername
scp myusername@192.168.1.164:/home/myusername/github/ArUco_Pose_Estimation/distortion_coefficients.npy /mnt/c/Users/WindowsUserName
- Note: If you're connected to another device via ssh (like a raspberry pi) and need to transfer the
-
Pose Estimation
Run3_main.py
to begin running the pose estimation for each ArUCo marker detected. This is done in real-time for each frame obtained from the webcam feed.python 3_main.py
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.
This repository is inspired by the work of GSNCodes