I have code:
void detectAndWrite( Mat frame )
{
std::vector<Rect> faces;
Mat frame_gray;
cvtColor( frame, frame_gray, CV_BGR2GRAY );
equalizeHist( frame_gray, frame_gray );
//-- Detect faces
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
for( int i = 0; i < faces.size(); i++ )
{
Point pt1(faces[i].x, faces[i].y);
Point pt2(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
cv::rectangle(frame, pt1, pt2, Scalar( 100, 100, 255 ));
}
//-- Write
imwrite("newimage.jpg", frame);
}
I gave the function a picture, two times. In first time it found a one object, so I saved new picture with one rectangle. In second time, it found two objects! And saved it in a file with three rectangles! But there is only two. I understood that probably some information about that picture in process saving in Cascade object(face_cascade). So I have two questions: 1. Why in different time it found different area of object? 2. How cascade remember picture with he already work? And object on it, how I can operate with it?