roiIsUsed = true;
}
- if (minSize.width > 0 && minSize.height > 0 &&
- minSize.width <= image.cols && minSize.height <= image.rows) {
+ try {
m_faceCascade.detectMultiScale(
intrestingRegion,
faceLocations,
3,
0,
minSize);
-
- } else {
- m_faceCascade.detectMultiScale(intrestingRegion, faceLocations);
+ } catch (cv::Exception e) {
+ return false;
}
if (roiIsUsed) {
}
/* default path */
- cv::Size minSize(-1, -1);
+ cv::Size minSize(0, 0);
cv::Rect roi(-1, -1, -1, -1);
std::string haarcascadeFilePathStr =
"/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml";
if (engine_cfg) {
+ int minWidth, minHeight;
+
/* set face detection model */
char *haarcascadeFilepath;
error = mv_engine_config_get_string_attribute_c(
error = mv_engine_config_get_int_attribute_c(
engine_cfg,
MV_FACE_DETECTION_MIN_SIZE_WIDTH,
- &minSize.width);
+ &minWidth);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Error occurred during face detection minimum width receiving."
" (%i)", error);
error = mv_engine_config_get_int_attribute_c(
engine_cfg,
MV_FACE_DETECTION_MIN_SIZE_HEIGHT,
- &minSize.height);
+ &minHeight);
if (error != MEDIA_VISION_ERROR_NONE)
LOGE("Error occurred during face detection minimum height receiving."
" (%i)", error);
+
+ if (minWidth > 0 && minHeight > 0 &&
+ minWidth <= image.cols && minHeight <= image.rows) {
+ minSize.width = minWidth;
+ minSize.height = minHeight;
+ }
}
static FaceDetector faceDetector;