## current position：Home>ORB-SLAM3 Algorithm Learning—Frame Construction—ORB Feature Extraction and BRIEF Descriptor Calculation

# ORB-SLAM3 Algorithm Learning—Frame Construction—ORB Feature Extraction and BRIEF Descriptor Calculation

2022-11-24 22:51:43【I am a happy little party dish】

### 文章目录

# 0总述

Characteristics of the detector realizing function：`ORBextractor.cc->ORBextractor::operator()`

输入一张图像,Returns the store feature pointsvector向量,Store description the sonmat,特征点数量,Steps are roughly divided into the following4步

- 构建图像金字塔
- 提取FastFeature points and useOctTreeHomogenization distribution
- 利用灰度质心法,计算特征点角度
- Calculation with rotation invariance isrBRIEF描述子

# 参数设置

Detector constructor：`ORBextractor.cc->ORBextractor::ORBextractor()`

Role is set related parameters of the characteristics of the detector,Mainly feature points extraction cap on the number and the related parameters in the image pyramid,These parameters according to theORB-SLAM3的配置文件设置,Generally do not need to change`mvScaleFactor:`

To hold each layer of the scale of the image pyramid information,The scale factor of each layer are made of a layer of scale*缩放因子,At the bottom of the scale as1`mvLevelSigma2:`

To hold the square of each layer pyramid image scale factor`mvInvScaleFactor`

、`mvInvLevelSigma2`

The reciprocal of storing the scale information,方便计算`mvImagePyramid`

:To hold each layer pyramid images,Size of the pyramid layers`mnFeaturesPerLevel`

: Record each layer pyramid images can detect the number of the biggest characteristic,Number of feature points between each layer satisfy geometric relationship,According to the configuration file setting the maximum number of feature points can be calculated according to the geometric relationship between each layer can detect the number of feature points

# 1.构建图像金字塔,Each layer of the pyramid image deposited in the member variablesmvImagePyramid

函数：`ORBextractor::ComputePyramid(cv::Mat image)`

比较简单,According to the scale of information to calculate the width and height of each layer of pyramid images,然后`resize`

放到vector容器里

# 2. 提取FastFeature points and useOctTreeHomogenization distribution

## 2.1 特征点提取

使用的是cv自带的fastCorner extraction function`cv::FAST(...)`

,But here the author set up a strict time threshold`iniThFAST(20)`

And a loose threshold`minThFAST(7)`

This calculation is the center pixel with a circle around the pixel gray value differences,Less than the threshold think gray feature point is not same,That is greater than that with different characteristics point

## 2.2 Characteristics of uniformity distribution

参考链接:https://zhuanlan.zhihu.com/p/61738607

核心函数：`ORBextractor.cc->ORBextractor::ComputeKeyPointsOctTree()->DistributeOctTree()`

- Number should be retained first calculate each layer of the pyramid image feature points
- Secondly, based on quadtree principle,Choose best response for each layer image feature points and ensure the uniform distribution of feature points

**1.Number should be retained first calculate each layer of the pyramid image feature points**

**基本原理：** Now the number of known need to extract the feature points of each image,The area of each layer of the image pyramid,Can calculate a pyramid image number of feature points and the area of unit area.After according to each layer of the pyramid in proportion to the total area of the image and the calculation number should assign each layer image feature points(吐槽：Feeling is a geometric sequence,Ratio is the proportion between two layer image area that the square of the scale factor)

**具体实现：**

我们假设第0层图像的宽为`W`

,长为`L`

,缩放因子为`s`

（这里的 `0<s<1`

）.The whole pyramid total area`S`

为

那么,The number of feature points per unit area as`N/S`

那么,第0Layer should be allocated for the number of feature points

Then so,推出了第`α`

Layer should be allocated for the number of feature points

**2.Secondly, based on quadtree principle,Choose best response for each layer image feature points and ensure the uniform distribution of feature points**

- 如果图片的宽度比较宽,就先把分成左右w/h份.一般的640×480的图像
- At the start of the only onenode.
- 如果node里面的点数>1,把每个node分成四个node,如果node里面的特征点为空,就不要了,删掉.
- 新分的node的点数>1,就再分裂成4个node.
- 如此,一直分裂.终止条件为：node的总数量> N_a,或者无法再进行分裂.然后从每个node里面选择一个质量最好的FAST点

**图示：Assume a certain layer image feature pointsN=25****Step1:只有1个node****Step2:第一次分裂**

(1)1个node分裂为4个node

(2)node数量4<25,Continue to split

**Step3:第二次分裂**

(1)4个node分裂成15个node,因为其中一个nodeThere is no point so remove thenode

(2)node数量16<25,Continue to split

**Step4:The third division**

(1)15个node分裂为30个node,Deleted without feature pointsnode

(2)node数量30>25,停止分裂

**Step5:从每个nodeSelect the response value of one of the biggest point**

# 3.利用灰度质心法,计算旋转角度

参考链接:https://zhuanlan.zhihu.com/p/61738607

ORBComputing Angle is simple,First of all a circular area of gray centroid,Connect centroid and the center of the circle to form a vector,The vector Angle is the Angle of the angular point.

图像来自：https://zhuanlan.zhihu.com/p/355441452

Circle circle is`fast`

特征点,圆的半径取为`15`

,因为整个patchGenerally take is`31×31`

的.

Gray centroid can be calculated by the following formula：

The Angle of：

至此,Not only to extractFAST角点,Also find out the Angle of the Angle point.This Angle can be used to guide describes the extraction of child,Ensure every time calculation descriptor in the same direction,Realize the Angle invariance.

这就是`Oriented FAST`

.

# 4.计算旋转后的BRIEF描述子

## 4.1 BRIEF描述子

BRIEFThe description of the is a binary sub,计算和匹配的速度都很快.计算步骤如下：

以关键点为中心,选择一个31×31的像素块

In this block according to certain methods selectionN对点,N一般取256,The method here is generally through early learning effect is the best choice256个位置

对于点对{A,B},By comparing the gray size of these two points determine a binary results,0或者1.

这样把256Points to the results of the row,就形成了BRIEF描述子.

`[1 0 1 0 0 ... 1 0 0]`

BRIEFThe matching of using hamming distance,非常快,Simple said is have a look at how many different digits.The following two descriptor,不同的位数为4.In fact we selected points of logarithm to256,Then distance scope is0~256.`[1 0 1 1 1 0]`

`[1 1 0 0 1 1]`

## 4.2 rBRIEF

**思想简述：** The direction of the feature points or whether to calculate the descriptor in the direction of the,The ultimate purpose is in order to more accurately match the corresponding feature points in two images,The basis of a match is in the judgement by describing the son.Two feature points around the smaller pixel information distribution differ,The less the descriptor distance,Two feature points aregoodMatch的可能性就越高.

这样,Determine whether two feature points matching problem is converted into computing feature points around the pixel distribution difference problem,And then again into the surrounding pixels of selection and the design of this kind of difference calculation.

对于BRIEFDescribe the child is,Calculation is calculating hamming distance,Point to the choice of the above mentioned also use learning method to carry on the design,现在就剩下一个问题了,**How to determine the feature points involved with the pixels around** .

BRIEF把关键点"周围像素"Become a pixel is fast`patch`

,If you don't consider rotating chosepatch就简单了,Direct pixel coordinates with feature points as the center,Choose the length and width of fixed a`patch`

就可以了,如下图所示.

但是存在一个问题,As the camera movement,特征点在x方向和yChange direction of the pixels on the,This selection of pixel in the image block will happen very big change,As above`PATCH1`

和`PATCH2`

,If take the two pixels fast to calculate distance to delineate the son,There must be a big difference.

基于这一现象,rBRIEFOn the basis of original increased rotary information,When the image rotation occurs,Feature points must occur in the direction of the spin,Select the image block scope also gave him a whole a spin,就变成了下图所示,使用`PATCH1’`

The pixels and`PATCH2`

The pixel to compare.

BRIEFRotation invariance principle is roughly such,下面看一下具体的实现.

BRIEFDescriptor is not consider rotating invariance,rBRIEF根据Oriented FASTCalculate the Angle of the,把原始的256The coordinates of a point to rotate after,In gray.So as to realize the rotation invariance.

原始的256A point to coordinate as`S`

,旋转后的为`S_θ`

具体实现代码：

```
// At the end of the feature extraction,会在computeOrientationFunction of calculating the Angle of the characteristic points
float angle = (float)kpt.angle*factorPI;// 将角度转换为弧度
float a = (float)cos(angle), b = (float)sin(angle);// Computing cosine and sine value
// 和之前一样,Here for the pixel feature point is a pointer to theuchar类型的指针,Is not the feature points corresponding pixel gray value,需要注意
// 如果把imgThe address-of operator in front of the&去掉,Access is the position corresponding to the grey value of the
// In other words is tocenterIndexes, to get the value of the other elements,This is feature in the macro definition under the
const uchar* center = &img.at<uchar>(cvRound(kpt.pt.y), cvRound(kpt.pt.x));
// 这里的step是Mat的属性之一,Said of a data byte length,Skip the specified step when convenient later iterations
// For example, a single channel grayscale image pixel values in my bytes is here700,而RGBThe length of the image a pixel is2100
const int step = (int)img.step;
// 这里定义了一个宏,Used in subsequent calculations easy
// 这里的center就是上面获取的uchar的指针,而pattern就是传入的参数
// It a long list of are in the calculation of index,而对centerTake the index is the index to get(位置)所对应的灰度值
// Random spot setx轴方向,Rotate to the direction of feature points
#define GET_VALUE(idx) \ center[cvRound(pattern[idx].x*b + pattern[idx].y*a)*step + \ cvRound(pattern[idx].x*a - pattern[idx].y*b)]
```

Need to compute the pixel position of the corresponding relations between before and after the rotation as shown in the figure below,The pixel coordinates spins a feature point the direction.

符号说明：

```
-θ:The key point of
-φ：Pixel block of a pixel before spinning withx轴夹角
-r:Pixel block the distance to the origin
-p(x,y):Before rotating pixel coordinates
-p'(x,y):After rotating pixel coordinates
```

Now became known`θ,p(x,y)`

求`p'(x,y)`

,推导公式如下：

以上就是ORB-SLAM3Image frame structure in the process of feature points extraction and the content of the descriptor computation part.

copyright notice

author[I am a happy little party dish],Please bring the original link to reprint, thank you.

https://en.cdmana.com/2022/328/202211242242405571.html

## The sidebar is recommended

- The configuration in the idea starts the web project through tomcat
- Optimal way to position wireless sensor nodes based on particle swarm optimization algorithm to mitigate coverage holes due to any energy depleted nodes Attached Matlab code
- Solving single-objective optimization problems (DDCS) based on dynamic control cuckoo algorithm with matlab code
- Solving simple scheduling problems based on leapfrog algorithm with matlab code
- Multi-objective cuckoo (MOCS) optimization algorithm with Matlab code
- Hot spots丨"Chinese elements" appear in the World Cup
- [Mysql] mysql lock waits for Lock wait timeout exceeded; try restarting transaction
- [SpringBoot] The SpringBoot @Value annotation cannot introduce the correct solution to the value in the configuration file
- [JAVA] Good code style in Java
- [JAVA] Two ways to read configuration files: ResourceBundle and Properties

## guess what you like

[JAVA] springboot multi-environment packaging

Springboot interceptor injection failure leads to cross-domain

Gateway encryption and decryption occasionally HTTP method names must be tokensConnection prematurely closed BEFORE response problem

Install QT5 on ubuntu18.04

[JAVA] logback log

Let’s briefly summarize the daily tasks of a MySQL DBA in a day;

[JAVA] Quartz timing tasks, automatic expiration, automatic shutdown, etc., integrate Springboot

[JAVA] Maven profiles control multi-environment data source log packaging

[JAVA] idea mac Jar package build method and Maven method

【JAVA】JWT token verification code

## Random recommended

- How to completely uninstall idea on Mac (can be reinstalled and cracked)
- [JAVA] Use Hikari connection pool in springBoot
- [LINUX] About database, nginx, zookeeper, kafka, Jar package, tomcat startup method
- [Springboot] SpringBoot cannot read static files after printing the Jar package, showing that the file does not exist
- 【JAVA】idea hot deployment, background automatically update code spring, springboot
- Voice Home invites you to participate in WAIC 2022 World Artificial Intelligence Conference
- SVM algorithm (2)
- MySQL database: 6. Overview and syntax of constraints
- Ensemble Learning Algorithm
- Naive Bayes Algorithm (1)
- Mobile Development - Responsive
- Summary of Docker commands
- m Matlab simulation of wireless image transmission based on QPSK modulation and demodulation, including modules such as spread spectrum despread equalization
- Common memory leaks in Android - [problem analysis + solution]
- JavaScript development tool WebStorm introductory tutorial: start running WebStorm (1)
- C++ Chinese Weekly Issue 88
- C++ Chinese Weekly Issue 89
- MetaElfLand, which integrates World Cup + GameFi elements, launched a special event for the World Cup
- m Based on OFDM system, compare SC algorithm, Minn algorithm, PARK algorithm synchronization performance matlab simulation analysis
- In the idea, the code is pushed to gitee_github through ssh to report an error
- Solve the problem of MySQL database executing Update stuck
- How to distinguish and define DQL DML DDL and DCL in SQL
- View the public network IP address under the Linux server
- The long article finishes the summary of MySQL common statements and commands in one go
- Custom persistence layer framework MyORMFramework (1) - JDBC analysis and solutions
- What is the order in which SQL statements are executed?
- bios memory training
- Matlab simulation of channel capacity based on power allocation and subcarrier pairing algorithm in m-diversity 2-hop OFDM system
- Getting Started with Spring Boot
- RocketMq: list of response codes, code=11
- Vue routing the true way
- What exactly does byte & 0xff do in Java?
- Power button (LeetCode) 65. Significant figures (c + +)
- [C language] The structure struct that must be learned before learning the data structure is detailed
- What about the commission less stock open an account?Comprehensive analytical!
- Hive sql grouping function grouping sets
- The general process of modifying the mailbox, mobile phone number and other processes in Vue, the verification code is generated and verified by redis on the back end (version 1.0)
- [K8S core architecture principle]
- Vue+SpringBoot+ElementUi+mybatis-plus implements user information modification and simulated recharge
- 【github pages】: build a github pages under windows, update the blog in real time