Skip to content

IndoorNav: A web app for accurate indoor navigation using AprilTags and computer vision. Developed with web technologies and OpenCV.

Notifications You must be signed in to change notification settings

DonBoscoStudents/IndoorNav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

IndoorNav

AprilTags are a type of fiducial marker system used in computer vision applications to detect and track objects in a visual scene. They were developed by the April Robotics Laboratory at the University of Michigan in 2011 and have since become a popular tool in robotics, augmented reality, and other applications.

AprilTags are 2D barcodes that consist of a black border and a pattern of smaller black and white squares within the border. Each tag has a unique ID that can be easily detected and decoded by a computer vision system using simple algorithms.

Because of their high accuracy and low processing requirements, AprilTags are often used in real-time applications where fast and reliable detection and tracking are essential. They are particularly useful in robotics applications, where they can be used to localize and navigate robots, or in augmented reality applications, where they can be used to overlay digital content on top of real-world objects.

Yes, AprilTags can be used to estimate both the orientation and location of an object. When a camera captures an image of an AprilTag, the computer vision system can extract the tag's ID and use it to estimate the tag's pose, which consists of its position and orientation in 3D space relative to the camera.

AprilTags are designed to be highly detectable even at long distances and from varying angles, which makes them useful for estimating the pose of objects in a wide range of applications. In robotics, for example, they can be used to determine the position and orientation of a robot relative to a set of reference points, while in augmented reality applications, they can be used to track the position and orientation of a user's smartphone or tablet.

It's worth noting that the accuracy of the pose estimation using AprilTags can depend on various factors such as the quality of the camera used, the size of the tags, and the lighting conditions. However, with appropriate setup and calibration, AprilTags can provide accurate and reliable pose estimation for many applications.

Here are the general steps to create a web app that can access the camera of the device:

  1. Create an HTML file with a video element: The first step is to create an HTML file that includes a video element. The video element will be used to display the live stream from the camera.

  2. Add JavaScript code to access the camera: Next, you need to add JavaScript code to access the camera. This can be done using the getUserMedia() function, which is a built-in function in modern web browsers that allows web applications to access the camera and microphone.

  3. Request camera permissions: Before accessing the camera, the user needs to grant permission. You can request camera permissions by calling the navigator.mediaDevices.getUserMedia() function, which returns a Promise that resolves with a MediaStream object.

  4. Display the camera stream: Once you have access to the camera, you can display the live stream in the video element by setting the srcObject property of the video element to the MediaStream object.

  5. Add additional features: Finally, you can add additional features to your web app, such as taking photos or recording videos, by using the MediaStream API.

Here is an example code snippet that demonstrates how to access the camera and display the live stream in a video element:

<video id="videoElement"></video>

<script>
  // Request camera permissions
  navigator.mediaDevices.getUserMedia({ video: true })
    .then(function(stream) {
      // Display the live stream in the video element
      var videoElement = document.getElementById('videoElement');
      videoElement.srcObject = stream;
    })
    .catch(function(error) {
      console.error('Error accessing camera:', error);
    });
</script>

Note that the exact code and implementation details may vary depending on the specific web app you are creating and the web development framework you are using.

Implementing AprilTag detection in a web app can be done using a combination of client-side and server-side technologies. Here are the general steps:

  1. Include the AprilTag detection library: First, you need to include an AprilTag detection library in your web app. One popular library is apriltag.js, a JavaScript implementation of the AprilTag detection algorithm.

  2. Capture camera frames: To detect AprilTags in real-time, you need to capture frames from the device's camera. You can use the getUserMedia() function to access the camera and capture frames in a canvas element.

  3. Convert frames to grayscale: AprilTag detection works best on grayscale images. Therefore, you need to convert the captured frames to grayscale using a library such as opencv.js or p5.js.

  4. Process frames with the AprilTag library: Once the frames are in grayscale, you can use the AprilTag detection library to process them and detect any tags in the image. The apriltag.js library provides a function detect() that takes in a grayscale image and returns an array of detected tags.

  5. Display the results: Finally, you can display the detected AprilTags in the video stream or display their position and orientation in a separate overlay or UI element.

Here is an example code snippet that demonstrates how to detect AprilTags in real-time using apriltag.js:

<video id="videoElement"></video>
<canvas id="canvasElement"></canvas>

<script src="apriltag.js"></script>

<script>
  // Request camera permissions
  navigator.mediaDevices.getUserMedia({ video: true })
    .then(function(stream) {
      // Display the live stream in the video element
      var videoElement = document.getElementById('videoElement');
      videoElement.srcObject = stream;
      
      // Capture frames and detect AprilTags
      var canvasElement = document.getElementById('canvasElement');
      var ctx = canvasElement.getContext('2d');
      
      setInterval(function() {
        // Capture a frame and convert to grayscale
        ctx.drawImage(videoElement, 0, 0, canvasElement.width, canvasElement.height);
        var imageData = ctx.getImageData(0, 0, canvasElement.width, canvasElement.height);
        var grayImageData = convertToGrayscale(imageData);
        
        // Detect AprilTags in the grayscale image
        var tags = detectAprilTags(grayImageData);
        
        // Display the detected tags
        displayTags(tags);
      }, 100);
    })
    .catch(function(error) {
      console.error('Error accessing camera:', error);
    });
    
  function convertToGrayscale(imageData) {
    // Use opencv.js to convert to grayscale
    // ...
    return grayImageData;
  }
  
  function detectAprilTags(grayImageData) {
    // Use apriltag.js to detect tags in the grayscale image
    var tags = apriltag.detect(grayImageData);
    return tags;
  }
  
  function displayTags(tags) {
    // Display the detected tags in the video stream or overlay
    // ...
  }
</script>

Note that this is a simplified example and may require additional optimization and error handling depending on your specific use case. Additionally, you may need to consider the performance and compatibility of the various libraries and technologies used in your web app.

Thank you for sharing more details about your idea. It sounds like an interesting project that involves using computer vision techniques for indoor navigation.

With the steps I provided earlier, you should be able to capture camera frames, convert them to grayscale, detect AprilTags, and display the results to the user in real-time. To use AprilTags for indoor navigation, you can assign each tag a unique identifier and pre-define their locations within the indoor environment. Then, as the user moves around and the app detects the AprilTags, it can use the detected IDs and locations to estimate the user's position and orientation relative to the predefined tag locations.

It is worth noting that AprilTag detection can be affected by factors such as lighting conditions, camera quality, tag size and orientation, and the presence of occlusions or other objects in the environment. Therefore, you may need to perform additional testing and optimization to ensure accurate and reliable detection.

In addition, you may also need to consider the user interface design and how the indoor navigation information is presented to the user. For example, you could use a map or augmented reality display to show the user's location and nearby points of interest.

I hope this helps you with your project. Good luck with your development!

About

IndoorNav: A web app for accurate indoor navigation using AprilTags and computer vision. Developed with web technologies and OpenCV.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published