Augmented Reality: Video in Video using ArUco Markers with OpenCV
Augmented Reality: Video in Video using ArUco Markers with OpenCV

Augmented Reality (AR) allows seamless integration of virtual content into the real world. One of the exciting applications of AR is overlaying a video within another video dynamically. This is achieved using ArUco markers, which serve as reference points for transformation and perspective correction.

Concept

Using OpenCV and ArUco markers, we detect specific markers in a destination video and warp a source video onto the region defined by these markers. This enables realistic placement and tracking of the source video within the destination scene.

Implementation

Key Steps
  1. Detect ArUco Markers: The destination video is processed frame by frame to identify ArUco marker locations.
  2. Extract Reference Points: The four corners of the detected markers define the region where the source video will be projected.
  3. Homography Transformation: Using cv2.findHomography(), the source video is warped to fit within the marker-defined area.
  4. Blending Frames: The transformed video is overlaid onto the destination frame, creating a seamless AR effect.
Code Highlights
  • Detecting Markers: cv2.aruco.detectMarkers(frame, dictionary)
  • Finding Homography: cv2.findHomography(pts_src, pts_dst, cv2.RANSAC)
  • Applying Warping: cv2.warpPerspective(frame_src, h, (frame_dst.shape[1], frame_dst.shape[0]))
Example Use Case

A video of a horse race is projected onto a video of an office space containing ArUco markers. The markers define the placement area, and the video seamlessly integrates within the office video, adjusting dynamically with camera movement.

Potential Applications

  • Interactive Presentations: Embed supplementary videos dynamically.
  • Advertising: Overlay AR billboards in videos.
  • Education & Training: Enhance learning materials with interactive content.

This technique offers a powerful way to merge real and virtual worlds, creating immersive AR experiences with minimal hardware requirements. Try it out and elevate your AR projects!

Written by Dhawal Banker

More From This Category

New test

New test

This is with default editor and the old template of the Divi for Projects.

read more

This is new post with default editor

I've had the privilege of working on a diverse range of projects, spanning AR/VR experiences, Computer Vision solutions, AI integrations, and training programs. Explore a selection of my work below, showcasing my expertise and...

read more