docs/solutions/instant_motion_tracking.md
{: .no_toc }
<details close markdown="block"> <summary> Table of contents </summary> {: .text-delta } 1. TOC {:toc} </details> ---Attention: Thank you for your interest in MediaPipe Solutions. We have ended support for this MediaPipe Legacy Solution as of March 1, 2023. For more information, see the MediaPipe Solutions site.
Augmented Reality (AR) technology creates fun, engaging, and immersive user experiences. The ability to perform AR tracking across devices and platforms, without initialization, remains important to power AR applications at scale.
MediaPipe Instant Motion Tracking provides AR tracking across devices and platforms without initialization or calibration. It is built upon the MediaPipe Box Tracking solution. With Instant Motion Tracking, you can easily place virtual 2D and 3D content on static or moving surfaces, allowing them to seamlessly interact with the real-world environment.
| Fig 1. Instant Motion Tracking is used to augment the world with a 3D sticker. |
The Instant Motion Tracking pipeline is implemented as a MediaPipe graph, which internally utilizes a RegionTrackingSubgraph in order to perform anchor tracking for each individual 3D sticker.
We first use a StickerManagerCalculator to prepare the individual sticker data for the rest of the application. This information is then sent to the RegionTrackingSubgraph that performs 3D region tracking for sticker placement and rendering. Once acquired, our tracked sticker regions are sent with user transformations (i.e. gestures from the user to rotate and zoom the sticker) and IMU data to the MatricesManagerCalculator, which turns all our sticker transformation data into a set of model matrices. This data is handled directly by our GlAnimationOverlayCalculator as an input stream, which will render the provided texture and object file using our matrix specifications. The output of GlAnimationOverlayCalculator is a video stream depicting the virtual 3D content rendered on top of the real world, creating immersive AR experiences for users.
With the Instant Motion Tracking MediaPipe graph, an application can create an interactive and realistic AR experience by specifying the required input streams, side packets, and output streams. The input streams are the following:
Side packets are also an integral part of the Instant Motion Tracking solution to provide device-specific information for the rendering system:
The rendering system for the Instant Motion Tracking is powered by OpenGL. For more information regarding the structure of model matrices and OpenGL rendering, please visit OpenGL Wiki. With the specifications above, the Instant Motion Tracking capabilities can be adapted to any device that is able to run the MediaPipe framework with a working IMU system and connected camera.
Please first see general instructions for Android on how to build MediaPipe examples.
Graph: mediapipe/graphs/instant_motion_tracking/instant_motion_tracking.pbtxt
Android target (or download prebuilt ARM64 APK):
mediapipe/examples/android/src/java/com/google/mediapipe/apps/instantmotiontracking:instantmotiontracking
Assets rendered by the GlAnimationOverlayCalculator must be preprocessed into an OpenGL-ready custom .uuu format. This can be done for user assets as follows:
First run
shell./mediapipe/graphs/object_detection_3d/obj_parser/obj_cleanup.sh [INPUT_DIR] [INTERMEDIATE_OUTPUT_DIR]and then run
buildbazel run -c opt mediapipe/graphs/object_detection_3d/obj_parser:ObjParser -- input_dir=[INTERMEDIATE_OUTPUT_DIR] output_dir=[OUTPUT_DIR]INPUT_DIR should be the folder with initial asset .obj files to be processed, and OUTPUT_DIR is the folder where the processed asset .uuu file will be placed.
Note: ObjParser combines all .obj files found in the given directory into a single .uuu animation file, using the order given by sorting the filenames alphanumerically. Also the ObjParser directory inputs must be given as absolute paths, not relative paths. See parser utility library at
mediapipe/graphs/object_detection_3d/obj_parser/for more details.