This project uses OpenCV's ArUco module to detect markers in an image, calculate their positions, and determine the directional path between them. It simulates path planning based on the spatial relationship of detected ArUco markers.
Start β Finish: This image demonstrates a more complex path with left and right turns.
Start β Finish: This image illustrates a more straightforward path layout, with mainly rightward movement.
The code performs the following steps:
-
Read Image: Load an image using OpenCV from the provided path.
-
Detect ArUco Markers: Using
cv2.aruco.detectMarkers()
with theDICT_ARUCO_ORIGINAL
dictionary. -
Calculate Center: Compute the average of the 4 corners of each marker to find its center.
-
Build Path in XY Plane: Determine movement (
+x
,-x
,+y
,-y
) between consecutive marker centers. -
Convert to Directional Instructions: Based on movement between points:
F
= ForwardL
= LeftR
= RightE
= End
.
βββ A.png # First sample path image
βββ A1.png # Second sample path image
βββ path_detector.py # Main Python script
βββ README.md # Project documentation
- Python 3.x
- OpenCV with ArUco support
Install dependencies:
pip install opencv-python opencv-contrib-python
- Ensure markers are placed in the correct order for meaningful path detection.
- You can experiment with different ArUco dictionaries if needed (e.g., DICT_4X4_50).
- OpenCV β For computer vision capabilities
- ArUco β For marker detection algorithms
MIT License β free to use, modify, and distribute.