1

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

1 Answer 1

2

The code you have provided doesnt give much insight into your detection method, etc.

Have you considered tracking the detected objects ? Its hard to determine which detections are new and which are re-detections without some sort of tracking.

The Haar classifier is not magic, it is very approximate.

For example you could detect objects using Haar and create a "person tracker" that would track their velocity (movement) and test objects detected in the n+1 frame if they could be the same person. Then after n tracked detections you could classify that object as a "person" and not a false positive and after n non-detections "forget" the object or mark it as lost.

One method of tracking would be using optical flow on the detected AreaOfInterest (the Haar rectangle) and try to determine the movement of the person. This is very simple but might prove to be effective.. There are of course more complicated and accurate methods of tracking.

This is not very hard if your camera is stationary, otherwise it gets complicated. Also overlapping persons are tricky.

The method you can use depends on the application of this tool. If you want real-time tracking some options are unavailable, where as in post processing you can back-track frames for example and filter out false positives after you determine they were not real detections.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.