Skip to content

Commit 945c8a5

Browse files
authored
Merge pull request #4025 from MaximSmolskiy:fix_findEllipses
Fix findEllipses
2 parents b23b765 + a4abeb3 commit 945c8a5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/ximgproc/src/find_ellipses.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,12 +1301,12 @@ void EllipseDetectorImpl::preProcessing(Mat1b &src, Mat1b &dp, Mat1b &dn) {
13011301
// 2 - the pixel does belong to an edge
13021302
for (int i = 0; i <= imgSize.height; i++) {
13031303
int *tmpMag = magBuffer[(i > 0) + 1] + 1;
1304-
const short *tmpDx = dx.ptr<short>(i);
1305-
const short *tmpDy = dy.ptr<short>(i);
13061304
uchar *tmpMap;
13071305
int prevFlag = 0;
13081306

13091307
if (i < imgSize.height) {
1308+
const short *tmpDx = dx.ptr<short>(i);
1309+
const short *tmpDy = dy.ptr<short>(i);
13101310
tmpMag[-1] = tmpMag[imgSize.width] = 0;
13111311
for (int j = 0; j < imgSize.width; j++)
13121312
tmpMag[j] = abs(tmpDx[j]) + abs(tmpDy[j]);
@@ -1322,8 +1322,8 @@ void EllipseDetectorImpl::preProcessing(Mat1b &src, Mat1b &dp, Mat1b &dn) {
13221322
tmpMap[-1] = tmpMap[imgSize.width] = 1;
13231323

13241324
tmpMag = magBuffer[1] + 1; // take the central row
1325-
tmpDx = (short *) (dx[i - 1]);
1326-
tmpDy = (short *) (dy[i - 1]);
1325+
const short *tmpDx = dx.ptr<short>(i - 1);
1326+
const short *tmpDy = dy.ptr<short>(i - 1);
13271327

13281328
ptrdiff_t magStep1, magStep2;
13291329
magStep1 = magBuffer[2] - magBuffer[1];

0 commit comments

Comments
 (0)