Commit 4bb6edf1 authored by 103yiran's avatar 103yiran Committed by Alexander Alekhin

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

* Postpone variable definitions

* dnn: reduce scope of 'Mat image' variable
parent d4a96b69
...@@ -247,7 +247,7 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef ...@@ -247,7 +247,7 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
std::vector<Mat> images; std::vector<Mat> images;
images_.getMatVector(images); images_.getMatVector(images);
CV_Assert(!images.empty()); 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(); Size imgSize = images[i].size();
if (size == Size()) if (size == Size())
...@@ -277,11 +277,10 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef ...@@ -277,11 +277,10 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
images[i] *= scalefactor; images[i] *= scalefactor;
} }
size_t i, nimages = images.size(); size_t nimages = images.size();
Mat image0 = images[0]; Mat image0 = images[0];
int nch = image0.channels(); int nch = image0.channels();
CV_Assert(image0.dims == 2); CV_Assert(image0.dims == 2);
Mat image;
if (nch == 3 || nch == 4) if (nch == 3 || nch == 4)
{ {
int sz[] = { (int)nimages, nch, image0.rows, image0.cols }; int sz[] = { (int)nimages, nch, image0.rows, image0.cols };
...@@ -289,9 +288,9 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef ...@@ -289,9 +288,9 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
Mat blob = blob_.getMat(); Mat blob = blob_.getMat();
Mat ch[4]; 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()); CV_Assert(image.depth() == blob_.depth());
nch = image.channels(); nch = image.channels();
CV_Assert(image.dims == 2 && (nch == 3 || nch == 4)); CV_Assert(image.dims == 2 && (nch == 3 || nch == 4));
...@@ -311,9 +310,9 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef ...@@ -311,9 +310,9 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef
blob_.create(4, sz, ddepth); blob_.create(4, sz, ddepth);
Mat blob = blob_.getMat(); 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()); CV_Assert(image.depth() == blob_.depth());
nch = image.channels(); nch = image.channels();
CV_Assert(image.dims == 2 && (nch == 1)); CV_Assert(image.dims == 2 && (nch == 1));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment