Commit cb7fd2f2 authored by Gregor Jaeger's avatar Gregor Jaeger

solution for issue 108, modification for issue 105 (Method I) and issue 88 (Method D)

parent 9edacfef
Pipeline #21612 passed with stages
in 34 seconds
...@@ -166,7 +166,8 @@ void Analysis::InitArgs(ArgumentParser* args) ...@@ -166,7 +166,8 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodD = args->GetStopFramesMethodD(); _StopFramesMethodD = args->GetStopFramesMethodD();
_IndividualFDFlags = args->GetIndividualFDFlags(); _IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesD=args->GetIsPlotTimeSeriesD(); _plotTimeseriesD=args->GetIsPlotTimeSeriesD();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D); _geoPolyMethodD = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
} }
if(args->GetIsMethodI()) { if(args->GetIsMethodI()) {
_DoesUseMethodI = true; _DoesUseMethodI = true;
...@@ -179,14 +180,19 @@ void Analysis::InitArgs(ArgumentParser* args) ...@@ -179,14 +180,19 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodI = args->GetStopFramesMethodI(); _StopFramesMethodI = args->GetStopFramesMethodI();
_IndividualFDFlags = args->GetIndividualFDFlags(); _IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesI=args->GetIsPlotTimeSeriesI(); _plotTimeseriesI=args->GetIsPlotTimeSeriesI();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_I); _geoPolyMethodI = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_I);
} }
if( _DoesUseMethodD && _DoesUseMethodI) // ToDo: obsolete ?
{
Log->Write("Warning:\t Using both method D and I is not safe!"); // if( _DoesUseMethodD && _DoesUseMethodI)
// because ReadGeomtry() may be called twice // {
} // Log->Write("Warning:\t Using both method D and I is not safe!");
// // because ReadGeometry() may be called twice (line 169 and 182)
// // overwrite _geoPoly -> new value for each Method
// Log->Write("Info:\t Using both method D and I is safe! :-)");
// }
_deltaF = args->GetDelatT_Vins(); _deltaF = args->GetDelatT_Vins();
_cutByCircle = args->GetIsCutByCircle(); _cutByCircle = args->GetIsCutByCircle();
_getProfile = args->GetIsGetProfile(); _getProfile = args->GetIsGetProfile();
...@@ -336,6 +342,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path) ...@@ -336,6 +342,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_A) if(result_A)
{ {
Log->Write("INFO:\tSuccess with Method A using measurement area id %d!\n",_areaForMethod_A[i]->_id); Log->Write("INFO:\tSuccess with Method A using measurement area id %d!\n",_areaForMethod_A[i]->_id);
std::cout << "INFO:\tSuccess with Method A using measurement area id "<< _areaForMethod_A[i]->_id << "\n";
} }
else else
{ {
...@@ -361,6 +368,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path) ...@@ -361,6 +368,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_B) if(result_B)
{ {
Log->Write("INFO:\tSuccess with Method B using measurement area id %d!\n",_areaForMethod_B[i]->_id); Log->Write("INFO:\tSuccess with Method B using measurement area id %d!\n",_areaForMethod_B[i]->_id);
std::cout << "INFO:\tSuccess with Method B using measurement area id "<< _areaForMethod_B[i]->_id << "\n";
} }
else else
{ {
...@@ -385,6 +393,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path) ...@@ -385,6 +393,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_C) if(result_C)
{ {
Log->Write("INFO:\tSuccess with Method C using measurement area id %d!\n",_areaForMethod_C[i]->_id); Log->Write("INFO:\tSuccess with Method C using measurement area id %d!\n",_areaForMethod_C[i]->_id);
std::cout << "INFO:\tSuccess with Method C using measurement area id "<< _areaForMethod_C[i]->_id << "\n";
if(_plotTimeseriesC[i]) if(_plotTimeseriesC[i])
{ {
string parameters_Timeseries=" " + _scriptsLocation.string()+ string parameters_Timeseries=" " + _scriptsLocation.string()+
...@@ -417,7 +426,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path) ...@@ -417,7 +426,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
method_D.SetStartFrame(_StartFramesMethodD[i]); method_D.SetStartFrame(_StartFramesMethodD[i]);
method_D.SetStopFrame(_StopFramesMethodD[i]); method_D.SetStopFrame(_StopFramesMethodD[i]);
method_D.SetCalculateIndividualFD(_IndividualFDFlags[i]); method_D.SetCalculateIndividualFD(_IndividualFDFlags[i]);
method_D.SetGeometryPolygon(_geoPoly[_areaForMethod_D[i]->_id]); method_D.SetGeometryPolygon(_geoPolyMethodD[_areaForMethod_D[i]->_id]);
method_D.SetGeometryFileName(_geometryFileName); method_D.SetGeometryFileName(_geometryFileName);
method_D.SetGeometryBoundaries(_lowVertexX, _lowVertexY, _highVertexX, _highVertexY); method_D.SetGeometryBoundaries(_lowVertexX, _lowVertexY, _highVertexX, _highVertexY);
method_D.SetGridSize(_grid_size_X, _grid_size_Y); method_D.SetGridSize(_grid_size_X, _grid_size_Y);
...@@ -470,7 +479,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path) ...@@ -470,7 +479,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
method_I.SetStartFrame(_StartFramesMethodI[i]); method_I.SetStartFrame(_StartFramesMethodI[i]);
method_I.SetStopFrame(_StopFramesMethodI[i]); method_I.SetStopFrame(_StopFramesMethodI[i]);
method_I.SetCalculateIndividualFD(_IndividualFDFlags[i]); method_I.SetCalculateIndividualFD(_IndividualFDFlags[i]);
method_I.SetGeometryPolygon(_geoPoly[_areaForMethod_I[i]->_id]); method_I.SetGeometryPolygon(_geoPolyMethodI[_areaForMethod_I[i]->_id]);
method_I.SetGeometryFileName(_geometryFileName); method_I.SetGeometryFileName(_geometryFileName);
method_I.SetGeometryBoundaries(_lowVertexX, _lowVertexY, _highVertexX, _highVertexY); method_I.SetGeometryBoundaries(_lowVertexX, _lowVertexY, _highVertexX, _highVertexY);
method_I.SetGridSize(_grid_size_X, _grid_size_Y); method_I.SetGridSize(_grid_size_X, _grid_size_Y);
......
...@@ -111,7 +111,8 @@ private: ...@@ -111,7 +111,8 @@ private:
Building* _building; Building* _building;
//polygon_2d _geoPoly; //polygon_2d _geoPoly;
std::map<int, polygon_2d> _geoPoly; std::map<int, polygon_2d> _geoPolyMethodD;
std::map<int, polygon_2d> _geoPolyMethodI;
double _grid_size_X; // the size of the grid double _grid_size_X; // the size of the grid
double _grid_size_Y; double _grid_size_Y;
......
...@@ -140,6 +140,7 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation, ...@@ -140,6 +140,7 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation,
vector<int> IdInFrame = peddata.GetIdInFrame(frameNr, ids, zPos_measureArea); vector<int> IdInFrame = peddata.GetIdInFrame(frameNr, ids, zPos_measureArea);
vector<double> XInFrame = peddata.GetXInFrame(frameNr, ids, zPos_measureArea); vector<double> XInFrame = peddata.GetXInFrame(frameNr, ids, zPos_measureArea);
vector<double> YInFrame = peddata.GetYInFrame(frameNr, ids, zPos_measureArea); vector<double> YInFrame = peddata.GetYInFrame(frameNr, ids, zPos_measureArea);
vector<double> ZInFrame = peddata.GetZInFrame(frameNr, ids, zPos_measureArea);
vector<double> VInFrame = peddata.GetVInFrame(frameNr, ids, zPos_measureArea); vector<double> VInFrame = peddata.GetVInFrame(frameNr, ids, zPos_measureArea);
//vector int to_remove //vector int to_remove
//------------------------------Remove peds outside geometry------------------------------------------ //------------------------------Remove peds outside geometry------------------------------------------
...@@ -151,6 +152,7 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation, ...@@ -151,6 +152,7 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation,
IdInFrame.erase(IdInFrame.begin() + i); IdInFrame.erase(IdInFrame.begin() + i);
XInFrame.erase(XInFrame.begin() + i); XInFrame.erase(XInFrame.begin() + i);
YInFrame.erase(YInFrame.begin() + i); YInFrame.erase(YInFrame.begin() + i);
ZInFrame.erase(ZInFrame.begin() + i);
VInFrame.erase(VInFrame.begin() + i); VInFrame.erase(VInFrame.begin() + i);
i--; i--;
} }
...@@ -189,7 +191,8 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation, ...@@ -189,7 +191,8 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation,
{ {
if(!_isOneDimensional) if(!_isOneDimensional)
{ {
GetIndividualFD(polygons,VInFrame, IdInFrame, _areaForMethod_D->_poly, str_frid); // TODO polygons_id // GetIndividualFD(polygons,VInFrame, IdInFrame, _areaForMethod_D->_poly, str_frid); // TODO polygons_id
GetIndividualFD(polygons,VInFrame, IdInFrame, _areaForMethod_D->_poly, str_frid, XInFrame, YInFrame, ZInFrame);
} }
} }
if(_getProfile) if(_getProfile)
...@@ -257,7 +260,7 @@ bool Method_D::OpenFileIndividualFD() ...@@ -257,7 +260,7 @@ bool Method_D::OpenFileIndividualFD()
{ {
fs::path trajFileName("_id_"+_measureAreaId+".dat"); fs::path trajFileName("_id_"+_measureAreaId+".dat");
fs::path indFDPath("Fundamental_Diagram"); fs::path indFDPath("Fundamental_Diagram");
indFDPath = _outputLocation / indFDPath / "IndividualFD" / (_trajName.string() + trajFileName.string()); indFDPath = _outputLocation / indFDPath / "IndividualFD" / ("IFD_D_" +_trajName.string() + trajFileName.string());
string Individualfundment=indFDPath.string(); string Individualfundment=indFDPath.string();
if((_fIndividualFD=Analysis::CreateFile(Individualfundment))==nullptr) if((_fIndividualFD=Analysis::CreateFile(Individualfundment))==nullptr)
{ {
...@@ -268,11 +271,11 @@ bool Method_D::OpenFileIndividualFD() ...@@ -268,11 +271,11 @@ bool Method_D::OpenFileIndividualFD()
{ {
if(_isOneDimensional) if(_isOneDimensional)
{ {
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame \t PedId \t Individual density(m^(-1)) \t Individual velocity(m/s) \t Headway(m)\n",_fps); fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame\tPersID\tIndividual density(m^(-1))\tIndividual velocity(m/s)\tHeadway(m)\n",_fps);
} }
else else
{ {
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame \t PedId \t Individual density(m^(-2)) \t Individual velocity(m/s) \t Voronoi Polygon \t Intersection Polygon\n",_fps); fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame\tPersID\tx/m\ty/m\tz/m\tIndividual density(m^(-2))\tIndividual velocity(m/s)\tVoronoi Polygon\tIntersection Polygon\n",_fps);
} }
return true; return true;
} }
...@@ -561,10 +564,11 @@ void Method_D::OutputVoroGraph(const string & frameId, std::vector<std::pair<po ...@@ -561,10 +564,11 @@ void Method_D::OutputVoroGraph(const string & frameId, std::vector<std::pair<po
return polygon_str; return polygon_str;
}*/ }*/
void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const vector<int>& Id, const polygon_2d& measureArea, const string& frid) void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const vector<int>& Id, const polygon_2d& measureArea, const string& frid, vector<double>& XInFrame, vector<double>& YInFrame, vector<double>& ZInFrame)
{ {
double uniquedensity=0; double uniquedensity=0;
double uniquevelocity=0; double uniquevelocity=0;
double x, y, z;
int uniqueId=0; int uniqueId=0;
int temp=0; int temp=0;
for (const auto & polygon_iterator:polygon) for (const auto & polygon_iterator:polygon)
...@@ -581,9 +585,15 @@ void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<d ...@@ -581,9 +585,15 @@ void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<d
uniquedensity=1.0/(area(polygon_iterator)*CMtoM*CMtoM); uniquedensity=1.0/(area(polygon_iterator)*CMtoM*CMtoM);
uniquevelocity=Velocity[temp]; uniquevelocity=Velocity[temp];
uniqueId=Id[temp]; uniqueId=Id[temp];
fprintf(_fIndividualFD,"%s\t%d\t%.3f\t%.3f\t%s\t%s\n", x = XInFrame[temp]*CMtoM;
y = YInFrame[temp]*CMtoM;
z = ZInFrame[temp]*CMtoM;
fprintf(_fIndividualFD,"%s\t %d\t %.4f\t %.4f\t %.4f\t %.4f\t %.4f\t%s\t%s\n",
frid.c_str(), frid.c_str(),
uniqueId, uniqueId,
x,
y,
z,
uniquedensity, uniquedensity,
uniquevelocity, uniquevelocity,
polygon_str.c_str(), polygon_str.c_str(),
......
...@@ -103,7 +103,7 @@ private: ...@@ -103,7 +103,7 @@ private:
std::tuple<double,double> GetVoronoiDensityVelocity(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const polygon_2d & measureArea); std::tuple<double,double> GetVoronoiDensityVelocity(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const polygon_2d & measureArea);
void GetProfiles(const std::string& frameId, const std::vector<polygon_2d>& polygons, const std::vector<double>& velocity); void GetProfiles(const std::string& frameId, const std::vector<polygon_2d>& polygons, const std::vector<double>& velocity);
void OutputVoroGraph(const std::string & frameId, std::vector<std::pair<polygon_2d, int> >& polygons, int numPedsInFrame,const std::vector<double>& VInFrame); void OutputVoroGraph(const std::string & frameId, std::vector<std::pair<polygon_2d, int> >& polygons, int numPedsInFrame,const std::vector<double>& VInFrame);
void GetIndividualFD(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const std::vector<int>& Id, const polygon_2d& measureArea, const std::string& frid); void GetIndividualFD(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const std::vector<int>& Id, const polygon_2d& measureArea, const std::string& frid, std::vector<double>& XInFrame, std::vector<double>& YInFrame, std::vector<double>& ZInFrame);
/** /**
* Reduce the precision of the points to two digits * Reduce the precision of the points to two digits
* @param polygon * @param polygon
......
This diff is collapsed.
...@@ -51,9 +51,9 @@ public: ...@@ -51,9 +51,9 @@ public:
void SetGeometryFileName(const fs::path& geometryFile); void SetGeometryFileName(const fs::path& geometryFile);
void SetGeometryBoundaries(double minX, double minY, double maxX, double maxY); void SetGeometryBoundaries(double minX, double minY, double maxX, double maxY);
void SetGridSize(double x, double y); void SetGridSize(double x, double y);
void SetCalculateProfiles(bool calcProfile); void SetCalculateProfiles(bool calcProfile); // ToDo: obsolete ?
void SetOutputVoronoiCellData(bool outputCellData); void SetOutputVoronoiCellData(bool outputCellData);
void SetPlotVoronoiGraph(bool plotVoronoiGraph); void SetPlotVoronoiGraph(bool plotVoronoiGraph); // ToDo: obsolete ?
void SetPlotVoronoiIndex(bool plotVoronoiIndex); void SetPlotVoronoiIndex(bool plotVoronoiIndex);
void SetMeasurementArea (MeasurementArea_B* area); void SetMeasurementArea (MeasurementArea_B* area);
void SetDimensional (bool dimension); void SetDimensional (bool dimension);
...@@ -70,11 +70,11 @@ private: ...@@ -70,11 +70,11 @@ private:
fs::path _outputLocation; fs::path _outputLocation;
fs::path _scriptsLocation; fs::path _scriptsLocation;
bool _calcIndividualFD; bool _calcIndividualFD;
polygon_2d _areaIndividualFD; polygon_2d _areaIndividualFD; // ToDo: obsolete ?
bool _getProfile; bool _getProfile; // ToDo: obsolete ?
bool _outputVoronoiCellData; bool _outputVoronoiCellData; // ToDo: obsolete ?
bool _plotVoronoiCellData; bool _plotVoronoiCellData; // ToDo: obsolete ?
bool _plotVoronoiIndex; bool _plotVoronoiIndex; // ToDo: obsolete ?
bool _isOneDimensional; bool _isOneDimensional;
bool _cutByCircle; //Adjust whether cut each original voronoi cell by a circle bool _cutByCircle; //Adjust whether cut each original voronoi cell by a circle
double _cutRadius; double _cutRadius;
...@@ -86,10 +86,10 @@ private: ...@@ -86,10 +86,10 @@ private:
double _geoMaxY; double _geoMaxY;
FILE* _fVoronoiRhoV; FILE* _fVoronoiRhoV;
FILE* _fIndividualFD; FILE* _fIndividualFD;
double _grid_size_X; // the size of the grid double _grid_size_X; // the size of the grid // ToDo: obsolete ?
double _grid_size_Y; double _grid_size_Y; // ToDo: obsolete ?
float _fps; float _fps;
bool OpenFileMethodI(); bool OpenFileMethodI(); // ToDo: obsolete ?
bool OpenFileIndividualFD(); bool OpenFileIndividualFD();
fs::path _geometryFileName; fs::path _geometryFileName;
fs::path _trajectoryPath; fs::path _trajectoryPath;
...@@ -99,11 +99,13 @@ private: ...@@ -99,11 +99,13 @@ private:
std::vector<std::pair<polygon_2d, int> > GetPolygons(std::vector<double>& XInFrame, std::vector<double>& YInFrame, std::vector<std::pair<polygon_2d, int> > GetPolygons(std::vector<double>& XInFrame, std::vector<double>& YInFrame,
std::vector<double>& VInFrame, std::vector<int>& IdInFrame); std::vector<double>& VInFrame, std::vector<int>& IdInFrame);
// ToDo: This functions are obsolete.
void OutputVoronoiResults(const std::vector<polygon_2d>& polygons, const std::string& frid, const std::vector<double>& VInFrame); void OutputVoronoiResults(const std::vector<polygon_2d>& polygons, const std::string& frid, const std::vector<double>& VInFrame);
std::tuple<double,double> GetVoronoiDensityVelocity(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const polygon_2d & measureArea); std::tuple<double,double> GetVoronoiDensityVelocity(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const polygon_2d & measureArea);
void GetProfiles(const std::string& frameId, const std::vector<polygon_2d>& polygons, const std::vector<double>& velocity); void GetProfiles(const std::string& frameId, const std::vector<polygon_2d>& polygons, const std::vector<double>& velocity);
void OutputVoroGraph(const std::string & frameId, std::vector<std::pair<polygon_2d, int> >& polygons, int numPedsInFrame,const std::vector<double>& VInFrame); void OutputVoroGraph(const std::string & frameId, std::vector<std::pair<polygon_2d, int> >& polygons, int numPedsInFrame,const std::vector<double>& VInFrame);
void GetIndividualFD(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const std::vector<int>& Id, const std::string& frid); void GetIndividualFD(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const std::vector<int>& Id, const std::string& frid);
void GetIndividualFD(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const std::vector<int>& Id, const std::string& frid, std::vector<double>& XInFrame, std::vector<double>& YInFrame, std::vector<double>& ZInFrame); void GetIndividualFD(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const std::vector<int>& Id, const std::string& frid, std::vector<double>& XInFrame, std::vector<double>& YInFrame, std::vector<double>& ZInFrame);
/** /**
* Reduce the precision of the points to two digits * Reduce the precision of the points to two digits
...@@ -111,7 +113,10 @@ private: ...@@ -111,7 +113,10 @@ private:
*/ */
void CalcVoronoiResults1D(std::vector<double>& XInFrame, std::vector<double>& VInFrame, std::vector<int>& IdInFrame, const polygon_2d & measureArea, const std::string& frid); void CalcVoronoiResults1D(std::vector<double>& XInFrame, std::vector<double>& VInFrame, std::vector<int>& IdInFrame, const polygon_2d & measureArea, const std::string& frid);
void ReducePrecision(polygon_2d& polygon); void ReducePrecision(polygon_2d& polygon);
// ToDo: This function is obsolete.
bool IsPedInGeometry(int frames, int peds, double **Xcor, double **Ycor, int *firstFrame, int *lastFrame); //check whether all the pedestrians are in the geometry bool IsPedInGeometry(int frames, int peds, double **Xcor, double **Ycor, int *firstFrame, int *lastFrame); //check whether all the pedestrians are in the geometry
double getOverlapRatio(const double& left, const double& right, const double& measurearea_left, const double& measurearea_right); double getOverlapRatio(const double& left, const double& right, const double& measurearea_left, const double& measurearea_right);
bool IsPointsOnOneLine(std::vector<double>& XInFrame, std::vector<double>& YInFrame); bool IsPointsOnOneLine(std::vector<double>& XInFrame, std::vector<double>& YInFrame);
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment