xuepengqiang
2019-12-26 025429cbd5dd3dc6f130b8de07664665b0c4b55a
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
#include "human_runing.h"
#include "linear.h"
#include <iostream>
#include "vector_utils.h"
#include "human_velocity.h"
 
 
Human_Run::Human_Run(char cam_id)
{
    this->cam_id = cam_id;
//    cout << this->cam_id << endl;
 
    CameraInfo cf;
    this->cam_vec_ray = cf.get_vec_ray();
    this->base_distance = BASE_DISTANCE;
    this->base_length = BASE_LENGTH;
    this->angle = ANGLE;
    this->bottom_distance = cf.bottom_distance;
 
 
    //    for(int i=0;i< this->cam_vec_ray.size();i++)
    //    {
    //        std::cout << cam_vec_ray[i].size() << endl;
    //        for (int j = 0; j < this->cam_vec_ray[i].size() ; j++) {
    //            cout << this->cam_vec_ray[i][j]<<endl;
    //        }
    //    }
 
}
 
 
double Human_Run::get_human_velocity(int rps, int human_id, int x1, int y1, int x2, int y2)
{
    int center_pointx = (int)(x1+x2)/2;
    int center_pointy = (int)(y2-(y2-y1)/10);
    cout << "runing" << endl;
 
    Linear linear(this->cam_vec_ray, center_pointx, center_pointy);
    double center_distance = linear.cal_distance();
 
//    cout << typeid(center_distance).name() << endl;
//    cout << center_distance << endl;
 
    double deep_distance = linear.adjust_distance(this->base_distance,this->bottom_distance, center_distance,this->angle);
    printf("deep_distance::%f",deep_distance);
 
 
    VectorUtils VU;
    if(VU.is_element_in_vector(this->human_vec,human_id))
    {
        
        double frame_presrate = center_distance/this->bottom_distance;
        this->human_velocity_map[human_id].add_next_point(center_pointx, center_pointy, deep_distance, frame_presrate);
    } else{
        this->human_vec.push_back(human_id);
        HumanVelocity HV(this->bottom_distance, this->base_distance);
        this->human_velocity_map[human_id] = HV;
    }
//    printf("%d",this->human_velocity_map[human_id]);
    double human_velocity = this->human_velocity_map[human_id].cal_human_velocity(rps);
    return human_velocity;
 
}