C-API cleanup: use AutoBuffer in MSER

pull/26228/head
Maksim Shabunin 2 months ago
parent 658336b366
commit 72023951ea
  1. 12
      modules/features2d/src/mser.cpp

@ -873,10 +873,13 @@ extractMSER_8uC3( const Mat& src,
const MSER_Impl::Params& params ) const MSER_Impl::Params& params )
{ {
bboxvec.clear(); bboxvec.clear();
MSCRNode* map = (MSCRNode*)cvAlloc( src.cols*src.rows*sizeof(map[0]) ); AutoBuffer<MSCRNode> mapBuf(src.cols*src.rows);
MSCRNode* map = mapBuf.data();
int Ne = src.cols*src.rows*2-src.cols-src.rows; int Ne = src.cols*src.rows*2-src.cols-src.rows;
MSCREdge* edge = (MSCREdge*)cvAlloc( Ne*sizeof(edge[0]) ); AutoBuffer<MSCREdge> edgeBuf(Ne);
TempMSCR* mscr = (TempMSCR*)cvAlloc( src.cols*src.rows*sizeof(mscr[0]) ); MSCREdge* edge = edgeBuf.data();
AutoBuffer<TempMSCR> mscrBuf(src.cols*src.rows);
TempMSCR* mscr = mscrBuf.data();
double emean = 0; double emean = 0;
Mat dx( src.rows, src.cols-1, CV_64FC1 ); Mat dx( src.rows, src.cols-1, CV_64FC1 );
Mat dy( src.rows-1, src.cols, CV_64FC1 ); Mat dy( src.rows-1, src.cols, CV_64FC1 );
@ -987,9 +990,6 @@ extractMSER_8uC3( const Mat& src,
} }
bboxvec.push_back(Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1)); bboxvec.push_back(Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1));
} }
cvFree( &mscr );
cvFree( &edge );
cvFree( &map );
} }
void MSER_Impl::detectRegions( InputArray _src, vector<vector<Point> >& msers, vector<Rect>& bboxes ) void MSER_Impl::detectRegions( InputArray _src, vector<vector<Point> >& msers, vector<Rect>& bboxes )

Loading…
Cancel
Save