diff --git a/modules/ximgproc/src/structured_edge_detection.cpp b/modules/ximgproc/src/structured_edge_detection.cpp index f8d3cd6b882..7d07e67117f 100644 --- a/modules/ximgproc/src/structured_edge_detection.cpp +++ b/modules/ximgproc/src/structured_edge_detection.cpp @@ -801,9 +801,11 @@ class StructuredEdgeDetectionImpl : public StructuredEdgeDetection {// for j,k in [0;width)x[0;nTreesEval) int currentNode = pIndex[j*nTreesEval + k]; - - int start = __rf.edgeBoundaries[currentNode]; - int finish = __rf.edgeBoundaries[currentNode + 1]; + size_t sizeBoundaries = __rf.edgeBoundaries.size(); + int convertedBoundaries = static_cast(sizeBoundaries); + int nBnds = (convertedBoundaries - 1) / (nTreesNodes * nTrees); + int start = __rf.edgeBoundaries[currentNode * nBnds]; + int finish = __rf.edgeBoundaries[currentNode * nBnds + 1]; if (start == finish) continue;