xuepengqiang
2020-05-26 48bf06c1cadadcfb93faa8df63db71e59b534f55
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <iostream>
#include "./src/coord_interface.h"
#include "src/con_target.h"
#include "./src/math_util.h"
 
int main() {
    std::cout << "Hello, World!" << std::endl;
//    float Ax = 30.0f, Ay = 110.0f, Bx = 326.36f, By = 64.45f;
//    const char* config_str = "{\"leftCam\":{ \"A1x\": 30.0, \"A1y\":110.0 ,\"A2x\": 120.0,\"A2y\":200.0, ,\"A3x\": 80.0,\"A3y\":400.0, ,\"A4x\": 20.0,\"A4y\":287.0},"
//                                "rightCam\":{ \"B1x\": 30.0, \"B1y\":110.0 ,\"B2x\": 120.0,\"B2y\":200.0, ,\"B3x\": 80.0,\"B3y\":400.0, ,\"B4x\": 20.0,\"B4y\":287.0}"
//                                "}";
 
//    CoordManager CM(config_str);
 
    // ---- 初始化赋值 ---
    CamVec *CV_Reg = (CamVec*)malloc(sizeof(CamVec));
    CV_Reg->count = 3; //表示有3个摄像机相互关联
    int reg_point_size = 4; // 关联区域的坐标点数
    CV_Reg->regInfo = (RegInfo*)malloc(sizeof(RegInfo)*CV_Reg->count);
 
    SPoint2f *regA_point = (SPoint2f*)malloc(sizeof(SPoint2f)*reg_point_size);
    regA_point[0] = SPoint2f(100.0f, 100.0f);
    regA_point[1] = SPoint2f(120.0f, 200.0f);
    regA_point[2] = SPoint2f(80.0f, 400.0f);
    regA_point[3] = SPoint2f(20.0f, 287.0f);
    CV_Reg->regInfo[0].count = reg_point_size;
    CV_Reg->regInfo[0].point = regA_point;
 
    SPoint2f* regB_point = (SPoint2f*)malloc(sizeof(SPoint2f)*reg_point_size);
    regB_point[0] = SPoint2f(326.36f, 64.45f);
    regB_point[1] = SPoint2f(339.16f, 128.24f);
    regB_point[2] = SPoint2f(313.73f, 255.86f);
    regB_point[3] = SPoint2f(275.41f, 183.80f);
    CV_Reg->regInfo[1].count = reg_point_size;
    CV_Reg->regInfo[1].point = regB_point;
 
    SPoint2f* regC_point = (SPoint2f*)malloc(sizeof(SPoint2f)*reg_point_size);
    regC_point[0] = SPoint2f(326.36f, 64.45f);
    regC_point[1] = SPoint2f(339.16f, 128.24f);
    regC_point[2] = SPoint2f(313.73f, 255.86f);
    regC_point[3] = SPoint2f(275.41f, 183.80f);
    CV_Reg->regInfo[2].count = reg_point_size;
    CV_Reg->regInfo[2].point = regC_point;
 
    CoordManager CM(CV_Reg); //初始化区域信息
 
 
    // 获取待匹配的点信息
    MulCam* mulCam = (MulCam*)malloc(sizeof(MulCam));
    mulCam->cam_count = CV_Reg->count;
    mulCam->matchHuman = (MatchHuman*)malloc(sizeof(MatchHuman)*mulCam->cam_count);
 
 
//    MatchHuman * A_Human = (MatchHuman*)malloc(sizeof(MatchHuman));
    int A_hcount = 3;
    mulCam->matchHuman[0].humanInfo = (HumanInfo*)malloc(sizeof(HumanInfo)*A_hcount);
    mulCam->matchHuman[0].humanInfo[0].human_id = 10000;
    mulCam->matchHuman[0].humanInfo[0].point = SPoint2f(100.0f, 100.0f);
    mulCam->matchHuman[0].humanInfo[1].human_id = 1002;
    mulCam->matchHuman[0].humanInfo[1].point = SPoint2f(30.0f, 110.0f);
    mulCam->matchHuman[0].humanInfo[2].human_id = 1003;
    mulCam->matchHuman[0].humanInfo[2].point = SPoint2f(35.0f, 100.0f);
    mulCam->matchHuman[0].count = A_hcount;
//    mulCam->matchHuman[0].humanInfo = A_Human;
 
//    MatchHuman * B_Human = (MatchHuman*)malloc(sizeof(MatchHuman));
    int B_hcount = 2;
    mulCam->matchHuman[1].humanInfo = (HumanInfo*)malloc(sizeof(HumanInfo)*B_hcount);
    mulCam->matchHuman[1].humanInfo[0].human_id = 2001;
    mulCam->matchHuman[1].humanInfo[0].point = SPoint2f(326.36f, 64.45f);
    mulCam->matchHuman[1].humanInfo[1].human_id = 2003;
    mulCam->matchHuman[1].humanInfo[1].point = SPoint2f(280.9f, 60.49f);
    mulCam->matchHuman[1].count = B_hcount;
//    mulCam->matchHuman[1] = B_Human;
 
//    MatchHuman * C_Human = (MatchHuman*)malloc(sizeof(MatchHuman));
    int C_hcount = 1;
    mulCam->matchHuman[2].humanInfo = (HumanInfo*)malloc(sizeof(HumanInfo)*B_hcount);
    mulCam->matchHuman[2].humanInfo[0].human_id = 30001;
    mulCam->matchHuman[2].humanInfo[0].point = SPoint2f(284.9f, 64.49f);
    mulCam->matchHuman[2].count = C_hcount;
//    mulCam->matchHuman[2] = C_Human;
 
 
 
 
    MulCam* lastmulCam = (MulCam*)malloc(sizeof(MulCam));
    lastmulCam->cam_count = CV_Reg->count;
    lastmulCam->matchHuman = (MatchHuman*)malloc(sizeof(MatchHuman)*mulCam->cam_count);
 
 
//    MatchHuman * A_Human = (MatchHuman*)malloc(sizeof(MatchHuman));
    int lA_hcount = 3;
    lastmulCam->matchHuman[0].humanInfo = (HumanInfo*)malloc(sizeof(HumanInfo)*A_hcount);
    lastmulCam->matchHuman[0].humanInfo[0].human_id = 1;
    lastmulCam->matchHuman[0].humanInfo[0].point = SPoint2f(100.0f, 100.0f);
    lastmulCam->matchHuman[0].humanInfo[1].human_id = 2;
    lastmulCam->matchHuman[0].humanInfo[1].point = SPoint2f(30.0f, 110.0f);
    lastmulCam->matchHuman[0].humanInfo[2].human_id = 3;
    lastmulCam->matchHuman[0].humanInfo[2].point = SPoint2f(35.0f, 100.0f);
    lastmulCam->matchHuman[0].count = lA_hcount;
//    mulCam->matchHuman[0].humanInfo = A_Human;
 
//    MatchHuman * B_Human = (MatchHuman*)malloc(sizeof(MatchHuman));
    int lB_hcount = 2;
    lastmulCam->matchHuman[1].humanInfo = (HumanInfo*)malloc(sizeof(HumanInfo)*B_hcount);
    lastmulCam->matchHuman[1].humanInfo[0].human_id = 3;
    lastmulCam->matchHuman[1].humanInfo[0].point = SPoint2f(326.36f, 64.45f);
    lastmulCam->matchHuman[1].humanInfo[1].human_id = 5;
    lastmulCam->matchHuman[1].humanInfo[1].point = SPoint2f(284.9f, 64.49f);
    lastmulCam->matchHuman[1].count = lB_hcount;
//    mulCam->matchHuman[1] = B_Human;
 
//    MatchHuman * C_Human = (MatchHuman*)malloc(sizeof(MatchHuman));
    int lC_hcount = 1;
    lastmulCam->matchHuman[2].humanInfo = (HumanInfo*)malloc(sizeof(HumanInfo)*B_hcount);
    lastmulCam->matchHuman[2].humanInfo[1].human_id = 5;
    lastmulCam->matchHuman[2].humanInfo[1].point = SPoint2f(284.9f, 64.49f);
    lastmulCam->matchHuman[2].count = lC_hcount;
 
 
 
    char * result="";
 
 
    result = CM.get_result(mulCam, lastmulCam);// 批量匹配区域中的人
 
    std::cout<< " ----------   " <<  std::endl;
    std::cout<< result <<  std::endl;
//    //遍历结果
//    for (int i = 0; i < mulCam->cam_count-1; ++i) {
//        map<string,float>::iterator iter;
//        for (iter=target->camResult[i].confidence_map.begin() ;iter!=target->camResult[i].confidence_map.end();iter++) {
//            std::cout<< iter->first << "  confidence   " << iter->second << std::endl;
//        }
//    }
//
//    std::cout<< " ----------   " <<  std::endl;
//    map<int,int>::iterator direction_iter;
//    for (direction_iter=target->direction_map.begin();direction_iter!=target->direction_map.end();direction_iter++) {
//        std::cout<< direction_iter->first << "  direction   " << direction_iter->second << std::endl;
//    }
 
//    map<string,float>::iterator iter;
//    for (iter=confidence_map.begin() ;iter!=confidence_map.end();iter++) {
//        std::cout<< iter->first << "  confidence   " << iter->second << std::endl;
//    }
 
 
    std::cout << "--over" << std::endl;
    return 0;
}