Skip to content

Commit e6e1409

Browse files
committed
メモリ解法漏れ箇所を修正
1 parent a96ffa3 commit e6e1409

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

modules/ximgproc/src/sparse_table_morphology.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,20 +294,21 @@ void erode(InputArray _src, OutputArray _dst, InputArray _kernel, Point anchor,
294294
cv::copyMakeBorder(src, expandedSrc, anchor.y, kernel.cols - 1 - anchor.y, anchor.x, kernel.rows - 1 - anchor.x, borderType, bV);
295295

296296
// calculate sparse table nodes
297-
std::vector<std::vector<Mat*>> st(rowDepthLim, std::vector<Mat*>(colDepthLim));
298-
st[0][0] = &expandedSrc;
297+
std::vector<std::vector<Mat>> st(rowDepthLim, std::vector<Mat>(colDepthLim));
298+
st[0][0] = expandedSrc;
299299
for (int i = 0; i < stPlan.size(); i++)
300300
{
301301
StStep step = stPlan[i];
302+
Mat node(expandedSrc.rows, expandedSrc.cols, expandedSrc.type());
302303
switch (step.ax)
303304
{
304305
case Dim::Col:
305-
st[step.dimRow][step.dimCol + 1] = new Mat(expandedSrc.rows, expandedSrc.cols, expandedSrc.type());
306-
makeMinSparseTableMat(*st[step.dimRow][step.dimCol], *st[step.dimRow][step.dimCol + 1], 0, 1 << step.dimCol);
306+
st[step.dimRow][step.dimCol + 1] = node;
307+
makeMinSparseTableMat(st[step.dimRow][step.dimCol], st[step.dimRow][step.dimCol + 1], 0, 1 << step.dimCol);
307308
break;
308309
case Dim::Row:
309-
st[step.dimRow + 1][step.dimCol] = new Mat(expandedSrc.rows, expandedSrc.cols, expandedSrc.type());
310-
makeMinSparseTableMat(*st[step.dimRow][step.dimCol], *st[step.dimRow + 1][step.dimCol], 1 << step.dimRow, 0);
310+
st[step.dimRow + 1][step.dimCol] = node;
311+
makeMinSparseTableMat(st[step.dimRow][step.dimCol], st[step.dimRow + 1][step.dimCol], 1 << step.dimRow, 0);
311312
break;
312313
}
313314
}
@@ -319,7 +320,7 @@ void erode(InputArray _src, OutputArray _dst, InputArray _kernel, Point anchor,
319320
for (int i = 0; i < pow2Rects.size(); i++)
320321
{
321322
Rect rect = pow2Rects[i];
322-
Mat sparseMat = *st[rect.height][rect.width];
323+
Mat sparseMat = st[rect.height][rect.width];
323324
int sideBorderSkipStep = (kernel.cols - 1) * sparseMat.step.p[1];
324325
uchar* srcPtr = sparseMat.ptr(rect.y, rect.x);
325326
uchar* dstPtr = dst.ptr();

0 commit comments

Comments
 (0)