xingzilong
2017-08-18 9e5babf9db52e64bdae60137be7696e56241fca6
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef _PL_SENSETIMEFACETRACK_H_
#define _PL_SENSETIMEFACETRACK_H_
 
#include "PipeLine.h"
#include "GraphicHelper.h"
#include <vector>
#include <cmath>
 
struct SensetimeFaceFeature
{
    PLGH_Rect rect;
    int id;
 
    float score;
 
    /* Camera vision vector point to face
     *  * * *
     *  * * *
     *  * * *
     */
    float yaw;
 
    /* Camera vision vector point to face
     *  * * *
     *  * * *
     *  * * *
     */
    float pitch;
 
    /* Camera vision vector point to face
     *  * * *
     *  * * *
     *  * * *
     */
    float roll;
 
    float eyeDistance;
    PLGH_Path featurePoints;
 
    bool outOfFrame;
    
    SensetimeFaceFeature() : 
        rect(), id(0), score(0.0), yaw(0.0), pitch(0.0), roll(0.0), eyeDistance(0.0), featurePoints(),
        outOfFrame(false)
    {}
 
    bool test_face_in_cone(float _yaw, float _pitch, float _roll) const
    {
        return  (std::abs(yaw) < _yaw && std::abs(pitch) < _pitch && std::abs(roll) < _roll);
    }
};
 
typedef std::vector<SensetimeFaceFeature> st_ff_vect_t;
 
struct SensetimeFaceTrackConfig
{
    int point_size; // 21 / 106
    int point_size_config; // CV_DETECT_ENABLE_ALIGN_21 / CV_DETECT_ENABLE_ALIGN_106
    int detect_face_cnt_limit; // -1
    bool draw_face_rect;
    bool draw_face_feature_point;
    bool generate_face_feature;
    bool generate_face_point;
    int explode_feature_rect_x;
    int explode_feature_rect_y;
    bool clamp_feature_rect; // clamp fr width and height
    int doTrackPerFrame;
 
    std::string license_file_path;
    std::string license_str;
 
    float visionConeAngle;
 
    bool evenWidthHeight;
    
    float score_min;
 
    SensetimeFaceTrackConfig() : 
        point_size(21), point_size_config(-1), detect_face_cnt_limit(-1), 
        draw_face_rect(true), draw_face_feature_point(true), generate_face_feature(false), generate_face_point(false),
        explode_feature_rect_x(0), explode_feature_rect_y(0),
        clamp_feature_rect(false), doTrackPerFrame(1),
        license_file_path(), license_str(),
        visionConeAngle(90.1), evenWidthHeight(true), 
        score_min(0.0f)
    { }
};
 
class PL_SensetimeFaceTrack : public PipeLineElem
{
public:
    PL_SensetimeFaceTrack();
    virtual ~PL_SensetimeFaceTrack();
 
    virtual bool init(void* args);
    virtual void finit();
 
    virtual bool pay(const PipeMaterial& pm);
    virtual bool gain(PipeMaterial& pm);
 
private:
    static bool pay_breaker_MBFT_YUV(const PipeMaterial* pm, void* args);
    
private:
    void* internal;
};
 
PipeLineElem* create_PL_SensetimeFaceTrack();
 
#endif