Commit d8774f27b2c194abfeb717428d5629738930e335
1 parent
f17baf81
DLandmarker with no rect specified
Showing
1 changed file
with
14 additions
and
8 deletions
openbr/plugins/classification/dlib.cpp
| @@ -49,15 +49,21 @@ private: | @@ -49,15 +49,21 @@ private: | ||
| 49 | 49 | ||
| 50 | void project(const Template &src, Template &dst) const | 50 | void project(const Template &src, Template &dst) const |
| 51 | { | 51 | { |
| 52 | - dst = src; | 52 | + dst = src; |
| 53 | 53 | ||
| 54 | - if (!src.file.rects().isEmpty()) { | ||
| 55 | - shape_predictor *sp = shapeResource.acquire(); | 54 | + shape_predictor *sp = shapeResource.acquire(); |
| 56 | 55 | ||
| 57 | - cv_image<unsigned char> cimg(src.m()); | ||
| 58 | - array2d<unsigned char> image; | ||
| 59 | - assign_image(image,cimg); | 56 | + cv_image<unsigned char> cimg(src.m()); |
| 57 | + array2d<unsigned char> image; | ||
| 58 | + assign_image(image,cimg); | ||
| 60 | 59 | ||
| 60 | + if (src.file.rects().isEmpty()) { //If the image has no rects assume the whole image is a face | ||
| 61 | + rectangle r(0, 0, src.m().cols, src.m().rows); | ||
| 62 | + full_object_detection shape = (*sp)(image, r); | ||
| 63 | + for (size_t i = 0; i < shape.num_parts(); i++) | ||
| 64 | + dst.file.appendPoint(QPointF(shape.part(i)(0),shape.part(i)(1))); | ||
| 65 | + } | ||
| 66 | + else { // Crop the image on the rects | ||
| 61 | for (int j=0; j<src.file.rects().size(); ++j) | 67 | for (int j=0; j<src.file.rects().size(); ++j) |
| 62 | { | 68 | { |
| 63 | QRectF rect = src.file.rects()[j]; | 69 | QRectF rect = src.file.rects()[j]; |
| @@ -66,9 +72,9 @@ private: | @@ -66,9 +72,9 @@ private: | ||
| 66 | for (size_t i=0; i<shape.num_parts(); i++) | 72 | for (size_t i=0; i<shape.num_parts(); i++) |
| 67 | dst.file.appendPoint(QPointF(shape.part(i)(0),shape.part(i)(1))); | 73 | dst.file.appendPoint(QPointF(shape.part(i)(0),shape.part(i)(1))); |
| 68 | } | 74 | } |
| 69 | - | ||
| 70 | - shapeResource.release(sp); | ||
| 71 | } | 75 | } |
| 76 | + | ||
| 77 | + shapeResource.release(sp); | ||
| 72 | } | 78 | } |
| 73 | }; | 79 | }; |
| 74 | 80 |