a
554325746@qq.com
2020-01-15 956063ff14bc75e3a2a97c7bcaa06b9edc84ad24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "RgbDetect.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
 
#include "FiStdDefEx.h"
#include <memory>
#include "THFeature_i.h"
//#include "THFaceLive_i.h"
#include "LogUtil.h"
 
shared_ptr<vector<unsigned char>> RgbDetect::rgb_image_buffer = nullptr;
shared_ptr<vector<THFI_FacePos>> RgbDetect::facePos = nullptr;
shared_ptr<vector<unsigned char>> RgbDetect::rgb_image_buffer4 = nullptr;
shared_ptr<vector<THFI_FacePos>> RgbDetect::facePos4 = nullptr;
const char* RgbDetect::rgbFileName = nullptr;
int RgbDetect::width = 0;
int RgbDetect::height = 0;
long int RgbDetect::fileSize = 0;
int RgbDetect::face_nums = 0;
int RgbDetect::face_nums4 = 0;
 
bool RgbDetect::detect(int channel, int detectFaceCount) {
    bool success = false;
    try {
        if (rgb_image_buffer != nullptr && rgb_image_buffer.get() != nullptr &&  fileSize > 0) {
            face_nums = THFI_DetectFace(channel, rgb_image_buffer.get()->data(), 24, width, height, &(RgbDetect::facePos.get()->at(0)), 20,360);
            //face_nums = THFI_DetectFace(channel, rgb_image_buffer.get()->data(), 24, width, height, &(RgbDetect::facePos.get()->at(0)), 1,0);
            if (face_nums > 0) {
                success = true;
            }
 
        }
    }catch (exception & e) {
        LogUtil::log(e.what());
    }
    return success;
}
 
bool RgbDetect::detect4(int channel, int detectFaceCount) {
    bool success = false;
    try {
        if (rgb_image_buffer4 != nullptr && rgb_image_buffer4.get() != nullptr &&  fileSize > 0) {
            face_nums4 = THFI_DetectFace(channel, rgb_image_buffer4.get()->data(), 24, width, height, &(RgbDetect::facePos4.get()->at(0)), 20,360);
            if (face_nums4 > 0) {
                success = true;
            }
 
        }
    }catch (exception & e) {
        LogUtil::log(e.what());
    }
    return success;
}
 
bool RgbDetect::detect(int detectFaceCount) {
    bool success = false;
    try {
        if (rgb_image_buffer != nullptr && rgb_image_buffer.get() != nullptr &&  fileSize > 0) {
            face_nums = THFI_DetectFace(0, rgb_image_buffer.get()->data(), 24, width, height, &(RgbDetect::facePos.get()->at(0)), 20,360);
            if (face_nums > 0) {
                success = true;
            }
 
        }
    }catch (exception & e) {
        LogUtil::log(e.what());
    }
    return success;
}