From 2a8efda21b8b1e0d606ffe102d9ffa7d5effc237 Mon Sep 17 00:00:00 2001 From: bhklein Date: Mon, 17 Nov 2014 15:37:10 -0500 Subject: [PATCH] Attempt to enroll images with missing eye landmarks, crop image on face region. --- openbr/janus | 2 +- openbr/janus.cpp | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/openbr/janus b/openbr/janus index 65df749..5b73e1e 160000 --- a/openbr/janus +++ b/openbr/janus @@ -1 +1 @@ -Subproject commit 65df7498c5262343c07edc5c6f931178f121ca0b +Subproject commit 5b73e1e1884b136b0e98df687bee0e0e2203386e diff --git a/openbr/janus.cpp b/openbr/janus.cpp index 4dd05bb..dd6d332 100644 --- a/openbr/janus.cpp +++ b/openbr/janus.cpp @@ -51,23 +51,41 @@ janus_error janus_allocate_template(janus_template *template_) janus_error janus_augment(const janus_image image, const janus_attribute_list attributes, janus_template template_) { Template t; - t.append(cv::Mat(image.height, - image.width, - image.color_space == JANUS_GRAY8 ? CV_8UC1 : CV_8UC3, - image.data)); for (size_t i=0; i("RIGHT_EYE_X"), t.file.get("RIGHT_EYE_Y"))); - t.file.set("Affine_1", QPointF(t.file.get("LEFT_EYE_X"), t.file.get("LEFT_EYE_Y"))); - t.file.appendPoint(t.file.get("Affine_1")); - t.file.appendPoint(t.file.get("Affine_0")); + QRectF rect(t.file.get("FACE_X"), + t.file.get("FACE_Y"), + t.file.get("FACE_WIDTH"), + t.file.get("FACE_HEIGHT")); + + if (rect.x() < 0) rect.setX(0); + if (rect.y() < 0) rect.setY(0); + if (rect.x() + rect.width() > image.width) rect.setWidth(image.width - rect.x()); + if (rect.y() + rect.height() > image.height) rect.setHeight(image.height - rect.y()); + + cv::Mat input(image.height, + image.width, + image.color_space == JANUS_GRAY8 ? CV_8UC1 : CV_8UC3, + image.data); + + input = input(cv::Rect(rect.x(), rect.y(), rect.width(), rect.height())).clone(); + t.append(input); + if (t.file.contains("RIGHT_EYE_X") && + t.file.contains("RIGHT_EYE_Y") && + t.file.contains("LEFT_EYE_X") && + t.file.contains("LEFT_EYE_Y")) { + t.file.set("Affine_0", QPointF(t.file.get("RIGHT_EYE_X") - rect.x(), t.file.get("RIGHT_EYE_Y") - rect.y())); + t.file.set("Affine_1", QPointF(t.file.get("LEFT_EYE_X") - rect.x(), t.file.get("LEFT_EYE_Y") - rect.y())); + t.file.appendPoint(t.file.get("Affine_0")); + t.file.appendPoint(t.file.get("Affine_1")); + } Template u; transform->project(t, u); template_->append(u); -- libgit2 0.21.4