Fix DetectionModel in case of out of [0, 1] range detection prediction

This commit is contained in:
Dmitry Kurtaev 2019-09-13 11:33:24 +03:00
parent 1e410ed826
commit 3ddb005480
2 changed files with 23 additions and 1 deletions

View File

@ -230,7 +230,7 @@ void DetectionModel::detect(InputArray frame, CV_OUT std::vector<int>& classIds,
int width = right - left + 1;
int height = bottom - top + 1;
if (width * height <= 1)
if (width <= 2 || height <= 2)
{
left = data[j + 3] * frameWidth;
top = data[j + 4] * frameHeight;

View File

@ -221,6 +221,28 @@ TEST_P(Test_Model, DetectionMobilenetSSD)
scoreDiff, iouDiff, confThreshold, nmsThreshold, size, mean, scale);
}
TEST_P(Test_Model, Detection_normalized)
{
std::string img_path = _tf("grace_hopper_227.png");
std::vector<int> refClassIds = {15};
std::vector<float> refConfidences = {0.999222f};
std::vector<Rect2d> refBoxes = {Rect2d(0, 4, 227, 222)};
std::string weights_file = _tf("MobileNetSSD_deploy.caffemodel");
std::string config_file = _tf("MobileNetSSD_deploy.prototxt");
Scalar mean = Scalar(127.5, 127.5, 127.5);
double scale = 1.0 / 127.5;
Size size{300, 300};
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 5e-3 : 1e-5;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 1e-5;
float confThreshold = FLT_MIN;
double nmsThreshold = 0.0;
testDetectModel(weights_file, config_file, img_path, refClassIds, refConfidences, refBoxes,
scoreDiff, iouDiff, confThreshold, nmsThreshold, size, mean, scale);
}
TEST_P(Test_Model, Segmentation)
{
std::string inp = _tf("dog416.png");