Commit b34f9cc43164e30d84ee64f3d3870b507c3aae39

Authored by Josh Klontz
1 parent 0fdd0580

DLandmarker cleanup

openbr/plugins/classification/dlib.cpp
@@ -74,25 +74,21 @@ private: @@ -74,25 +74,21 @@ private:
74 array2d<unsigned char> image; 74 array2d<unsigned char> image;
75 assign_image(image,cimg); 75 assign_image(image,cimg);
76 76
77 - if (src.file.rects().isEmpty()) { //If the image has no rects assume the whole image is a face  
78 - rectangle r(0, 0, cvImage.cols, cvImage.rows);  
79 - full_object_detection shape = (*sp)(image, r);  
80 - for (size_t i = 0; i < shape.num_parts(); i++)  
81 - dst.file.appendPoint(QPointF(shape.part(i)(0),shape.part(i)(1)));  
82 - setFacePoints(dst);  
83 - }  
84 - else { // Crop the image on the rects  
85 - for (int j=0; j<src.file.rects().size(); ++j)  
86 - {  
87 - QRectF rect = src.file.rects()[j];  
88 - rectangle r(rect.left(),rect.top(),rect.right(),rect.bottom());  
89 - full_object_detection shape = (*sp)(image, r);  
90 - for (size_t i=0; i<shape.num_parts(); i++)  
91 - dst.file.appendPoint(QPointF(shape.part(i)(0),shape.part(i)(1)));  
92 - setFacePoints(dst);  
93 - } 77 + rectangle r;
  78 + if (src.file.rects().isEmpty()) { // If the image has no rects assume the whole image is a face
  79 + r = rectangle(0, 0, cvImage.cols, cvImage.rows);
  80 + } else { // Crop the image on the first rect
  81 + const QRectF rect = src.file.rects().first();
  82 + r = rectangle(rect.left(), rect.top(), rect.right(), rect.bottom());
94 } 83 }
95 84
  85 + full_object_detection shape = (*sp)(image, r);
  86 + QList<QPointF> points;
  87 + for (size_t i=0; i<shape.num_parts(); i++)
  88 + points.append(QPointF(shape.part(i)(0), shape.part(i)(1)));
  89 + dst.file.setPoints(points);
  90 + setFacePoints(dst);
  91 +
96 shapeResource.release(sp); 92 shapeResource.release(sp);
97 } 93 }
98 }; 94 };