ArUCo markers and Computer Vision for Localisation
This module was modified from ArUCo-Markers-Pose-Estimation-Generation-Python. The original license still applies to this code regardless of these modifications.
https://github.com/user-attachments/assets/f96c039b-bd86-4312-868f-6efccbbd9363
Purpose
The purpose of this module is to convert a video into an array of locations & timestamps like this:
[{"location": [108.404, -0.314, 172.88], "timestamp": "2025-09-13 17:59:31.348000"},
{"location": [108.378, -0.304, 172.877], "timestamp": "2025-09-13 17:59:31.414000"},
...
{"location": [109.216, -0.114, 173.852], "timestamp": "2025-09-13 18:00:02.558000"}]
Equipment Required
- a camera high-quality camera = more precision further away from camera
- a printed ArUCo tag
- a chessboard for calibration printed on paper or a real game board
Setup Repository
Create a virtual environment
Windows: python -m venv venv
Activate virtual environment
Windows: venv/Scripts/activate
Install dependencies
pip install -r requirements.txt
Setup Done, start localising below 🙃
Localisation Method
Step 0: Calibrate camera
This means to find out your current camera calibration including distortion (skew, round distortion) and intrinsic camera properties (focal length, principal point). The calibration output is two matrices which are saved as intrinsic_matrix.npy and distortion_coefficients.npy.
To calibrate your camera, do:
a. take a video of a chessboard
b. save the video under previously_calibrated_cameras
c. open calibrate_camera.py
d. adjust camera_filename, chessboard_size to match
e. run python calibrate_camera.py
Step 1: Place your camera
During localisation the camera needs to be fixed in the same place. It is ok if the target is moving. Notice where you place your camera i.e. what is the translation and rotation relative to a origin (e.g. corner of building). Adjust these variables in the measure_locations.py file:
camera_translation = [103.849, 0, 183.396] # in metres from origin
camera_rotation = [0, 90, 0]
camera = Camera(load_calibration_details_for_camera_name("My Smartphone Camera"),
camera_translation, camera_rotation)
Step 2: State your ArUCo tag
State how which type of ArUCo tag you printed out and how big it is in cm:
aruco_dict_type = "DICT_5X5_100"
aruco_marker_length = 15.9
If you don't have a ArUCo tag, use the following command to generate one and then print it out after:
python ./aruco_markers_computer_vision/generate_aruco_tags.py --id 24 --type DICT_5X5_100 --output tags/
Step 3: Record localisation video
Placing your calibrated camera in its correct spot, record a video and specify its location and when you started recording:
video_start_time = datetime(2025, 9, 18, 14, 55, 28)
video_file_path = f"./calculating_location/original_source_videos/{video_name}"
Step 4: Run python measure_locations.py
By default, the locations are output to calculating_location/output folder.
Notes
If you found this repository useful, take a look at and star ⭐️ the original repository.
Feel free to reach out to me or the original author:
Me - arnard76@gmail.com or ashe292@aucklanduni.ac.nz
Original Author - github.com/GSNCodes
Happy Learning! Keep chasing your dreams!
References
- https://docs.opencv.org/4.x/d9/d6d/tutorial_table_of_content_aruco.html
- https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html
Common Issues
OpenCV parse "warning"
Shows during pose estimation / measuring locations, but doesn't stop the actual thing from running so just wait patiently.
indoor-localisation-accuracy-testing\ArUCo-markers-cv-localisation-method\calculating_location\pose_estimation.py:96: RuntimeWarning: invalid value encountered in cast
imgpts = imgpts.reshape(-1, 2).astype(int)
OpenCV(4.12.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
OpenCV(4.12.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
OpenCV(4.12.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
OpenCV(4.12.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
OpenCV(4.12.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
OpenCV(4.12.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
OpenCV(4.12.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
OpenCV(4.12.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
> - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
Metadata
Release files for aruco-markers-cv-localisation-arnard76 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aruco_markers_cv_localisation_arnard76-0.0.6.tar.gz | 26.7 kB | Without provenance | Details for aruco_markers_cv_localisation_arnard76-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aruco_markers_cv_localisation_arnard76-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for aruco_markers_cv_localisation_arnard76-0.0.6-py3-none-any.whl |
Total release size: 56.7 kB
Release files / aruco_markers_cv_localisation_arnard76-0.0.6.tar.gz
| Download URL | aruco_markers_cv_localisation_arnard76-0.0.6.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ee3ad2f510786a75a2b62332e649c923d542ec0ce701df8c1ac1b061313864d
|
|
BLAKE2b-256 checksum How to use checksums |
9a6492f183f1800260309c4ed5ae7b4319d3300fc45be0747ea7e85cf7ad31da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.8
|
Release files / aruco_markers_cv_localisation_arnard76-0.0.6-py3-none-any.whl
| Download URL | aruco_markers_cv_localisation_arnard76-0.0.6-py3-none-any.whl |
|---|---|
| Size | 29.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ecfd8282ebc4281baa45d81a5ee966b3477269dc533cfcddb4e30392f0dcaa8a
|
|
BLAKE2b-256 checksum How to use checksums |
581e811d4e3a2bf6dfdad4db94aa8eb04818836a8b98e4f1f5d35da0271d214f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.8
|
Security for aruco-markers-cv-localisation-arnard76 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.