mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-22 07:31:26 +08:00
stereo: fix crash
- uninitialized variable 'previous_size' - incorrect Mat element access pattern via address arithmetic
This commit is contained in:
@@ -366,13 +366,12 @@ namespace cv
|
|||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
//arrays used in the region removal
|
//arrays used in the region removal
|
||||||
Mat speckleY;
|
Mat_<int> speckleY;
|
||||||
Mat speckleX;
|
Mat_<int> speckleX;
|
||||||
Mat puss;
|
Mat_<int> puss;
|
||||||
//int *specklePointX;
|
//int *specklePointX;
|
||||||
//int *specklePointY;
|
//int *specklePointY;
|
||||||
//long long *pus;
|
//long long *pus;
|
||||||
int previous_size;
|
|
||||||
//!method for setting the maximum disparity
|
//!method for setting the maximum disparity
|
||||||
void setMaxDisparity(int val)
|
void setMaxDisparity(int val)
|
||||||
{
|
{
|
||||||
@@ -480,10 +479,10 @@ namespace cv
|
|||||||
CV_Assert(currentMap.cols == out.cols);
|
CV_Assert(currentMap.cols == out.cols);
|
||||||
CV_Assert(currentMap.rows == out.rows);
|
CV_Assert(currentMap.rows == out.rows);
|
||||||
CV_Assert(t >= 0);
|
CV_Assert(t >= 0);
|
||||||
int *pus = (int *)puss.data;
|
CV_Assert(!puss.empty());
|
||||||
int *specklePointX = (int *)speckleX.data;
|
int *specklePointX = (int *)speckleX.data;
|
||||||
int *specklePointY = (int *)speckleY.data;
|
int *specklePointY = (int *)speckleY.data;
|
||||||
memset(pus, 0, previous_size * sizeof(pus[0]));
|
puss.setTo(Scalar::all(0));
|
||||||
T *map = (T *)currentMap.data;
|
T *map = (T *)currentMap.data;
|
||||||
T *outputMap = (T *)out.data;
|
T *outputMap = (T *)out.data;
|
||||||
int height = currentMap.rows;
|
int height = currentMap.rows;
|
||||||
@@ -511,7 +510,7 @@ namespace cv
|
|||||||
speckle_size = dr;
|
speckle_size = dr;
|
||||||
specklePointX[dr] = i;
|
specklePointX[dr] = i;
|
||||||
specklePointY[dr] = j;
|
specklePointY[dr] = j;
|
||||||
pus[i * width + j] = 1;
|
puss(i, j) = 1;
|
||||||
dr++;
|
dr++;
|
||||||
map[iw + j] = k;
|
map[iw + j] = k;
|
||||||
while (st < dr)
|
while (st < dr)
|
||||||
@@ -522,7 +521,7 @@ namespace cv
|
|||||||
for (int d = 0; d < 8; d++)
|
for (int d = 0; d < 8; d++)
|
||||||
{//if insisde
|
{//if insisde
|
||||||
if (ii + di[d] >= 0 && ii + di[d] < height && jj + dj[d] >= 0 && jj + dj[d] < width &&
|
if (ii + di[d] >= 0 && ii + di[d] < height && jj + dj[d] >= 0 && jj + dj[d] < width &&
|
||||||
pus[(ii + di[d]) * width + jj + dj[d]] == 0)
|
puss(ii + di[d], jj + dj[d]) == 0)
|
||||||
{
|
{
|
||||||
T val = map[(ii + di[d]) * width + jj + dj[d]];
|
T val = map[(ii + di[d]) * width + jj + dj[d]];
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
@@ -531,7 +530,7 @@ namespace cv
|
|||||||
specklePointX[dr] = (ii + di[d]);
|
specklePointX[dr] = (ii + di[d]);
|
||||||
specklePointY[dr] = (jj + dj[d]);
|
specklePointY[dr] = (jj + dj[d]);
|
||||||
dr++;
|
dr++;
|
||||||
pus[(ii + di[d]) * width + jj + dj[d]] = 1;
|
puss(ii + di[d], jj + dj[d]) = 1;
|
||||||
}//this means that my point is a good point to be used in computing the final filling value
|
}//this means that my point is a good point to be used in computing the final filling value
|
||||||
else if (val >= 1 && val < 250)
|
else if (val >= 1 && val < 250)
|
||||||
{
|
{
|
||||||
|
@@ -275,7 +275,6 @@ namespace cv
|
|||||||
StereoBinaryBMImpl(int _numDisparities, int _kernelSize) : Matching(_numDisparities)
|
StereoBinaryBMImpl(int _numDisparities, int _kernelSize) : Matching(_numDisparities)
|
||||||
{
|
{
|
||||||
params = StereoBinaryBMParams(_numDisparities, _kernelSize);
|
params = StereoBinaryBMParams(_numDisparities, _kernelSize);
|
||||||
previous_size = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void compute(InputArray leftarr, InputArray rightarr, OutputArray disparr)
|
void compute(InputArray leftarr, InputArray rightarr, OutputArray disparr)
|
||||||
@@ -322,12 +321,11 @@ namespace cv
|
|||||||
|
|
||||||
int width = left0.cols;
|
int width = left0.cols;
|
||||||
int height = left0.rows;
|
int height = left0.rows;
|
||||||
if(previous_size != width * height)
|
if (puss.total() != (size_t)width * height)
|
||||||
{
|
{
|
||||||
previous_size = width * height;
|
speckleX.create(height, width);
|
||||||
speckleX.create(height,width,CV_32SC4);
|
speckleY.create(height, width);
|
||||||
speckleY.create(height,width,CV_32SC4);
|
puss.create(height, width);
|
||||||
puss.create(height,width,CV_32SC4);
|
|
||||||
|
|
||||||
censusImage[0].create(left0.rows,left0.cols,CV_32SC4);
|
censusImage[0].create(left0.rows,left0.cols,CV_32SC4);
|
||||||
censusImage[1].create(left0.rows,left0.cols,CV_32SC4);
|
censusImage[1].create(left0.rows,left0.cols,CV_32SC4);
|
||||||
|
@@ -692,12 +692,11 @@ namespace cv
|
|||||||
{
|
{
|
||||||
int width = left.cols;
|
int width = left.cols;
|
||||||
int height = left.rows;
|
int height = left.rows;
|
||||||
if(previous_size != width * height)
|
if (puss.total() != (size_t)width * height)
|
||||||
{
|
{
|
||||||
previous_size = width * height;
|
speckleX.create(height, width);
|
||||||
speckleX.create(height,width,CV_32SC4);
|
speckleY.create(height, width);
|
||||||
speckleY.create(height,width,CV_32SC4);
|
puss.create(height, width);
|
||||||
puss.create(height,width,CV_32SC4);
|
|
||||||
}
|
}
|
||||||
Mat aux;
|
Mat aux;
|
||||||
aux.create(height,width,CV_16S);
|
aux.create(height,width,CV_16S);
|
||||||
|
Reference in New Issue
Block a user