notplus / MTCNN-PureC

MTCNN face detection with C and Arm-CMSIS-DSP
MIT License
16 stars 8 forks source link
face-detection

MTCNN-PureC

MTCNN face detection with C and Arm-CMSIS-DSP

Introduction

The project is a MTCNN face detection based on C. To implement MTCNN in MCU, the project doesn't rely on any library and you can use ARM-CMSIS-DSP to accelerate the matrix multiplication. The input data is a RGB CHW txt, and output is the keypoints of face and bounding box of face.

本项目为MTCNN的C实现,无依赖库,主要为arm平台的mcu编写,在部署时可通过ARM-CMSIS-DSP库来加速矩阵乘法运算,请参考官方文档。

本项目在保持API不变下简化了arm_math.harm_mat_mult_f32.c,以便在PC平台运行。

输入为RGB CHW格式的文本文件,输出为人脸包围盒和人脸关键点。

Usage

git clone https://github.com/notplus/MTCNN-PureC.git
cd MTCNN-PureC
mkdir build
cd build
cmake ..
make

Demo

picture 1

Input

输入为RGB CHW 格式图像生成的文本文件,可使用如下代码生成,另外使用时需要在include/test.h中修改图像尺寸。

import numpy as np
import cv2
img = cv2.imread("1.jpg")
img_ = img[:,:,::-1].transpose((2,0,1))
np.savetxt('input1.txt', img_.reshape(-1), "%d")

Output

Print with opencv

picture 2

Implement Details

The project mainly refers to MTCNN-light and remove OpenCV and OpenBLAS dependencies.
Convolution is implemented by im2col and matrix multiplication.

本项目主要参考了MTCNN-light,并且移除了OpenCV和OpenBLAS依赖。