draw another rect after facedetection

asked 2016-04-06 09:37:46 -0500

moodyman gravatar image

updated 2016-04-06 11:50:06 -0500

Hello,

i am trying to locate the hair area after face detecting, and i thought about drawing a smaller rectangle at a certain position inside the face detection area. Assuming that the hair will always be on top of the face, i have been thinking of drawing a rectangle from the positions given by the face detection, and by modifying them to draw the new one. Now I am quite new to objectiv-C, and I would like some help to draw the rectangle, Here is my code:

#pragma mark - CvVideoCameraDelegate
- (void)processImage:(cv::Mat &)image {
    Mat gray;
    std::vector<cv::Rect> faces;
    Scalar color = Scalar(0, 255, 0);
    cvtColor(image, gray, COLOR_BGR2GRAY);
    _faceDetector.detectMultiScale(gray, faces, 1.1, 2, 0, cv::Size(60, 60));
    for (int i = 0; i < faces.size(); i++) {
        rectangle(image, faces[i], color, 1);
        // I think that i should write here the code for the new rect, so now i've been thinking of that, please correct me if i am wrong
// x, y should move the rectangle to the desired position
    int x = faces[i].x + x/3;
    int y = faces[i].y*0.2 - y/3;
    // h, w should resize the rectangle 
    int h = y+faces[i].height*0.1 ; //the smaller rect should be at least 10 times smaller, in order to get few pixels 
    int w = x+faces[i].width*0.1;

    rectangle(image, Point (x,y),Point (w,h), Scalar(255,0,255), 2, 8, 0);

    }
}


@end

thank you for your time

edit retag flag offensive close merge delete

Comments

what exactly is your question, now ?

berak gravatar imageberak ( 2016-04-06 10:08:36 -0500 )edit
2

try : cv::Point to overcome the ambiguity

berak gravatar imageberak ( 2016-04-06 10:53:48 -0500 )edit