Commit c766e4b0665d8bf6339e2699598631280989d677
1 parent
d875dee1
提交当前使用的人脸检测模型
Showing
16 changed files
with
472 additions
and
0 deletions
3rdparty/model/face_detect/libface_det_vdec.so
0 → 100644
No preview for this file type
3rdparty/model/face_detect/models/face_det_yolov5s_310p.om
0 → 100644
No preview for this file type
3rdparty/model/face_detect/models/face_fuzzy_310p.om
0 → 100644
No preview for this file type
3rdparty/model/face_detect/models/face_ldmk_310p.om
0 → 100644
No preview for this file type
3rdparty/model/face_detect/models/face_occlusion_310p.om
0 → 100644
No preview for this file type
3rdparty/model/face_detect/models/face_pose_310p.om
0 → 100644
No preview for this file type
3rdparty/model/face_detect/models/face_score_310p.om
0 → 100644
No preview for this file type
3rdparty/model/face_detect/readme.txt
0 → 100644
1 | +人脸检测组件_x86_vdec_v0.0.2.20230704_withfixed_license | ||
2 | + | ||
3 | +支持系统: | ||
4 | + Atlas x86 linux | ||
5 | +文件清单: | ||
6 | + face_detect.h: 接口文件 | ||
7 | + libface_det_vdec.so: 依赖库文件 | ||
8 | + models: 各模型文件 | ||
9 | + test/: 测试文件 | ||
10 | + test.cpp: 调用示例 | ||
11 | + imgs:测试数据 | ||
12 | + list.txt: 测试图片列表 | ||
13 | + | ||
14 | +更新内容: | ||
15 | + -2023.06.15 编译ascend310p x86版本 | ||
16 | + -2023.07.04 修复宽高对齐因素导致的精度不足问题 | ||
17 | + -2023.07.12 宽高对齐约束与vdec一致 | ||
18 | + | ||
19 | + | ||
20 | +注意事项说明: | ||
21 | + -auth_license = "sy_tongtu_aiplatform_sdk_2023" | ||
22 | + | ||
23 | +中科院自动化所 模式识别实验室图像视频组 | ||
24 | + | ||
25 | +2023年07月12日 | ||
0 | \ No newline at end of file | 26 | \ No newline at end of file |
3rdparty/model/face_detect/test/face_detect.h
0 → 100644
1 | +/************************************************************ | ||
2 | +* Version: face_detect_v1.4.1.20201221.x86_64.gpu | ||
3 | +* CopyRight: 中科视语(北京)科技有限公司 | ||
4 | +* UpdateDate: 20201221 | ||
5 | +* Content: | ||
6 | +************************************************************/ | ||
7 | +#ifndef FACEDETECT_H_ | ||
8 | +#define FACEDETECT_H_ | ||
9 | + | ||
10 | +#ifdef _MSC_VER | ||
11 | +#ifdef FACEDETECT_EXPORTS | ||
12 | +#define FACEDETECT_API __declspec(dllexport) | ||
13 | +#else | ||
14 | +#define FACEDETECT_API __declspec(dllimport) | ||
15 | +#endif | ||
16 | +#else | ||
17 | +#define FACEDETECT_API __attribute__ ((visibility ("default"))) | ||
18 | +#endif | ||
19 | +#ifdef __cplusplus | ||
20 | +extern "C" | ||
21 | +{ | ||
22 | +#endif | ||
23 | + | ||
24 | +#include "sy_common.h" //通用数据结构体定义 | ||
25 | + | ||
26 | +// #define GPUIMG_PROCESS | ||
27 | + | ||
28 | +#ifndef FACIALFEAPOINTSIZE //关键点检测支持25个点 | ||
29 | +#define FACIALFEAPOINTSIZE 25 | ||
30 | +#endif | ||
31 | + | ||
32 | + | ||
33 | +#ifndef __FD_INFO__ | ||
34 | +#define __FD_INFO__ | ||
35 | + typedef struct fd_info { | ||
36 | + sy_rect face_position; //人脸位置 | ||
37 | + float face_pos_score; //人脸框置信度 | ||
38 | + sy_point facial_fea_point[FACIALFEAPOINTSIZE]; //人脸关键点位置信息 | ||
39 | + int occlusion; //人脸遮挡度,范围值为0-100,越大表示人脸遮挡程度越高 | ||
40 | + int clarity; //人脸清晰度,范围值为0-100,越大表示图像越清晰,人脸清晰度判别建议阈值为30 | ||
41 | + int brightness; //人脸亮度,只有3种可能的值:[-1->太暗,0->正常,1->太亮],亮度结果会受亮度阈值参数brightness_min和brightness_max影响 | ||
42 | + //int hat; //带帽子,范围为0-100,越大表示越可能有佩戴帽子,建议判别阈值为50 | ||
43 | + //int glass; //带眼镜,范围为0-100,越大表示越可能有戴眼镜,建议判别阈值为70 | ||
44 | + float roll; //姿态角 | ||
45 | + float yaw; //姿态角 | ||
46 | + float pitch; //姿态角 | ||
47 | + float score; //人脸置信度 | ||
48 | + } fd_info; | ||
49 | +#endif | ||
50 | + | ||
51 | +#ifndef __FD_RESULT__ | ||
52 | +#define __FD_RESULT__ | ||
53 | + typedef struct fd_result { //结果结构体 | ||
54 | + fd_info *info; //内存由外部申请 | ||
55 | + int count; //人脸个数 | ||
56 | + } fd_result; | ||
57 | +#endif | ||
58 | + | ||
59 | +#ifndef __FD_PARAM__ | ||
60 | +#define __FD_PARAM__ | ||
61 | + typedef struct fd_param | ||
62 | + { | ||
63 | + sy_command facial_fea_point_config; //是否启动关键点检测 | ||
64 | + sy_command pose_config; //是否启动姿态角 | ||
65 | + sy_command quality_config; //是否启动质量检测 | ||
66 | + sy_command score_config; //是否启动人脸置信度 | ||
67 | + // int log; //日志 | ||
68 | + // int mode; //运行模式(DEVICE_GPU / DEVICE_CPU) | ||
69 | + int devId; //指定显卡id | ||
70 | + float thresld; //检测阈值 建议0.7 | ||
71 | + | ||
72 | + int max_result_count; //检测结果目标数上限 | ||
73 | + // int max_batch_size_detect; //检测批处理检测数量上限 | ||
74 | + // int max_batch_size_ldmk; //关键点批处理检测数量上限 | ||
75 | + // int max_batch_size_pose; //姿态角批处理检测数量上限 | ||
76 | + // int max_batch_size_score; //置信度批处理检测数量上限 | ||
77 | + // int max_batch_size_blurglass; //质量(模糊)批处理检测数量上限 | ||
78 | + // //int max_batch_size_hat; //质量(帽子)批处理检测数量上限 | ||
79 | + // int max_batch_size_occlusion; //质量(遮挡)批处理检测数量上限 | ||
80 | + | ||
81 | + char * auth_license; | ||
82 | + char* det_modelNames; //人脸检测 | ||
83 | + char* ldmk_modelNames; //人脸关键点 | ||
84 | + char* pose_modelNames; //人脸姿态 | ||
85 | + char* score_modelNames; //人脸置信度 | ||
86 | + char* fuzzy_modelNames; //人脸质量_模糊 | ||
87 | + char* occlusion_modelNames; //人脸质量_遮挡 | ||
88 | + | ||
89 | + fd_param() : facial_fea_point_config(SY_CONFIG_OPEN), pose_config(SY_CONFIG_OPEN), \ | ||
90 | + quality_config(SY_CONFIG_OPEN), score_config(SY_CONFIG_OPEN), thresld(0.6), devId(0), max_result_count(20), auth_license("") {}; //默认功能全部启动 | ||
91 | + }fd_param; | ||
92 | +#endif | ||
93 | + | ||
94 | + /************************************************************************* | ||
95 | + * function: fd_init | ||
96 | + * purpose: init resources | ||
97 | + * param: | ||
98 | + [in] handle - handle | ||
99 | + [in] param - init param | ||
100 | + * return: success(0) or error code(<0) | ||
101 | + * notes: null | ||
102 | + *************************************************************************/ | ||
103 | + FACEDETECT_API int fd_init(void ** handle, fd_param param); | ||
104 | + | ||
105 | + | ||
106 | + /************************************************************************* | ||
107 | + * function: fd_release | ||
108 | + * purpose: release sources | ||
109 | + * param: | ||
110 | + [in] handle - handle | ||
111 | + * return: null | ||
112 | + * notes: null | ||
113 | + *************************************************************************/ | ||
114 | + FACEDETECT_API void fd_release(void ** handle); | ||
115 | + | ||
116 | + /************************************************************************* | ||
117 | + * function: fd_get_version | ||
118 | + * purpose: get sdk version | ||
119 | + * param: null | ||
120 | + * return: null | ||
121 | + * notes: null | ||
122 | + *************************************************************************/ | ||
123 | + FACEDETECT_API const char * fd_get_version(); | ||
124 | + | ||
125 | + /************************************************************************* | ||
126 | + * function: fd_detect_batch | ||
127 | + * purpose: detect faces | ||
128 | + * param: | ||
129 | + [in] handle - handle | ||
130 | + [in] img_data_array - data array | ||
131 | + [in] format - data format | ||
132 | + [in] batch_size - batch size | ||
133 | + [in] result - face detect result | ||
134 | + * return: success(0) or error code(<0) | ||
135 | + * notes: null | ||
136 | + *************************************************************************/ | ||
137 | + //FACEDETECT_API int fd_detect_batch(void * handle, sy_img * img_data_array, sy_format format, int batch_size, fd_result *result); | ||
138 | + | ||
139 | + /************************************************************************* | ||
140 | + * function: fd_detect | ||
141 | + * purpose: detect faces | ||
142 | + * param: | ||
143 | + [in] handle - handle | ||
144 | + [in] img_data_array - data array | ||
145 | + [in] format - data format | ||
146 | + [in] result - face detect result | ||
147 | + * return: success(0) or error code(<0) | ||
148 | + * notes: null | ||
149 | + *************************************************************************/ | ||
150 | + FACEDETECT_API int fd_detect(void * handle, sy_img img_data, sy_format format, fd_result *result); | ||
151 | + | ||
152 | + | ||
153 | + FACEDETECT_API int fd_detect_batch(void * handle, sy_img * img_data_array, sy_format format, int batch_size, fd_result *result); | ||
154 | +#ifdef __cplusplus | ||
155 | +}; | ||
156 | +#endif | ||
157 | + | ||
158 | +#endif | ||
159 | + |
3rdparty/model/face_detect/test/imgs/202205071457080003_146.jpg
0 → 100644
985 KB
3rdparty/model/face_detect/test/imgs/202205071527200001_1.jpg
0 → 100644
295 KB
3rdparty/model/face_detect/test/imgs/202205071527400003_2.jpg
0 → 100644
296 KB
3rdparty/model/face_detect/test/list.txt
0 → 100644
3rdparty/model/face_detect/test/makefile
0 → 100644
1 | +XX = g++ | ||
2 | + | ||
3 | + | ||
4 | +PROJECT_ROOT= /data/cmhu/vpt_ascend | ||
5 | + | ||
6 | +DEPEND_DIR = $(PROJECT_ROOT)/bin | ||
7 | +SRC_ROOT = $(PROJECT_ROOT)/src | ||
8 | + | ||
9 | +TARGET= $(PROJECT_ROOT)/bin/face_test | ||
10 | + | ||
11 | +THIRDPARTY_ROOT = $(PROJECT_ROOT)/3rdparty | ||
12 | +SPDLOG_ROOT = $(THIRDPARTY_ROOT)/spdlog-1.9.2/release | ||
13 | +# OPENCV_ROOT = $(THIRDPARTY_ROOT)/opencv_4_1 | ||
14 | +OPENCV_ROOT = $(THIRDPARTY_ROOT)/opencv-4.5.4/release | ||
15 | +JSON_ROOT = $(THIRDPARTY_ROOT)/jsoncpp-1.9.5/release | ||
16 | +FFMPEG_ROOT = $(THIRDPARTY_ROOT)/ffmpeg-4.4.4/release | ||
17 | +RABBITMQ_CLIENT_ROOT = $(THIRDPARTY_ROOT)/rabbitmq-c-0.11.0/release | ||
18 | +BOOST_ROOT = $(THIRDPARTY_ROOT)/boost_1_81_0/release | ||
19 | +WEBSOCKETPP_ROOT = $(THIRDPARTY_ROOT)/websocketpp-0.8.2/release/include \ | ||
20 | + | ||
21 | +JRTP_ROOT = $(THIRDPARTY_ROOT)/gb28181_3rd/jrtp_export | ||
22 | + | ||
23 | +DEFS = -DENABLE_DVPP_INTERFACE -DWITH_FACE_DET_SS | ||
24 | +# DEFS = -DENABLE_DVPP_INTERFACE -DUSE_VILLAGE -DPOST_USE_RABBITMQ | ||
25 | + | ||
26 | +include_dir=-I/usr/local/Ascend/ascend-toolkit/latest/include \ | ||
27 | + -I $(SRC_ROOT)/common \ | ||
28 | + -I $(SPDLOG_ROOT)/include \ | ||
29 | + -I $(OPENCV_ROOT)/include/opencv4 \ | ||
30 | + -I $(JSON_ROOT)/include \ | ||
31 | + -I $(FFMPEG_ROOT)/include \ | ||
32 | + -I $(RABBITMQ_CLIENT_ROOT)/include \ | ||
33 | + -I $(JRTP_ROOT)/jrtplib/include/jrtplib3 \ | ||
34 | + -I $(SRC_ROOT)/decoder/gb28181/rtp \ | ||
35 | + -I $(SRC_ROOT)/decoder/gb28181 \ | ||
36 | + -I $(WEBSOCKETPP_ROOT) \ | ||
37 | + -I $(BOOST_ROOT)/include \ | ||
38 | + -I $(SRC_ROOT)/common \ | ||
39 | + -I $(SRC_ROOT)/common/dvpp \ | ||
40 | + | ||
41 | + | ||
42 | +LIBS= -L $(SPDLOG_ROOT)/lib -l:libspdlog.a \ | ||
43 | + -L $(DEPEND_DIR) -lface_det_vdec \ | ||
44 | + -L $(OPENCV_ROOT)/lib -lopencv_world\ | ||
45 | + -L $(JSON_ROOT)/lib -l:libjsoncpp.a \ | ||
46 | + -L $(FFMPEG_ROOT)/lib -l:libavformat.a -l:libavcodec.a -l:libswscale.a -l:libavutil.a -l:libavfilter.a -l:libswresample.a -l:libavdevice.a -l:libx264.a\ | ||
47 | + -L $(RABBITMQ_CLIENT_ROOT)/lib/x86_64-linux-gnu -l:librabbitmq.a \ | ||
48 | + -L $(JRTP_ROOT)/jrtplib/lib -l:libjrtp.a \ | ||
49 | + -L/usr/local/Ascend/ascend-toolkit/latest/runtime/lib64 -lacl_dvpp -lascendcl \ | ||
50 | + -L $(BOOST_ROOT)/lib -lboost_system \ | ||
51 | + | ||
52 | + | ||
53 | + | ||
54 | +CXXFLAGS= -g -O0 -fPIC $(include_dir) $(LIBS) $(DEFS) -lpthread -lrt -lz -fexceptions -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fvisibility=hidden -Wall -Wno-deprecated -Wdeprecated-declarations -Wl,-Bsymbolic -ldl | ||
55 | + | ||
56 | + | ||
57 | + | ||
58 | +SRCS:=$(wildcard $(THIRDPARTY_ROOT)/model/face_detect/test/*.cpp) \ | ||
59 | + $(wildcard $(SRC_ROOT)/common/*.cpp) \ | ||
60 | + $(wildcard $(SRC_ROOT)/common/dvpp/*.cpp) \ | ||
61 | + | ||
62 | + | ||
63 | +OBJS = $(patsubst %.cpp, %.o, $(notdir $(SRCS))) | ||
64 | + | ||
65 | + | ||
66 | +$(TARGET):$(OBJS) | ||
67 | + rm -f $(TARGET) | ||
68 | + $(XX) -o $@ $^ $(CXXFLAGS) | ||
69 | + rm -f *.o | ||
70 | + | ||
71 | +%.o:$(THIRDPARTY_ROOT)/model/face_detect/test/%.cpp | ||
72 | + $(XX) $(CXXFLAGS) -c $< | ||
73 | + | ||
74 | +%.o:$(SRC_ROOT)/common/dvpp/%.cpp | ||
75 | + $(XX) $(CXXFLAGS) -c $< | ||
76 | + | ||
77 | +%.o:$(SRC_ROOT)/common/%.cpp | ||
78 | + $(XX) $(CXXFLAGS) -c $< | ||
79 | + | ||
80 | + | ||
81 | +clean: | ||
82 | + rm -f *.o $(TARGET) | ||
83 | + | ||
84 | + | ||
85 | +cleano: | ||
86 | + rm -f *.o | ||
0 | \ No newline at end of file | 87 | \ No newline at end of file |
3rdparty/model/face_detect/test/stream_data.h
0 → 100644
1 | +#ifndef _STREAM_DATA_H_ | ||
2 | +#define _STREAM_DATA_H_ | ||
3 | + | ||
4 | +#include <memory> | ||
5 | + | ||
6 | +struct ImageData { | ||
7 | + uint32_t width = 0; | ||
8 | + uint32_t height = 0; | ||
9 | + uint32_t alignWidth = 0; | ||
10 | + uint32_t alignHeight = 0; | ||
11 | + uint32_t size = 0; | ||
12 | + std::shared_ptr<uint8_t> data; | ||
13 | +}; | ||
14 | + | ||
15 | +#endif | ||
0 | \ No newline at end of file | 16 | \ No newline at end of file |
3rdparty/model/face_detect/test/test.cpp
0 → 100644
1 | +#include <iostream> | ||
2 | +#include <sstream> | ||
3 | +#include <fstream> | ||
4 | +#include <chrono> | ||
5 | +#include <dirent.h> | ||
6 | +#include "face_detect.h" | ||
7 | +#include "opencv2/opencv.hpp" | ||
8 | +#include "opencv2/imgcodecs/legacy/constants_c.h" | ||
9 | +#include "opencv2/imgproc/types_c.h" | ||
10 | +#include "time.h" | ||
11 | +#include "sys/time.h" | ||
12 | +#include "sy_errorinfo.h" | ||
13 | +#include "utils.h" | ||
14 | +#include "dvpp_process.h" | ||
15 | + | ||
16 | +using namespace std; | ||
17 | +using namespace cv; | ||
18 | + | ||
19 | +double msecond() { | ||
20 | + struct timeval tv; | ||
21 | + gettimeofday(&tv, 0); | ||
22 | + return (tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0); | ||
23 | +} | ||
24 | + | ||
25 | + | ||
26 | +void getAllNm(std::string pthNm, std::vector<std::string>& fileList) | ||
27 | +{ | ||
28 | + DIR *dir; | ||
29 | + struct dirent *ptr; | ||
30 | + dir = opendir(pthNm.c_str()); ///open the dir | ||
31 | + int filenum = 0; | ||
32 | + while((ptr = readdir(dir)) != NULL) ///read the list of this dir | ||
33 | + { | ||
34 | + // char* to string | ||
35 | + std::string curNm = ptr->d_name; | ||
36 | + if(curNm != "." && curNm != "..") | ||
37 | + { | ||
38 | + filenum++; | ||
39 | + fileList.push_back(curNm); | ||
40 | + //printf("file %d name: %s\n", filenum, curNm.c_str()); | ||
41 | + } | ||
42 | + } | ||
43 | + closedir(dir); | ||
44 | +} | ||
45 | + | ||
46 | +void CvBGR2NV21(Mat& bgr, unsigned char* yuv) { | ||
47 | + int stride = (bgr.cols + 15) / 16 * 16; | ||
48 | + int strideH = (bgr.rows + 1) / 2 * 2; | ||
49 | + for (int i = 0; i < bgr.rows; i++) { | ||
50 | + for (int j = 0; j < bgr.cols; j++) { | ||
51 | + int B = bgr.at<cv::Vec3b>(i, j)[0]; | ||
52 | + int G = bgr.at<cv::Vec3b>(i, j)[1]; | ||
53 | + int R = bgr.at<cv::Vec3b>(i, j)[2]; | ||
54 | + | ||
55 | + int Y = (77 * R + 150 * G + 29 * B) >> 8; | ||
56 | + yuv[i * stride + j] = (Y < 0) ? 0 : ((Y > 255) ? 255 : Y); | ||
57 | + if (i % 2 == 0 && j % 2 == 0) { | ||
58 | + int V = ((-44 * R - 87 * G + 131 * B) >> 8) + 128; /// | ||
59 | + int U = ((131 * R - 110 * G - 21 * B) >> 8) + 128; /// | ||
60 | + yuv[strideH * stride + i / 2 * stride + j] = (V < 0) ? 0 : ((V > 255) ? 255 : V); | ||
61 | + yuv[strideH * stride + i / 2 * stride + j + 1] = (U < 0) ? 0 : ((U > 255) ? 255 : U); | ||
62 | + } | ||
63 | + } | ||
64 | + } | ||
65 | +} | ||
66 | + | ||
67 | +int main() { | ||
68 | + cout << fd_get_version() << endl; | ||
69 | + | ||
70 | + fd_param param; | ||
71 | + param.det_modelNames = "./models/face_detect/face_det_yolov5s_310p.om"; | ||
72 | + param.ldmk_modelNames = "./models/face_detect/face_ldmk_310p.om"; | ||
73 | + param.pose_modelNames = "./models/face_detect/face_pose_310p.om"; | ||
74 | + param.score_modelNames = "./models/face_detect/face_score_310p.om"; | ||
75 | + param.fuzzy_modelNames = "./models/face_detect/face_fuzzy_310p.om"; | ||
76 | + param.occlusion_modelNames = "./models/face_detect/face_occlusion_310p.om"; | ||
77 | + param.thresld = 0.2; | ||
78 | + param.devId = 0; | ||
79 | + param.auth_license = "sy_tongtu_aiplatform_sdk_2023"; | ||
80 | + param.facial_fea_point_config = SY_CONFIG_OPEN; //是否启动关键点检测 | ||
81 | + param.pose_config = SY_CONFIG_OPEN; //是否启动姿态角 | ||
82 | + param.quality_config = SY_CONFIG_OPEN; //是否启动质量检测 | ||
83 | + param.score_config = SY_CONFIG_OPEN; //是否启动人脸置信度 //SY_CONFIG_OPEN SY_CONFIG_CLOSE | ||
84 | + param.max_result_count = 100; | ||
85 | + | ||
86 | + void* handle = nullptr; | ||
87 | + cout << "init start " << endl; | ||
88 | + ACL_CALL(aclInit(nullptr), ACL_SUCCESS, SY_FAILED); | ||
89 | + ACL_CALL(aclrtSetDevice(param.devId), ACL_SUCCESS, SY_FAILED); | ||
90 | + aclrtContext ctx; | ||
91 | + ACL_CALL(aclrtCreateContext(&ctx, param.devId), ACL_SUCCESS, SY_FAILED); | ||
92 | + aclrtStream stream = nullptr; | ||
93 | + ACL_CALL(aclrtCreateStream(&stream), ACL_SUCCESS, SY_FAILED); | ||
94 | + DvppProcess* dvpp = new DvppProcess(); | ||
95 | + dvpp->InitResource(stream); | ||
96 | + int ret = fd_init(&handle, param); | ||
97 | + | ||
98 | + if (ret == 0) { | ||
99 | + cout << "init success " << endl; | ||
100 | + const char* img_file_path="imgs/"; | ||
101 | + | ||
102 | + ifstream infile("list.txt"); | ||
103 | + string file; | ||
104 | + while (infile >> file) { | ||
105 | + string filename = "imgs/" + file; | ||
106 | + cout << "img path: " << filename << endl; | ||
107 | + const int batchsize = 1; | ||
108 | + Mat cvImg = imread(filename.c_str()); | ||
109 | + sy_img imgs[batchsize]; | ||
110 | + | ||
111 | + /* | ||
112 | + ImageData src[batchsize], dvpp_data[batchsize]; | ||
113 | + for (int b = 0; b < batchsize; b++) { | ||
114 | + Utils::ReadImageFile(src[b], filename); //将二进制图像读入内存,并读取宽高信息 | ||
115 | + ACL_CALL(dvpp->CvtJpegToYuv420sp(dvpp_data[b], src[b]), SY_SUCCESS, SY_FAILED); //解码 | ||
116 | + imgs[b].w_ = dvpp_data[b].width; | ||
117 | + imgs[b].h_ = dvpp_data[b].height; | ||
118 | + imgs[b].data_ = dvpp_data[b].data.get(); | ||
119 | + cout << dvpp_data[b].size << endl; | ||
120 | + }*/ | ||
121 | + | ||
122 | + uint32_t alignWidth = (cvImg.cols + 15) / 16 * 16; | ||
123 | + uint32_t alignHeight = (cvImg.rows + 1) / 2 * 2; | ||
124 | + uint32_t size = alignWidth * alignHeight * 1.5; | ||
125 | + cout << "opencv:"<<cvImg.cols << " " <<cvImg.rows<< " " <<alignWidth<<" "<<alignHeight <<" "<< size << " " << endl; | ||
126 | + std::shared_ptr<uint8_t> data = shared_ptr<uint8_t>((new uint8_t[size]), | ||
127 | + [](uint8_t* p) {delete [] p;}); | ||
128 | + CvBGR2NV21(cvImg, data.get()); | ||
129 | + | ||
130 | + for (int i = 0; i < batchsize; i++) { | ||
131 | + imgs[i].w_ = cvImg.cols; | ||
132 | + imgs[i].h_ = cvImg.rows; | ||
133 | + imgs[i].data_ = data.get(); | ||
134 | + } | ||
135 | + | ||
136 | + fd_result results[batchsize]; | ||
137 | + for (int fd_i = 0; fd_i < batchsize; fd_i++) { | ||
138 | + results[fd_i].info = new fd_info[50]; //内存由外部申请 | ||
139 | + } | ||
140 | + double t1, t2; | ||
141 | + t1 = msecond(); | ||
142 | + int ret = fd_detect_batch(handle, imgs, SY_FORMAT_BGR888, batchsize, results); | ||
143 | + t2 = msecond(); | ||
144 | + printf("debug mean process time: %.2f\n", (t2 - t1)/batchsize); | ||
145 | + if (SY_SUCCESS != ret) { | ||
146 | + printf("vpr detection process failed!"); | ||
147 | + return SY_FAILED; | ||
148 | + } | ||
149 | + | ||
150 | + // draw results | ||
151 | + for(int b = 0; b < batchsize; b ++){ | ||
152 | + printf("debug det num:%d\n",results[b].count); | ||
153 | + for (int j = 0; j < results[b].count; j++) { | ||
154 | + printf("fd_detect_batch %d - %d %d %d %d %d\n", b, j, results[b].info[j].face_position.left_, results[b].info[j].face_position.top_, results[b].info[j].face_position.width_, results[b].info[j].face_position.height_); | ||
155 | + rectangle(cvImg, Rect(results[b].info[j].face_position.left_, results[b].info[j].face_position.top_, results[b].info[j].face_position.width_, results[b].info[j].face_position.height_), Scalar(0, 0, 255), 3); | ||
156 | + for (int f = 0; f < 25; f++) { | ||
157 | + cv::circle(cvImg, cv::Point(results[b].info[j].facial_fea_point[f].x_, results[b].info[j].facial_fea_point[f].y_), 1, Scalar(0, 0, 255), 1); | ||
158 | + } | ||
159 | + | ||
160 | + cout << "detect_score:" << results[b].info[j].face_pos_score << endl; | ||
161 | + printf("angle: pitch: %.2f, roll: %.2f, yaw: %.2f, score = %.2f \n", results[b].info[j].pitch, results[b].info[j].roll, results[b].info[j].yaw, results[b].info[j].score); | ||
162 | + printf("occlusion: %d clarity: %d brightness: %d\n", results[b].info[j].occlusion, results[b].info[j].clarity, results[b].info[j].brightness/*, results[b].info[j].hat, results[b].info[j].glass*/); | ||
163 | + printf("----- ldmk = (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n", results[b].info[j].facial_fea_point[0].x_, results[b].info[j].facial_fea_point[0].y_, results[b].info[j].facial_fea_point[1].x_, results[b].info[j].facial_fea_point[1].y_, results[b].info[j].facial_fea_point[2].x_, results[b].info[j].facial_fea_point[2].y_, results[b].info[j].facial_fea_point[3].x_, results[b].info[j].facial_fea_point[3].y_); | ||
164 | + printf("----- ldmk eye center = (%d,%d) ldmk lip up center = (%d,%d)\n", results[b].info[j].facial_fea_point[6].x_, results[b].info[j].facial_fea_point[6].y_, results[b].info[j].facial_fea_point[8].x_, results[b].info[j].facial_fea_point[8].y_); | ||
165 | + | ||
166 | + } | ||
167 | + } | ||
168 | + string jpgSaveName = "result/" + file; | ||
169 | + cv::imwrite(jpgSaveName, cvImg); | ||
170 | + | ||
171 | + for (int fd_i = 0; fd_i < batchsize; fd_i++) { | ||
172 | + delete[] results[fd_i].info; | ||
173 | + results[fd_i].info = NULL; | ||
174 | + } | ||
175 | + | ||
176 | + } | ||
177 | + } | ||
178 | + | ||
179 | + dvpp->DestroyResource(); | ||
180 | + fd_release(&handle); | ||
181 | + aclFinalize(); | ||
182 | + | ||
183 | + return 0; | ||
184 | +} |