HartisanBUAA / Camereon-Model-Tracker

GNU General Public License v3.0
27 stars 4 forks source link


Camereon Model Tracker

Real-time 6-DOF pose tracking of rigid objects based on CAD models and monocular images

( English / 中文 )


Introduction

Theory

  This algorithm is used to calculate the 6-DOF pose, including translation and rotation, of a 3D object relative to a monocular camera in real time, which can be used in the fields of augmented reality, robotic grasping, and target tracking etc.. It is similar with VisionLib and Vuforia Model Target. The algorithm uses the CAD model of the target object to extract 3D edge features, and extracts 2D edge features in the RGB image acquired by the monocular camera, and then establish the correspondence between the 3D features and 2D features, so as to solve the object's pose.

Features

Demo

  Video

Scenes

  Based on the above principle, this algorithm is mainly applicable to (but not limited to) texture-less scenes that natively have CAD models, such as the industrial field. Meanwhile, given its dependence on edge features, the geometric structure of the object and the number of edges will have a certain impact on the tracking effect, so the model and parameter selection should follow suggestions from VisionLib or suggestions from Vuforia.

Implementation

  The author implemented the algorithm kernel using C++. Meanwhile, in order to make it easier to use, the author has also developed a Unity plugin based on the kernel. There are two versions of this plugin: ARFoundation version and MRTK version. The former is suitable for iOS/Android devices and the latter is suitable for Microsoft Hololens 2. Most features can also work based on the video stream from the native camera directly without relying on the ARFoundation, but ARFoundation can bring two benefits: 1. Fusion with SLAM can improve the stability of the pose and the ability of self-recovery; 2. ARFoundation provides camera intrinsics in real time without requiring the user to pre-calibrate the camera (especially those with Auto Focus).
  The plugin is currently a lab prototype version and has not been fully tested, there may be adaptation bugs on some devices. During the trial period, the algorithm kernel runs for 5 minutes from the time the program starts, and stops automatically after the timeout.

Preparation

Device Support

Software

Installation

Model Preparation

Usage

ARFoundation Version

Go to MRTK version

1. Import basic objects

  Delete the default Main Camera from the scene,and import AR Session and XR Origin through "Toolbar - GameObject - XR". There will be a new Main Camera under XR Origin.

basic components - arf

2. Import Camereon package

  Import Camereon.ModelTracker.ARFoundation-vx.x.x.unitypackage, there are three folders(Plugins、Scripts、Shaders)and one prefab (CMRModelTracker) in this package.
  NOTE: There is a known bug in unity that the Plugins folder does not contain the iOS framework library when exporting the unitypackage. Therefore, iOS users need to download the iOS framework zip from the Release page, unzip it and put the iOS folder into the Plugins folder. This bug is being fixed.

import package - arf

3. Import Camereon objects

  Add the prefab CMRModelTracker to the scene, the prefab contains:

4. Import CAD model

  Add the target's model to the scene, place it under CMR Camera as a son node, and adjust it's initial pose relative to the CMR Camera through the Transform component. This pose will be used in the initialization process, and the user should choose the appropriate pose based on the application scenario.
  Add the last Layer and name it "CMR", and set the Layer of both the CMR Camera and the model to "CMR". This is to avoid interfering with the main scene when performing background processing on the model.

add layer

5. Object settings

  The prefab CMRModelTracker should load the script CMRModelTrackerManager, which is under the Scripts folder. Connect the objects in the scene to the variables in the script as shown in the figure, where VLCar is the CAD model as an example.

cmr settings - arf

  The script CMRModelTrackerManager provides several setup options:

6. Project settings

7. Program interaction

  When the program starts running on the device, the camera is automatically turned on by ARFoundation and the video stream is displayed on the screen. When the Camereon tracker starts running (through API or "Auto Start" is checked in the script), the edge features of the target with the initial pose, which was set in "4. Import CAD model", will display on the screen. The user just need to move the device so that the edges are roughly aligned with the target object in the image, then the initialization will be completed and tracking begins. Successful initialization is manifested by the red edges disappearing or turning green, depending on whether "Display Edges" is checked in the script settings.

interaction - arf


MRTK Version

1. Import basic objects

  Delete the default Main Camera from the scene,and import MixedRealityToolkit, MixedRealitySceneContent and MixedRealityPlayspace through "Toolbar - MixedReality - Toolkit - Add to Scene and Configure". There will be a new Main Camera under MixedRealityPlayspace.

basic components - mrtk

2. Import Camereon package

  Import Camereon.ModelTracker.MRTK2-vx.x.x.unitypackage, there are three folders(Plugins、Scripts、Shaders)and one prefab (CMRModelTracker) in this package.

import package - mrtk

3. Import Camereon objects

  Add the prefab CMRModelTracker to the scene, the prefab contains:

4. Import CAD model

  Add the target's model to the scene, place it under CMR Camera as a son node, and adjust it's initial pose relative to the CMR Camera through the Transform component. This pose will be used in the initialization process, and the user should choose the appropriate pose (relative to eyes, not the PV camera) based on the application scenario.
  Add the last Layer and name it "CMR", and set the Layer of both the CMR Camera and the model to "CMR". This is to avoid interfering with the main scene when performing background processing on the model.

add layer

5. Object settings

  The prefab CMRModelTracker should load the script CMRModelTrackerManager, which is under the Scripts folder. Connect the objects in the scene to the variables in the script as shown in the figure, where VLCar is the CAD model as an example.

cmr settings - mrtk

  The script CMRModelTrackerManager provides several setup options:

6. Project settings

7. Program interaction

  When the Camereon tracker starts running (through API or "Auto Start" is checked in the script), the CAD model of the target with initial pose, which was set in "4. Import CAD model", will display in front of the user's eyes. The user just need to move his head so that the model is roughly aligned with the real target object, then the initialization will be completed (with some delays) and tracking begins. Successful initialization is manifested by the red model disappearing or turning green, depending on whether "Display Model" is checked in the script settings.

Public APIs

  To facilitate user control of the program logic, the CMRModelTrackerManager script provides some APIs for both the ARFoundation version and the MRTK version:

License

GPL v3

Contact Information

Hartisan@buaa.edu.cn
Github

(Top)