2、Augmented Reality

2、Augmented Reality2.1、Overview2.2、Application2.2.1、Start up launch2.2.2、Effect demonstration2.3、Code2.3.1、Algorithm principle2.3.2、Code

2.1、Overview

Augmented Reality ("AR"), is a technology that ingeniously integrates virtual information with the real world. It extensively uses a variety of technical means such as multimedia, 3D modeling, real-time tracking and registration, intelligent interaction, sensing, etc., to simulate and apply computer-generated text, images, 3D models, music, video and other virtual information to the real world. In order to achieve the "enhancement" of the real world.

The AR system has three outstanding features: ①The information integration of the real world and the virtual world; ②It has real-time interactivity; ③It adds and locates virtual objects in the 3D space.

2.2、Application

When using the AR case, you must have the camera's internal reference, otherwise it will not work.

 

2.2.1、Start up launch

Method 1

Method 2

This method can only be started in the successive main controllers that have been connected.

Set the parameters according to your needs, and you can also modify the launch file directly, you don't need to attach parameters when you start up.

 

2.2.2、Effect demonstration

A total of 12 effects.

 

image-20210902122726648

Press【F】key to switch between different effects.

image-20210906141251637

You can also switch effects through the command.

image-20210906141849036

image-20210906141829879

2.3、Code

2.3.1、Algorithm principle

Use the RANSAC scheme to find the object pose from the 3D-2D point correspondence.

The RanSaC algorithm is a classic algorithm for data processing. Its function is to extract specific components in an object under a large amount of noise. The following figure illustrates the effect of RanSaC algorithm. Some points in the figure obviously satisfy a certain straight line, and another group of points is pure noise. The purpose is to find a straight line equation in the presence of a lot of noise, at this time the amount of noise data is 3 times that of a straight line.

img

 

2.3.2、Code

launch file

python main function

More function:

https://docs.opencv.org/3.0-alpha/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html

We need to use cornerSubPix() to perform further optimization calculations on the detected corners, so that the accuracy of the corners can reach the sub-pixel level.

The RANSAC scheme is used to find the object pose from the 3D-2D point correspondence. This function estimates the pose of the object given a set of object points, their corresponding image projections, camera matrix and distortion coefficients. This function finds a pose that minimizes the re-projection error, that is, the re-observation error, that is, the sum of the squared distances between the observed pixel point projection imagePoints and the object projection (projectPoints()) objectPoints. The use of RANSAC can avoid the influence of outliers on the results.