[Dclib-devel] Get wrong mmod_rect coords
Brought to you by:
davisking
From: Ben G. <ben...@gm...> - 2018-12-10 16:31:28
|
Hi, I'm using the the mmod_faces_detection example and I'm trying to get the faces rectangles coordinates with no luck, here is what I'm doing: std::vector<rectangle> getFacesVec(matrix<rgb_pixel> img) { net_type net; deserialize("mmod_human_face_detector.dat") >> net; std::vector<rectangle> r; // Upsampling the image will allow us to detect smaller faces but will cause the // program to use more RAM and run longer. while(img.size() < 1800*1800) pyramid_up(img); // Note that you can process a bunch of images in a std::vector at once and it runs // much faster, since this will form mini-batches of images and therefore get // better parallelism out of your GPU hardware. However, all the images must be // the same size. To avoid this requirement on images being the same size we // process them individually in this example. // We will also use a face landmarking model to align faces to a standard pose: (see face_landmark_detection_ex.cpp for an introduction) auto dets = net(img); for (auto&& d : dets) { r.push_back(d.rect); } return r; } .... faces = getFacesVec(img); for (auto f : faces) { cout << "Rect left: " << f.left() << endl; cout << "Rect right: " << f.right() << endl; cout << "Rect top: " << f.top() << endl; cout << "Rect bottom: " << f.bottom() << endl; cout << "Rect width: " << f.width() << endl; cout << "Rect height: " << f.height() << endl; cv::Rect roi(f.left(), f.top() , f.right(), f.bottom()); cout << "Trying to print cropped face" << endl; cout << "X = " << roi.x << " Y = " << roi.y << " Width = " << roi.width << " Height = " << roi.height << endl; cv::Mat crop = m(roi); sprintf(s, "%d.jpg", i++); cv::imwrite(s, crop); } and I'm getting coords out of the image scope like this: Mat rows: 432 Mat cols: 768 Rect left: 1068 Rect right: 1914 Rect top: 480 Rect bottom: 1325 Rect width: 847 Rect height: 846 What's I'm doing wrong? Regards, Ben |