Skip to content
Snippets Groups Projects
Verified Commit b7f73ad6 authored by Mohcine Chraibi's avatar Mohcine Chraibi
Browse files

add dummy pedestrians when numPeds < 3

parent f6bb29e8
No related branches found
No related tags found
2 merge requests!15Resolve "Method D | IndividualFD file use wrong PersID",!14Resolve "Method I | new measurement method"
Pipeline #17432 failed
......@@ -161,6 +161,7 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodD = args->GetStopFramesMethodD();
_IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesD=args->GetIsPlotTimeSeriesD();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
}
if(args->GetIsMethodI()) {
_DoesUseMethodI = true;
......@@ -173,6 +174,7 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodI = args->GetStopFramesMethodI();
_IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesI=args->GetIsPlotTimeSeriesI();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_I);
}
_deltaF = args->GetDelatT_Vins();
......@@ -186,7 +188,6 @@ void Analysis::InitArgs(ArgumentParser* args)
_IgnoreBackwardMovement =args->GetIgnoreBackwardMovement();
_grid_size_X = int(args->GetGridSizeX());
_grid_size_Y = int(args->GetGridSizeY());
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
_geometryFileName=args->GetGeometryFilename();
_projectRootDir=args->GetProjectRootDir();
_trajFormat=args->GetFileFormat();
......@@ -199,11 +200,11 @@ void Analysis::InitArgs(ArgumentParser* args)
std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, const std::vector<MeasurementArea_B*>& areas)
{
_building = new Building();
_building->LoadGeometry(geometryFile.string());
// create the polygons
_building->InitGeometry();
// _building->AddSurroundingRoom();
double geo_minX = FLT_MAX;
double geo_minY = FLT_MAX;
......@@ -221,10 +222,8 @@ std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, c
for (auto&& it_sub : it_room.second->GetAllSubRooms())
{
SubRoom* subroom = it_sub.second.get();
point_2d point(0,0);
boost::geometry::centroid(area->_poly,point);
//check if the area is contained in the obstacle
if(subroom->IsInSubRoom(Point(point.x()/M2CM,point.y()/M2CM)))
{
......@@ -245,7 +244,6 @@ std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, c
geoPoly[area->_id].inners().resize(k++);
geoPoly[area->_id].inners().back();
model::ring<point_2d>& inner = geoPoly[area->_id].inners().back();
for(auto&& tmp_point:obst->GetPolygon())
{
append(inner, make<point_2d>(tmp_point._x*M2CM, tmp_point._y*M2CM));
......@@ -267,9 +265,8 @@ std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, c
_highVertexY = geo_maxY;
_lowVertexX = geo_minX;
_lowVertexY = geo_minY;
// using boost::geometry::dsv;
using boost::geometry::dsv;
// cout<<"INFO: \tGeometry polygon is:\t" << dsv(geoPoly[1])<<endl;
return geoPoly;
}
......@@ -488,7 +485,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
bool result_I = method_I.Process(data,_scriptsLocation, _areaForMethod_I[i]->_zPos);
if(result_I)
{
Log->Write("INFO:\tSuccess with Method I uing measurement area id %d!\n",_areaForMethod_I[i]->_id);
Log->Write("INFO:\tSuccess with Method I using measurement area id %d!\n",_areaForMethod_I[i]->_id);
std::cout << "INFO:\tSuccess with Method I using measurement area id "<< _areaForMethod_I[i]->_id << "\n";
if(_plotTimeseriesI[i])
{
......
......@@ -152,13 +152,12 @@ bool Method_I::Process (const PedData& peddata,const fs::path& scriptsLocation,
XInFrame.erase(XInFrame.begin() + i);
YInFrame.erase(YInFrame.begin() + i);
VInFrame.erase(VInFrame.begin() + i);
Log->Write("Warning:\t Pedestrian removed");
i--;
}
}
int NumPeds = IdInFrame.size();
//---------------------------------------------------------------------------------------------------------------
if(NumPeds>3)
{
if(_isOneDimensional)
{
CalcVoronoiResults1D(XInFrame, VInFrame, IdInFrame, _areaForMethod_I->_poly,str_frid);
......@@ -210,12 +209,6 @@ bool Method_I::Process (const PedData& peddata,const fs::path& scriptsLocation,
Log->Write("WARNING: \tVoronoi Diagrams are not obtained!. Frame: %d (minFrame = %d)\n", frid, minFrame);
}
}
} // if N >3
else
{
Log->Write("INFO: \tThe number of the pedestrians is small (%d). Frame = %d (minFrame = %d)\n", NumPeds, frid, minFrame);
}
}
fclose(_fVoronoiRhoV);
if(_calcIndividualFD)
{
......@@ -285,8 +278,6 @@ std::vector<std::pair<polygon_2d, int> > Method_I::GetPolygons(vector<double>& X
double boundpoint =10*max(max(fabs(_geoMinX),fabs(_geoMinY)), max(fabs(_geoMaxX), fabs(_geoMaxY)));
std::vector<std::pair<polygon_2d, int> > polygons_id;
polygons_id = vd.getVoronoiPolygons(XInFrame, YInFrame, VInFrame,IdInFrame, boundpoint);
// std:: cout << " GetPolygons " << polygons_id.size() << "\n";
polygon_2d poly ;
if(_cutByCircle)
{
......
......@@ -49,11 +49,39 @@ VoronoiDiagram::~VoronoiDiagram()
std::vector<std::pair<polygon_2d, int> > VoronoiDiagram::getVoronoiPolygons(vector<double>& XInFrame, vector<double>& YInFrame,
vector<double>& VInFrame, vector<int>& IdInFrame, const double Bound_Max)
{
const int numPedsInFrame = IdInFrame.size();
int numPedsInFrame = IdInFrame.size();
vector<int> XInFrame_temp;
vector<int> YInFrame_temp;
vector<double> VInFrame_temp;
vector<int> IdInFrame_temp;
// in case 1 or 2 pedestrians are in the geometry
// add dummy pedestrians around to enable voronoi calculations
// @todo: maybe use negative ids for these dummy pedestrians to exclude
// them from any analysis.
if(numPedsInFrame == 1 || numPedsInFrame == 2)
{
numPedsInFrame += 4;
// up right
XInFrame.push_back(XInFrame[0]+10);
YInFrame.push_back(YInFrame[0]+10);
VInFrame.push_back(VInFrame[0]);
IdInFrame.push_back(IdInFrame[0]+1);
// up left
XInFrame.push_back(XInFrame[0]-10);
YInFrame.push_back(YInFrame[0]+10);
VInFrame.push_back(VInFrame[0]);
IdInFrame.push_back(IdInFrame[0]+2);
// down right
XInFrame.push_back(XInFrame[0]+10);
YInFrame.push_back(YInFrame[0]-10);
VInFrame.push_back(VInFrame[0]);
IdInFrame.push_back(IdInFrame[0]+3);
// down left
XInFrame.push_back(XInFrame[0]-10);
YInFrame.push_back(YInFrame[0]-10);
VInFrame.push_back(VInFrame[0]);
IdInFrame.push_back(IdInFrame[0]+4);
}
for (int i = 0; i < numPedsInFrame; i++)
{
......@@ -64,6 +92,7 @@ std::vector<std::pair<polygon_2d, int> > VoronoiDiagram::getVoronoiPolygons(vect
IdInFrame_temp.push_back(IdInFrame[i]);
}
VD voronoidiagram;
construct_voronoi(points.begin(), points.end(), &voronoidiagram);
int Ncell = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment