#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;
|
|
}
|