From 23e876a316f1f195f1bce097b6646f3f76ec1636 Mon Sep 17 00:00:00 2001 From: Manuel Gunther <siebenkopf@googlemail.com> Date: Wed, 2 Nov 2016 14:26:40 -0600 Subject: [PATCH] restricted the automatically added boundary to be the image resolution --- bob/ip/flandmark/cpp/flandmark_detector.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bob/ip/flandmark/cpp/flandmark_detector.cpp b/bob/ip/flandmark/cpp/flandmark_detector.cpp index 085282f..eccc5c6 100644 --- a/bob/ip/flandmark/cpp/flandmark_detector.cpp +++ b/bob/ip/flandmark/cpp/flandmark_detector.cpp @@ -921,7 +921,7 @@ void flandmark_maximize_gdotprod(double * maximum, double * idx, const double * void flandmark_imcrop(const blitz::Array<uint8_t, 2>& input, blitz::Array<uint8_t,2>& output, int* bbx) { - if (bbx[0] < 0 or bbx[2] >= input.extent(0) or bbx[1] < 0 or bbx[3] >= input.extent(1)) + if (bbx[0] < 0 or bbx[2] > input.extent(0) or bbx[1] < 0 or bbx[3] > input.extent(1)) throw std::runtime_error("Bounding box exceeds image resolution"); output.resize(bbx[2]-bbx[0], bbx[3]-bbx[1]); @@ -947,6 +947,12 @@ void flandmark_get_normalized_image_frame(const blitz::Array<uint8_t, 2>& input, corrected_bbx[2] = int(c[0] + nd[0]/2.); corrected_bbx[3] = int(c[1] + nd[1]/2.); + // if extended bbx is larger than the image, reduce it + corrected_bbx[0] = std::max(corrected_bbx[0], 0); + corrected_bbx[1] = std::max(corrected_bbx[1], 0); + corrected_bbx[2] = std::min(corrected_bbx[2], bbox[2]); + corrected_bbx[3] = std::min(corrected_bbx[3], bbox[3]); + blitz::Array<uint8_t, 2> croppedImage; blitz::Array<double, 2> scaledImage(model->data.options.bw[1], model->data.options.bw[0]); -- GitLab