From 29faf164b9d1b2a4ac2a66bc9de3f6282e5c4b4b Mon Sep 17 00:00:00 2001 From: Vitaly Tuzov Date: Tue, 9 Jan 2018 20:30:39 +0300 Subject: [PATCH] Fixed exception when ROI for generated sample is evaluated out of image borders --- apps/createsamples/utility.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/createsamples/utility.cpp b/apps/createsamples/utility.cpp index 76734a154a8f..ece9c085daad 100644 --- a/apps/createsamples/utility.cpp +++ b/apps/createsamples/utility.cpp @@ -685,8 +685,8 @@ void icvPlaceDistortedSample( Mat background, Mat img( background.size(), CV_8UC1 ); Mat maskimg( background.size(), CV_8UC1 ); - resize( data->img(roi), img, img.size(), 0, 0, INTER_LINEAR_EXACT); - resize( data->maskimg(roi), maskimg, maskimg.size(), 0, 0, INTER_LINEAR_EXACT); + resize( data->img(roi & Rect(Point(0,0), data->img.size())), img, img.size(), 0, 0, INTER_LINEAR_EXACT); + resize( data->maskimg(roi & Rect(Point(0, 0), data->maskimg.size())), maskimg, maskimg.size(), 0, 0, INTER_LINEAR_EXACT); forecolordev = theRNG().uniform( -maxintensitydev, maxintensitydev );