I am creating a program the compute peoples using haar cascade . the detection don't give me all people in one frame , but in the next frame i detect the objects that are not detected in the precedent frame .
example : in a video i have theree persons in the frame 1 i detect person A and B in the frame 2 i detect person A and C
Is there any to get the true number of persons according to the two frames
i used this function but it is not reliable
bool isInside(Rect rectangle, Point point)
{
if (point.x > rectangle.x && point.x<rectangle.x + rectangle.width && point.y>rectangle.y && point.y < rectangle.y + rectangle.height)
return true;
}
vector<Point> getNouvellesDetections(vector<Rect> rectangles, vector<Point> anciennePoints)
{
vector<Point> nouvellePoints = anciennePoints;
for (int i = 0; i < rectangles.size(); i++)
{
bool isNouveau = true;
for (int j = 0; j < anciennePoints.size(); j++)
{
if (isInside(rectangles[i], anciennePoints[j]))
{
isNouveau = false;
anciennePoints[j].x = getCenterX(rectangles[i]);
anciennePoints[j].y = getCenterY(rectangles[i]);
break;
}
}
if (isNouveau)
{
Point point;
point.x = getCenterX(rectangles[i]);
point.y = getCenterY(rectangles[i]);
nouvellePoints.push_back(point);
}
}
return nouvellePoints;
}