Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

check if Rects intersect

hi all, I wanted to implement a simple check to see if the face in the new frame is the same as in the previous frame. I cobbled up something like below:

But i don't think its working. Is it because when i make a copy of the faces vector, it is not a deep copy?

   haar_cascade.detectMultiScale(gray, faces,1.2,4,0|CASCADE_SCALE_IMAGE, Size(min_face_size,min_face_size),Size(max_face_size,max_face_size));
    // At this point you have the position of the faces in
    // faces. Now we'll get the faces, make a prediction and
    // annotate it in the video. Cool or what?

    vector< Rect_<int> > track=faces; // Keep the old faces in a separate vector

    Mat face_resized;

    for(int i = 0; i < faces.size(); i++) {
    Rect a=track[i];
    Rect b=faces[i];
    bool intersects=((a&b).area()>0);
    if(intersects) cout << "same window" << endl;
    else cout << "different window" << endl;
        // Process face by face:
        Rect face_i = faces[i];
        // Crop the face from the image. So simple with OpenCV C++:

        Mat face = gray(face_i);