Matlab simulation of personnel smoking behavior detection algorithm based on deep learning network

Table of contents

1. Preview of algorithm operation renderings

2.Algorithm running software version

3. Some core programs

4. Overview of algorithm theory

5. Algorithm complete program engineering


1. Preview of algorithm operation renderings

2.Algorithm running software version

matlab2022a

3. Some core programs

clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
rng('default')

load FRCNN.mat
In_layer_Size  = [224 224 3];
imgPath = 'smoke_train/';        % 图像库路径
imgDir  = dir([imgPath '*.jpg']); % 遍历所有jpg格式文件
cnt     = 0;
for i = 1:length(imgDir)          % 遍历结构体就可以一一处理图片了
    i
    if mod(i,12)==1
       figure
    end
    cnt     = cnt+1;
    subplot(3,4,cnt); 
    img = imread([imgPath imgDir(i).name]); %读取每张图片
    I               = imresize(img,In_layer_Size(1:2));
    [bboxes,scores] = detect(detector,I);
    [Vs,Is] = max(scores);
    if isempty(bboxes)==0
    I1              = insertObjectAnnotation(I,'rectangle',bboxes(Is,:),Vs);
    
    else
    I1              = I;
    Vs              = 0;
    end
    imshow(I1)
    title(['检测置信度:',num2str(Vs)]);
    if cnt==12
       cnt=0;
    end
end
0056

4. Overview of algorithm theory

         The personnel smoking behavior detection algorithm based on Faster R-CNN deep learning network is a method that uses deep learning technology to detect personnel smoking behavior. The algorithm is mainly based on the Faster R-CNN network structure, and realizes the detection of smoking behavior through target detection and feature extraction of people in video or image sequences.

  1. Algorithm principle

The principle of this algorithm is mainly divided into three steps: region proposal, feature extraction and target classification.

(1) Regional proposal

In the region proposal stage, the algorithm generates a series of target regions through the Region Proposal Network (RPN). RPN is a neural network structure based on a convolutional neural network (CNN). By performing a convolution operation on the input image, it extracts the feature map of the image and generates a series of target areas according to preset rules. These target areas may contain targets such as faces and cigarettes, but do not contain background information.

(2) Feature extraction

In the feature extraction stage, the algorithm inputs the extracted target area into a convolutional neural network (CNN) for feature extraction. CNN is a deep learning network structure that extracts the characteristics of the data by performing convolution operations on the input data. By performing a convolution operation on the target area, the feature map of the target area can be obtained.

(3) Target classification

In the target classification stage, the algorithm inputs the extracted feature map into the fully connected layer (FC) for classification and border correction. FC is a deep learning network structure used to map input data to the target label space. By performing a fully connected operation on the feature map, the classification results and border information of the target area can be obtained.

The main formulas of this algorithm include the formula of convolutional neural network (CNN), the formula of RPN and the formula of FC.

(1) Formula of convolutional neural network (CNN)

CNN is a commonly used deep learning network structure, mainly used for image feature extraction. Its basic structure includes multiple convolutional layers, pooling layers and fully connected layers. Among them, the convolution layer is used to perform convolution operations on the input image and extract the features of the image; the pooling layer is used to downsample the feature map and reduce the number of network parameters; the fully connected layer is used to map the feature map to the target Label space for tasks such as classification and regression.

The formula of CNN is as follows:

(2) RPN formula

RPN is a CNN-based target region generation network used to generate a series of target regions. Its basic structure is similar to CNN, but two fully connected layers are added after the last convolutional layer to generate frame information and confidence information of the target area. The formula of RPN is as follows:

(3) FC formula

FC is a deep learning network structure used to map input data to the target label space. Its basic structure is a fully connected layer, where each node is connected to all nodes in the previous layer.

The formula of FC is as follows:

5. Algorithm complete program engineering

OOOOO

OOO

O

Guess you like

Origin blog.csdn.net/aycd1234/article/details/132656797