From a4abeb3b1bdda5d98aaf9b34855fd132aec4a294 Mon Sep 17 00:00:00 2001 From: MaximSmolskiy Date: Thu, 16 Oct 2025 03:42:19 +0300 Subject: [PATCH] Fix findEllipses --- modules/ximgproc/src/find_ellipses.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ximgproc/src/find_ellipses.cpp b/modules/ximgproc/src/find_ellipses.cpp index b5ab61e7930..3164aa26f43 100644 --- a/modules/ximgproc/src/find_ellipses.cpp +++ b/modules/ximgproc/src/find_ellipses.cpp @@ -1301,12 +1301,12 @@ void EllipseDetectorImpl::preProcessing(Mat1b &src, Mat1b &dp, Mat1b &dn) { // 2 - the pixel does belong to an edge for (int i = 0; i <= imgSize.height; i++) { int *tmpMag = magBuffer[(i > 0) + 1] + 1; - const short *tmpDx = dx.ptr(i); - const short *tmpDy = dy.ptr(i); uchar *tmpMap; int prevFlag = 0; if (i < imgSize.height) { + const short *tmpDx = dx.ptr(i); + const short *tmpDy = dy.ptr(i); tmpMag[-1] = tmpMag[imgSize.width] = 0; for (int j = 0; j < imgSize.width; j++) tmpMag[j] = abs(tmpDx[j]) + abs(tmpDy[j]); @@ -1322,8 +1322,8 @@ void EllipseDetectorImpl::preProcessing(Mat1b &src, Mat1b &dp, Mat1b &dn) { tmpMap[-1] = tmpMap[imgSize.width] = 1; tmpMag = magBuffer[1] + 1; // take the central row - tmpDx = (short *) (dx[i - 1]); - tmpDy = (short *) (dy[i - 1]); + const short *tmpDx = dx.ptr(i - 1); + const short *tmpDy = dy.ptr(i - 1); ptrdiff_t magStep1, magStep2; magStep1 = magBuffer[2] - magBuffer[1];