This project is a simple augmented reality (AR) web application that uses AR.js and A-Frame to display a 3D object (a yellow cylinder) when a specific barcode marker is detected using the device's webcam.
Features:
- Barcode Marker Detection: The application uses a 4x4 matrix barcode (similar to QR codes) with a specific value (165) to detect and display the AR object.
- 3D Object Rendering: When the barcode marker is recognized, a yellow cylinder is rendered above the marker.
- Webcam Integration: Uses the device’s webcam to capture and process the marker in real-time.
- Responsive Design: The application is optimized for various screen sizes and ensures the AR experience is smooth by disabling UI debug elements.
To run the application:
- Clone or Download the repository containing this HTML file.
- Open the HTML file in a browser with webcam permissions enabled (best viewed using a mobile browser or a desktop browser with a webcam).
- Point the webcam at a barcode marker with the value 165 to see the 3D yellow cylinder appear.
Technologies Used
- HTML & JavaScript: Basic HTML structure with JavaScript libraries for AR and 3D rendering.
- A-Frame: A framework for building 3D and AR/VR experiences directly in HTML.
- AR.js: A library built on top of A-Frame that provides AR functionality.
- aframe-extras: An extension library for A-Frame to handle various utilities like loaders and physics.
Libraries Included:
- A-Frame v0.9.0
- AR.js for A-Frame
- aframe-extras Loaders
- AR.js Configuration
The AR.js script is configured to:
- sourceType: Webcam - It uses the device's webcam for AR detection.
- detectionMode: mono_and_matrix - Supports both traditional markers and matrix barcode markers.
- matrixCodeType: 4x4 - The marker used is a 4x4 barcode type.
Usage Notes: Ensure that you grant your browser permission to access the webcam. This project works best with barcode markers generated for the 4x4 matrix code type. The value used here is 165. If the 3D object does not appear, check the lighting conditions and ensure the barcode is clearly visible to the camera. Customization Change Marker Value: Modify the value attribute of the element to use a different barcode marker. Change 3D Object: Replace with any other A-Frame primitive (e.g., , ) or a 3D model using the tag.