Maintenance at Wednesday, 30. June 2021, from 7:30 to 9:30
Some of the planned changes may require user action

Commit cb7fd2f2 authored by Gregor Jaeger's avatar Gregor Jaeger
Browse files

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)
_StopFramesMethodD = args->GetStopFramesMethodD();
_IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesD=args->GetIsPlotTimeSeriesD();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
_geoPolyMethodD = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
}
if(args->GetIsMethodI()) {
_DoesUseMethodI = true;
......@@ -179,14 +180,19 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodI = args->GetStopFramesMethodI();
_IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesI=args->GetIsPlotTimeSeriesI();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_I);
_geoPolyMethodI = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_I);
}
if( _DoesUseMethodD && _DoesUseMethodI)
{
Log->Write("Warning:\t Using both method D and I is not safe!");
// because ReadGeomtry() may be called twice
}
// ToDo: obsolete ?
// if( _DoesUseMethodD && _DoesUseMethodI)
// {
// 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();
_cutByCircle = args->GetIsCutByCircle();
_getProfile = args->GetIsGetProfile();
......@@ -336,6 +342,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_A)
{
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
{
......@@ -361,6 +368,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_B)
{
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
{
......@@ -385,6 +393,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_C)
{
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])
{
string parameters_Timeseries=" " + _scriptsLocation.string()+
......@@ -417,7 +426,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
method_D.SetStartFrame(_StartFramesMethodD[i]);
method_D.SetStopFrame(_StopFramesMethodD[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.SetGeometryBoundaries(_lowVertexX, _lowVertexY, _highVertexX, _highVertexY);
method_D.SetGridSize(_grid_size_X, _grid_size_Y);
......@@ -470,7 +479,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
method_I.SetStartFrame(_StartFramesMethodI[i]);
method_I.SetStopFrame(_StopFramesMethodI[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.SetGeometryBoundaries(_lowVertexX, _lowVertexY, _highVertexX, _highVertexY);
method_I.SetGridSize(_grid_size_X, _grid_size_Y);
......
......@@ -111,7 +111,8 @@ private:
Building* _building;
//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_Y;
......
......@@ -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<double> XInFrame = peddata.GetXInFrame(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 int to_remove
//------------------------------Remove peds outside geometry------------------------------------------
......@@ -151,6 +152,7 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation,
IdInFrame.erase(IdInFrame.begin() + i);
XInFrame.erase(XInFrame.begin() + i);
YInFrame.erase(YInFrame.begin() + i);
ZInFrame.erase(ZInFrame.begin() + i);
VInFrame.erase(VInFrame.begin() + i);
i--;
}
......@@ -189,7 +191,8 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation,
{
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)
......@@ -257,7 +260,7 @@ bool Method_D::OpenFileIndividualFD()
{
fs::path trajFileName("_id_"+_measureAreaId+".dat");
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();
if((_fIndividualFD=Analysis::CreateFile(Individualfundment))==nullptr)
{
......@@ -268,11 +271,11 @@ bool Method_D::OpenFileIndividualFD()
{
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
{
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;
}
......@@ -561,10 +564,11 @@ void Method_D::OutputVoroGraph(const string & frameId, std::vector<std::pair<po
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 uniquevelocity=0;
double x, y, z;
int uniqueId=0;
int temp=0;
for (const auto & polygon_iterator:polygon)
......@@ -581,9 +585,15 @@ void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<d
uniquedensity=1.0/(area(polygon_iterator)*CMtoM*CMtoM);
uniquevelocity=Velocity[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(),
uniqueId,
x,
y,
z,
uniquedensity,
uniquevelocity,
polygon_str.c_str(),
......
......@@ -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);
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 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
* @param polygon
......
This diff is collapsed.
......@@ -51,9 +51,9 @@ public:
void SetGeometryFileName(const fs::path& geometryFile);
void SetGeometryBoundaries(double minX, double minY, double maxX, double maxY);
void SetGridSize(double x, double y);
void SetCalculateProfiles(bool calcProfile);
void SetCalculateProfiles(bool calcProfile); // ToDo: obsolete ?
void SetOutputVoronoiCellData(bool outputCellData);
void SetPlotVoronoiGraph(bool plotVoronoiGraph);
void SetPlotVoronoiGraph(bool plotVoronoiGraph); // ToDo: obsolete ?
void SetPlotVoronoiIndex(bool plotVoronoiIndex);
void SetMeasurementArea (MeasurementArea_B* area);
void SetDimensional (bool dimension);
......@@ -70,11 +70,11 @@ private:
fs::path _outputLocation;
fs::path _scriptsLocation;
bool _calcIndividualFD;
polygon_2d _areaIndividualFD;
bool _getProfile;
bool _outputVoronoiCellData;
bool _plotVoronoiCellData;
bool _plotVoronoiIndex;
polygon_2d _areaIndividualFD; // ToDo: obsolete ?
bool _getProfile; // ToDo: obsolete ?
bool _outputVoronoiCellData; // ToDo: obsolete ?
bool _plotVoronoiCellData; // ToDo: obsolete ?
bool _plotVoronoiIndex; // ToDo: obsolete ?
bool _isOneDimensional;
bool _cutByCircle; //Adjust whether cut each original voronoi cell by a circle
double _cutRadius;
......@@ -86,10 +86,10 @@ private:
double _geoMaxY;
FILE* _fVoronoiRhoV;
FILE* _fIndividualFD;
double _grid_size_X; // the size of the grid
double _grid_size_Y;
double _grid_size_X; // the size of the grid // ToDo: obsolete ?
double _grid_size_Y; // ToDo: obsolete ?
float _fps;
bool OpenFileMethodI();
bool OpenFileMethodI(); // ToDo: obsolete ?
bool OpenFileIndividualFD();
fs::path _geometryFileName;
fs::path _trajectoryPath;
......@@ -99,11 +99,13 @@ private:
std::vector<std::pair<polygon_2d, int> > GetPolygons(std::vector<double>& XInFrame, std::vector<double>& YInFrame,
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);
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 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, std::vector<double>& XInFrame, std::vector<double>& YInFrame, std::vector<double>& ZInFrame);
/**
* Reduce the precision of the points to two digits
......@@ -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 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
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);
};
......
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