2、Opencv application

2.1、Overview

OpenCV is a cross-platform computer vision and machine learning software library based on the BSD license (open source) that can run on Linux, Windows, Android and MacOS operating systems.

2.2、QR code

2.2.1、Introduction to QR Code

QR code is a type of two-dimensional barcode. It not only has large information capacity, high reliability, and low cost, but it can also express a variety of text information such as Chinese characters and images. It has strong confidentiality and anti-counterfeiting and is very convenient to use.

2.2.2、Structure of QR code

PcitureParsing
imgPositioning markings: Indicate the direction of the QR code.
imgAlignment markings: If the QR code is large, these additional elements help positioning.
imgTiming pattern: Through these lines, the scanner can identify the size of the matrix
imgVersion information: The version number of the QR code being used. There are currently 40 different version numbers of the QR code.
imgFormat information: The format mode contains information about fault tolerance and data mask mode, and makes it easier to scan the code.
imgData and error correction keys: These modes save actual data.
imgQuiet zone: This area is very important to the scanner, and its role is to separate itself from the surroundings.

2.2.3、Features of QR codes

The data value in the QR code contains repeated information (redundant value).

2.2.4、QR code creation and recognition

Code path:~/astra_ws/src/astra_visual/qrcode

Install

Create a qrcode object

qrcode QR code to add logo

Note: When using Chinese, Chinese characters need to be added

image-20210901153136251

Note: Because video0-7 of RDK-X3 is occupied, and the newly connected camera is device video8, so we need to modify the camera port number called in the QRcode_Parsing.py code.

After modification

image-20210901152557779

After modification

image-20210901152557779

2.3、Human body pose estimation

Path code:~/astra_ws/src/astra_visual/detection

2.3.1、Overview

Human Posture Estimation, as shown in the figure below.

基于图卷积的行人意图识别方法与流程

2.3.2、Principle

image-20210901161528551

Input an image, extract the features through the convolutional network to obtain a set of feature maps, and then use the CNN network to extract Part Confidence Maps and Part Affinity Fields respectively;

2.3.3、Start up

After clicking the image frame, use the keyboard【f】key to switch target detection.

Input picture

person

Output picture

result

2.4、Target Detection

The main problem to be solved in this section is how to use the dnn module in OpenCV to import a trained target detection network.

We use OpenCV3.2.0 on our Transbot system.

At present, there are three main methods for using deep learning to detect objects:

2.4.1、Model structure

The main work of MobileNet is to replace the past standard convolutions with depthwise sparable convolutions to improve the computational efficiency and parameter amount of convolutional networks. The basic structure of depthwise separable convolution is shown in the figure below:

网络解析(二):MobileNets详解

The MobileNets network is composed of many depthwise separable convolutions shown in the figure above. The specific network structure is shown in the figure below:

网络解析(二):MobileNets详解

2.4.2、About code

List of recognizable objects

Load category [object_detection_coco.txt], import model [frozen_inference_graph.pb], specify deep learning framework [TensorFlow]

Import the picture, extract the height and width, calculate the 300x300 pixel blob, and pass this blob to the neural network

2.4.3、Start up

After clicking the image frame, use the keyboard【f】key to switch the human pose estimation.

image-20210901172132630