How krawal19/artag_detection_and_tracking works
Project type and purpose
• This is a command‐line, Python-based computer vision application rather than a client-server or full-stack web app.
• Purpose: take raw video(s) of fiducial AR tags, detect and track each tag, then superimpose either a 2D image (Lena) or a 3D cube onto the tag in every frame, producing annotated output videos.
File structure
• Top-level:
• data/ – raw input videos
• images_for_readme/ – static illustration images
• output/ – generated AVI files
• src/ – two entry scripts: cube.py (3D cube overlay) and lena.py (Lena overlay)
• LICENSE, README.md
• There are no sub-folders under src/, so the architecture is flat but conceptually modular: each script invokes a common tag‐processing pipeline plus its own overlay logic.
Key architectural insights from README
• Core pipeline stages:
A. Tag corner detection
B. Tag orientation detection
C. Tag ID detection
• Two distinct “post‐processing” branches:
• Superimpose Lena image via homography & masking
• Superimpose 3D cube via projection matrix & line drawing
• Dependencies: Python 3.5.4, OpenCV 4.1.1
Components
a. Main components (blocks):
1) Frame Reader (VideoCapture)
2) Tag Detection Module
– grayscale & threshold → contour extraction → quad approximation
3) Tag Orientation Module
– compute homography → warp to upright → detect orientation marker
4) Tag ID Module
– sample interior squares → decode bits → tag ID
5) Overlay Branch
• Lena Overlay: template image loader → homography → warp → mask → composite
6) Frame Writer (VideoWriter)
7) CLI Scripts: cube.py and lena.py invoke pipeline + branch
8) File I/O: data/ → input videos; output/ → result AVI files
9) External libraries: OpenCV
b. Relationships & data flow
• cube.py vs. lena.py both share steps 1–3 but fork at Overlay Branch
• File I/O connects the CLI scripts to data/ and output/
c. Architectural patterns & design principles
• Pipeline (linear sequence of transform stages)
• Strategy/branching for overlay logic (select one of two extensions)
• Single-responsibility: each module does one processing step
• Data-driven: video frames pass through stages in memory
d. Key technologies/frameworks
• Python 3.x
• OpenCV 4.x (Video I/O, image processing, homography, contour detection)
• NumPy (arrays, linear algebra) implicitly via OpenCV