Merge pull request #14117 from 103yiran:103yiran-patch-dnn

* Postpone variable definitions

* dnn: reduce scope of 'Mat image' variable
pull/14244/head^2
103yiran 6 years ago committed by Alexander Alekhin
parent d4a96b699e
commit 4bb6edf176
  1. 13
      modules/dnn/src/dnn.cpp

@ -247,7 +247,7 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
std::vector<Mat> images;
images_.getMatVector(images);
CV_Assert(!images.empty());
for (int i = 0; i < images.size(); i++)
for (size_t i = 0; i < images.size(); i++)
{
Size imgSize = images[i].size();
if (size == Size())
@ -277,11 +277,10 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
images[i] *= scalefactor;
}
size_t i, nimages = images.size();
size_t nimages = images.size();
Mat image0 = images[0];
int nch = image0.channels();
CV_Assert(image0.dims == 2);
Mat image;
if (nch == 3 || nch == 4)
{
int sz[] = { (int)nimages, nch, image0.rows, image0.cols };
@ -289,9 +288,9 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
Mat blob = blob_.getMat();
Mat ch[4];
for( i = 0; i < nimages; i++ )
for(size_t i = 0; i < nimages; i++ )
{
image = images[i];
const Mat& image = images[i];
CV_Assert(image.depth() == blob_.depth());
nch = image.channels();
CV_Assert(image.dims == 2 && (nch == 3 || nch == 4));
@ -311,9 +310,9 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
blob_.create(4, sz, ddepth);
Mat blob = blob_.getMat();
for( i = 0; i < nimages; i++ )
for(size_t i = 0; i < nimages; i++ )
{
Mat image = images[i];
const Mat& image = images[i];
CV_Assert(image.depth() == blob_.depth());
nch = image.channels();
CV_Assert(image.dims == 2 && (nch == 1));

Loading…
Cancel
Save