From 254d4ae42960d836e34bebca99e31a5f8b45d723 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 16:39:58 +0400 Subject: [PATCH] Boring changes - imgproc. --- modules/imgproc/include/opencv2/imgproc.hpp | 2 +- modules/imgproc/src/clahe.cpp | 2 +- modules/imgproc/src/contours.cpp | 4 +- modules/imgproc/src/filter.cpp | 192 ++++++++++++++-------------- modules/imgproc/src/generalized_hough.cpp | 4 +- modules/imgproc/src/hough.cpp | 14 +- modules/imgproc/src/imgwarp.cpp | 8 +- modules/imgproc/src/lsd.cpp | 4 +- modules/imgproc/src/morph.cpp | 110 ++++++++-------- modules/imgproc/src/smooth.cpp | 48 +++---- modules/imgproc/test/test_convhull.cpp | 2 +- 11 files changed, 195 insertions(+), 195 deletions(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 24d9f44..55816cc 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -656,7 +656,7 @@ public: Point dstOfs = Point(0,0), bool isolated = false); //! returns true if the filter is separable - bool isSeparable() const { return (const BaseFilter*)filter2D == 0; } + bool isSeparable() const { return !filter2D; } //! returns the number int remainingInputRows() const; int remainingOutputRows() const; diff --git a/modules/imgproc/src/clahe.cpp b/modules/imgproc/src/clahe.cpp index 4ce4797..89fb62b 100644 --- a/modules/imgproc/src/clahe.cpp +++ b/modules/imgproc/src/clahe.cpp @@ -330,5 +330,5 @@ namespace cv::Ptr cv::createCLAHE(double clipLimit, cv::Size tileGridSize) { - return new CLAHE_Impl(clipLimit, tileGridSize.width, tileGridSize.height); + return makePtr(clipLimit, tileGridSize.width, tileGridSize.height); } diff --git a/modules/imgproc/src/contours.cpp b/modules/imgproc/src/contours.cpp index 6f5b0c8..797f8c5 100644 --- a/modules/imgproc/src/contours.cpp +++ b/modules/imgproc/src/contours.cpp @@ -1339,8 +1339,8 @@ icvFindContoursInInterval( const CvArr* src, if( contourHeaderSize < (int)sizeof(CvContour)) CV_Error( CV_StsBadSize, "Contour header size must be >= sizeof(CvContour)" ); - storage00 = cvCreateChildMemStorage(storage); - storage01 = cvCreateChildMemStorage(storage); + storage00.reset(cvCreateChildMemStorage(storage)); + storage01.reset(cvCreateChildMemStorage(storage)); CvMat stub, *mat; diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp index 86322e4..f7e7efa 100644 --- a/modules/imgproc/src/filter.cpp +++ b/modules/imgproc/src/filter.cpp @@ -117,7 +117,7 @@ void FilterEngine::init( const Ptr& _filter2D, if( isSeparable() ) { - CV_Assert( !rowFilter.empty() && !columnFilter.empty() ); + CV_Assert( rowFilter && columnFilter ); ksize = Size(rowFilter->ksize, columnFilter->ksize); anchor = Point(rowFilter->anchor, columnFilter->anchor); } @@ -244,9 +244,9 @@ int FilterEngine::start(Size _wholeSize, Rect _roi, int _maxBufRows) rowCount = dstY = 0; startY = startY0 = std::max(roi.y - anchor.y, 0); endY = std::min(roi.y + roi.height + ksize.height - anchor.y - 1, wholeSize.height); - if( !columnFilter.empty() ) + if( columnFilter ) columnFilter->reset(); - if( !filter2D.empty() ) + if( filter2D ) filter2D->reset(); return startY; @@ -2735,42 +2735,42 @@ cv::Ptr cv::getLinearRowFilter( int srcType, int bufType, if( (symmetryType & (KERNEL_SYMMETRICAL|KERNEL_ASYMMETRICAL)) != 0 && ksize <= 5 ) { if( sdepth == CV_8U && ddepth == CV_32S ) - return Ptr(new SymmRowSmallFilter - (kernel, anchor, symmetryType, SymmRowSmallVec_8u32s(kernel, symmetryType))); + return makePtr > + (kernel, anchor, symmetryType, SymmRowSmallVec_8u32s(kernel, symmetryType)); if( sdepth == CV_32F && ddepth == CV_32F ) - return Ptr(new SymmRowSmallFilter - (kernel, anchor, symmetryType, SymmRowSmallVec_32f(kernel, symmetryType))); + return makePtr > + (kernel, anchor, symmetryType, SymmRowSmallVec_32f(kernel, symmetryType)); } if( sdepth == CV_8U && ddepth == CV_32S ) - return Ptr(new RowFilter - (kernel, anchor, RowVec_8u32s(kernel))); + return makePtr > + (kernel, anchor, RowVec_8u32s(kernel)); if( sdepth == CV_8U && ddepth == CV_32F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_8U && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_16U && ddepth == CV_32F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_16U && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_16S && ddepth == CV_32F ) - return Ptr(new RowFilter - (kernel, anchor, RowVec_16s32f(kernel))); + return makePtr > + (kernel, anchor, RowVec_16s32f(kernel)); if( sdepth == CV_16S && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_32F && ddepth == CV_32F ) - return Ptr(new RowFilter - (kernel, anchor, RowVec_32f(kernel))); + return makePtr > + (kernel, anchor, RowVec_32f(kernel)); if( sdepth == CV_32F && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_64F && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); CV_Error_( CV_StsNotImplemented, ("Unsupported combination of source format (=%d), and buffer format (=%d)", srcType, bufType)); - return Ptr(0); + return Ptr(); } @@ -2789,24 +2789,24 @@ cv::Ptr cv::getLinearColumnFilter( int bufType, int dstTyp if( !(symmetryType & (KERNEL_SYMMETRICAL|KERNEL_ASYMMETRICAL)) ) { if( ddepth == CV_8U && sdepth == CV_32S ) - return Ptr(new ColumnFilter, ColumnNoVec> - (kernel, anchor, delta, FixedPtCastEx(bits))); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, FixedPtCastEx(bits)); if( ddepth == CV_8U && sdepth == CV_32F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_8U && sdepth == CV_64F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_16U && sdepth == CV_32F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_16U && sdepth == CV_64F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_16S && sdepth == CV_32F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_16S && sdepth == CV_64F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_32F && sdepth == CV_32F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_64F && sdepth == CV_64F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); } else { @@ -2814,60 +2814,60 @@ cv::Ptr cv::getLinearColumnFilter( int bufType, int dstTyp if( ksize == 3 ) { if( ddepth == CV_8U && sdepth == CV_32S ) - return Ptr(new SymmColumnSmallFilter< - FixedPtCastEx, SymmColumnVec_32s8u> + return makePtr, SymmColumnVec_32s8u> > (kernel, anchor, delta, symmetryType, FixedPtCastEx(bits), - SymmColumnVec_32s8u(kernel, symmetryType, bits, delta))); + SymmColumnVec_32s8u(kernel, symmetryType, bits, delta)); if( ddepth == CV_16S && sdepth == CV_32S && bits == 0 ) - return Ptr(new SymmColumnSmallFilter, - SymmColumnSmallVec_32s16s>(kernel, anchor, delta, symmetryType, - Cast(), SymmColumnSmallVec_32s16s(kernel, symmetryType, bits, delta))); + return makePtr, + SymmColumnSmallVec_32s16s> >(kernel, anchor, delta, symmetryType, + Cast(), SymmColumnSmallVec_32s16s(kernel, symmetryType, bits, delta)); if( ddepth == CV_32F && sdepth == CV_32F ) - return Ptr(new SymmColumnSmallFilter< - Cast,SymmColumnSmallVec_32f> + return makePtr,SymmColumnSmallVec_32f> > (kernel, anchor, delta, symmetryType, Cast(), - SymmColumnSmallVec_32f(kernel, symmetryType, 0, delta))); + SymmColumnSmallVec_32f(kernel, symmetryType, 0, delta)); } if( ddepth == CV_8U && sdepth == CV_32S ) - return Ptr(new SymmColumnFilter, SymmColumnVec_32s8u> + return makePtr, SymmColumnVec_32s8u> > (kernel, anchor, delta, symmetryType, FixedPtCastEx(bits), - SymmColumnVec_32s8u(kernel, symmetryType, bits, delta))); + SymmColumnVec_32s8u(kernel, symmetryType, bits, delta)); if( ddepth == CV_8U && sdepth == CV_32F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_8U && sdepth == CV_64F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_16U && sdepth == CV_32F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_16U && sdepth == CV_64F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_16S && sdepth == CV_32S ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_16S && sdepth == CV_32F ) - return Ptr(new SymmColumnFilter, SymmColumnVec_32f16s> + return makePtr, SymmColumnVec_32f16s> > (kernel, anchor, delta, symmetryType, Cast(), - SymmColumnVec_32f16s(kernel, symmetryType, 0, delta))); + SymmColumnVec_32f16s(kernel, symmetryType, 0, delta)); if( ddepth == CV_16S && sdepth == CV_64F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_32F && sdepth == CV_32F ) - return Ptr(new SymmColumnFilter, SymmColumnVec_32f> + return makePtr, SymmColumnVec_32f> > (kernel, anchor, delta, symmetryType, Cast(), - SymmColumnVec_32f(kernel, symmetryType, 0, delta))); + SymmColumnVec_32f(kernel, symmetryType, 0, delta)); if( ddepth == CV_64F && sdepth == CV_64F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); } CV_Error_( CV_StsNotImplemented, ("Unsupported combination of buffer format (=%d), and destination format (=%d)", bufType, dstType)); - return Ptr(0); + return Ptr(); } @@ -2933,7 +2933,7 @@ cv::Ptr cv::createSeparableLinearFilter( Ptr _columnFilter = getLinearColumnFilter( _bufType, _dstType, columnKernel, _anchor.y, ctype, _delta, bits ); - return Ptr( new FilterEngine(Ptr(0), _rowFilter, _columnFilter, + return Ptr( new FilterEngine(Ptr(), _rowFilter, _columnFilter, _srcType, _dstType, _bufType, _rowBorderType, _columnBorderType, _borderValue )); } @@ -3085,13 +3085,13 @@ cv::Ptr cv::getLinearFilter(int srcType, int dstType, anchor = normalizeAnchor(anchor, _kernel.size()); /*if( sdepth == CV_8U && ddepth == CV_8U && kdepth == CV_32S ) - return Ptr(new Filter2D, FilterVec_8u> + return makePtr, FilterVec_8u> > (_kernel, anchor, delta, FixedPtCastEx(bits), - FilterVec_8u(_kernel, bits, delta))); + FilterVec_8u(_kernel, bits, delta)); if( sdepth == CV_8U && ddepth == CV_16S && kdepth == CV_32S ) - return Ptr(new Filter2D, FilterVec_8u16s> + return makePtr, FilterVec_8u16s> > (_kernel, anchor, delta, FixedPtCastEx(bits), - FilterVec_8u16s(_kernel, bits, delta)));*/ + FilterVec_8u16s(_kernel, bits, delta));*/ kdepth = sdepth == CV_64F || ddepth == CV_64F ? CV_64F : CV_32F; Mat kernel; @@ -3101,53 +3101,53 @@ cv::Ptr cv::getLinearFilter(int srcType, int dstType, _kernel.convertTo(kernel, kdepth, _kernel.type() == CV_32S ? 1./(1 << bits) : 1.); if( sdepth == CV_8U && ddepth == CV_8U ) - return Ptr(new Filter2D, FilterVec_8u> - (kernel, anchor, delta, Cast(), FilterVec_8u(kernel, 0, delta))); + return makePtr, FilterVec_8u> > + (kernel, anchor, delta, Cast(), FilterVec_8u(kernel, 0, delta)); if( sdepth == CV_8U && ddepth == CV_16U ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_8U && ddepth == CV_16S ) - return Ptr(new Filter2D, FilterVec_8u16s> - (kernel, anchor, delta, Cast(), FilterVec_8u16s(kernel, 0, delta))); + return makePtr, FilterVec_8u16s> > + (kernel, anchor, delta, Cast(), FilterVec_8u16s(kernel, 0, delta)); if( sdepth == CV_8U && ddepth == CV_32F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_8U && ddepth == CV_64F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16U && ddepth == CV_16U ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16U && ddepth == CV_32F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16U && ddepth == CV_64F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16S && ddepth == CV_16S ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16S && ddepth == CV_32F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16S && ddepth == CV_64F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_32F && ddepth == CV_32F ) - return Ptr(new Filter2D, FilterVec_32f> - (kernel, anchor, delta, Cast(), FilterVec_32f(kernel, 0, delta))); + return makePtr, FilterVec_32f> > + (kernel, anchor, delta, Cast(), FilterVec_32f(kernel, 0, delta)); if( sdepth == CV_64F && ddepth == CV_64F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); CV_Error_( CV_StsNotImplemented, ("Unsupported combination of source format (=%d), and destination format (=%d)", srcType, dstType)); - return Ptr(0); + return Ptr(); } @@ -3178,9 +3178,9 @@ cv::Ptr cv::createLinearFilter( int _srcType, int _dstType, Ptr _filter2D = getLinearFilter(_srcType, _dstType, kernel, _anchor, _delta, bits); - return Ptr(new FilterEngine(_filter2D, Ptr(0), - Ptr(0), _srcType, _dstType, _srcType, - _rowBorderType, _columnBorderType, _borderValue )); + return makePtr(_filter2D, Ptr(), + Ptr(), _srcType, _dstType, _srcType, + _rowBorderType, _columnBorderType, _borderValue ); } diff --git a/modules/imgproc/src/generalized_hough.cpp b/modules/imgproc/src/generalized_hough.cpp index 7ee3b70..a261d64 100644 --- a/modules/imgproc/src/generalized_hough.cpp +++ b/modules/imgproc/src/generalized_hough.cpp @@ -491,7 +491,7 @@ namespace Ptr cv::createGeneralizedHoughBallard() { - return new GeneralizedHoughBallardImpl; + return makePtr(); } // GeneralizedHoughGuil @@ -940,5 +940,5 @@ namespace Ptr cv::createGeneralizedHoughGuil() { - return new GeneralizedHoughGuilImpl; + return makePtr(); } diff --git a/modules/imgproc/src/hough.cpp b/modules/imgproc/src/hough.cpp index f33c6d2..9c8eaca 100644 --- a/modules/imgproc/src/hough.cpp +++ b/modules/imgproc/src/hough.cpp @@ -766,21 +766,21 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist, float idp, dr; CvSeqReader reader; - edges = cvCreateMat( img->rows, img->cols, CV_8UC1 ); + edges.reset(cvCreateMat( img->rows, img->cols, CV_8UC1 )); cvCanny( img, edges, MAX(canny_threshold/2,1), canny_threshold, 3 ); - dx = cvCreateMat( img->rows, img->cols, CV_16SC1 ); - dy = cvCreateMat( img->rows, img->cols, CV_16SC1 ); + dx.reset(cvCreateMat( img->rows, img->cols, CV_16SC1 )); + dy.reset(cvCreateMat( img->rows, img->cols, CV_16SC1 )); cvSobel( img, dx, 1, 0, 3 ); cvSobel( img, dy, 0, 1, 3 ); if( dp < 1.f ) dp = 1.f; idp = 1.f/dp; - accum = cvCreateMat( cvCeil(img->rows*idp)+2, cvCeil(img->cols*idp)+2, CV_32SC1 ); + accum.reset(cvCreateMat( cvCeil(img->rows*idp)+2, cvCeil(img->cols*idp)+2, CV_32SC1 )); cvZero(accum); - storage = cvCreateMemStorage(); + storage.reset(cvCreateMemStorage()); nz = cvCreateSeq( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), storage ); centers = cvCreateSeq( CV_32SC1, sizeof(CvSeq), sizeof(int), storage ); @@ -866,7 +866,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist, cvClearSeq( centers ); cvSeqPushMulti( centers, &sort_buf[0], center_count ); - dist_buf = cvCreateMat( 1, nz_count, CV_32FC1 ); + dist_buf.reset(cvCreateMat( 1, nz_count, CV_32FC1 )); ddata = dist_buf->data.fl; dr = dp; @@ -1060,7 +1060,7 @@ void cv::HoughCircles( InputArray _image, OutputArray _circles, double param1, double param2, int minRadius, int maxRadius ) { - Ptr storage = cvCreateMemStorage(STORAGE_SIZE); + Ptr storage(cvCreateMemStorage(STORAGE_SIZE)); Mat image = _image.getMat(); CvMat c_image = image; CvSeq* seq = cvHoughCircles( &c_image, storage, method, diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 05a9630..32a1517 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -3931,8 +3931,8 @@ cvLogPolar( const CvArr* srcarr, CvArr* dstarr, ssize = cvGetMatSize(src); dsize = cvGetMatSize(dst); - mapx = cvCreateMat( dsize.height, dsize.width, CV_32F ); - mapy = cvCreateMat( dsize.height, dsize.width, CV_32F ); + mapx.reset(cvCreateMat( dsize.height, dsize.width, CV_32F )); + mapy.reset(cvCreateMat( dsize.height, dsize.width, CV_32F )); if( !(flags & CV_WARP_INVERSE_MAP) ) { @@ -4049,8 +4049,8 @@ void cvLinearPolar( const CvArr* srcarr, CvArr* dstarr, dsize.width = dst->cols; dsize.height = dst->rows; - mapx = cvCreateMat( dsize.height, dsize.width, CV_32F ); - mapy = cvCreateMat( dsize.height, dsize.width, CV_32F ); + mapx.reset(cvCreateMat( dsize.height, dsize.width, CV_32F )); + mapy.reset(cvCreateMat( dsize.height, dsize.width, CV_32F )); if( !(flags & CV_WARP_INVERSE_MAP) ) { diff --git a/modules/imgproc/src/lsd.cpp b/modules/imgproc/src/lsd.cpp index 58d226f..f468c61 100644 --- a/modules/imgproc/src/lsd.cpp +++ b/modules/imgproc/src/lsd.cpp @@ -393,9 +393,9 @@ CV_EXPORTS Ptr createLineSegmentDetectorPtr( int _refine, double _scale, double _sigma_scale, double _quant, double _ang_th, double _log_eps, double _density_th, int _n_bins) { - return Ptr(new LineSegmentDetectorImpl( + return makePtr( _refine, _scale, _sigma_scale, _quant, _ang_th, - _log_eps, _density_th, _n_bins)); + _log_eps, _density_th, _n_bins); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index ef91902..33ddcf7 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -857,42 +857,42 @@ cv::Ptr cv::getMorphologyRowFilter(int op, int type, int ksiz if( op == MORPH_ERODE ) { if( depth == CV_8U ) - return Ptr(new MorphRowFilter, - ErodeRowVec8u>(ksize, anchor)); + return makePtr, + ErodeRowVec8u> >(ksize, anchor); if( depth == CV_16U ) - return Ptr(new MorphRowFilter, - ErodeRowVec16u>(ksize, anchor)); + return makePtr, + ErodeRowVec16u> >(ksize, anchor); if( depth == CV_16S ) - return Ptr(new MorphRowFilter, - ErodeRowVec16s>(ksize, anchor)); + return makePtr, + ErodeRowVec16s> >(ksize, anchor); if( depth == CV_32F ) - return Ptr(new MorphRowFilter, - ErodeRowVec32f>(ksize, anchor)); + return makePtr, + ErodeRowVec32f> >(ksize, anchor); if( depth == CV_64F ) - return Ptr(new MorphRowFilter, - ErodeRowVec64f>(ksize, anchor)); + return makePtr, + ErodeRowVec64f> >(ksize, anchor); } else { if( depth == CV_8U ) - return Ptr(new MorphRowFilter, - DilateRowVec8u>(ksize, anchor)); + return makePtr, + DilateRowVec8u> >(ksize, anchor); if( depth == CV_16U ) - return Ptr(new MorphRowFilter, - DilateRowVec16u>(ksize, anchor)); + return makePtr, + DilateRowVec16u> >(ksize, anchor); if( depth == CV_16S ) - return Ptr(new MorphRowFilter, - DilateRowVec16s>(ksize, anchor)); + return makePtr, + DilateRowVec16s> >(ksize, anchor); if( depth == CV_32F ) - return Ptr(new MorphRowFilter, - DilateRowVec32f>(ksize, anchor)); + return makePtr, + DilateRowVec32f> >(ksize, anchor); if( depth == CV_64F ) - return Ptr(new MorphRowFilter, - DilateRowVec64f>(ksize, anchor)); + return makePtr, + DilateRowVec64f> >(ksize, anchor); } CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type)); - return Ptr(0); + return Ptr(); } cv::Ptr cv::getMorphologyColumnFilter(int op, int type, int ksize, int anchor) @@ -904,42 +904,42 @@ cv::Ptr cv::getMorphologyColumnFilter(int op, int type, in if( op == MORPH_ERODE ) { if( depth == CV_8U ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec8u>(ksize, anchor)); + return makePtr, + ErodeColumnVec8u> >(ksize, anchor); if( depth == CV_16U ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec16u>(ksize, anchor)); + return makePtr, + ErodeColumnVec16u> >(ksize, anchor); if( depth == CV_16S ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec16s>(ksize, anchor)); + return makePtr, + ErodeColumnVec16s> >(ksize, anchor); if( depth == CV_32F ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec32f>(ksize, anchor)); + return makePtr, + ErodeColumnVec32f> >(ksize, anchor); if( depth == CV_64F ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec64f>(ksize, anchor)); + return makePtr, + ErodeColumnVec64f> >(ksize, anchor); } else { if( depth == CV_8U ) - return Ptr(new MorphColumnFilter, - DilateColumnVec8u>(ksize, anchor)); + return makePtr, + DilateColumnVec8u> >(ksize, anchor); if( depth == CV_16U ) - return Ptr(new MorphColumnFilter, - DilateColumnVec16u>(ksize, anchor)); + return makePtr, + DilateColumnVec16u> >(ksize, anchor); if( depth == CV_16S ) - return Ptr(new MorphColumnFilter, - DilateColumnVec16s>(ksize, anchor)); + return makePtr, + DilateColumnVec16s> >(ksize, anchor); if( depth == CV_32F ) - return Ptr(new MorphColumnFilter, - DilateColumnVec32f>(ksize, anchor)); + return makePtr, + DilateColumnVec32f> >(ksize, anchor); if( depth == CV_64F ) - return Ptr(new MorphColumnFilter, - DilateColumnVec64f>(ksize, anchor)); + return makePtr, + DilateColumnVec64f> >(ksize, anchor); } CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type)); - return Ptr(0); + return Ptr(); } @@ -952,32 +952,32 @@ cv::Ptr cv::getMorphologyFilter(int op, int type, InputArray _ke if( op == MORPH_ERODE ) { if( depth == CV_8U ) - return Ptr(new MorphFilter, ErodeVec8u>(kernel, anchor)); + return makePtr, ErodeVec8u> >(kernel, anchor); if( depth == CV_16U ) - return Ptr(new MorphFilter, ErodeVec16u>(kernel, anchor)); + return makePtr, ErodeVec16u> >(kernel, anchor); if( depth == CV_16S ) - return Ptr(new MorphFilter, ErodeVec16s>(kernel, anchor)); + return makePtr, ErodeVec16s> >(kernel, anchor); if( depth == CV_32F ) - return Ptr(new MorphFilter, ErodeVec32f>(kernel, anchor)); + return makePtr, ErodeVec32f> >(kernel, anchor); if( depth == CV_64F ) - return Ptr(new MorphFilter, ErodeVec64f>(kernel, anchor)); + return makePtr, ErodeVec64f> >(kernel, anchor); } else { if( depth == CV_8U ) - return Ptr(new MorphFilter, DilateVec8u>(kernel, anchor)); + return makePtr, DilateVec8u> >(kernel, anchor); if( depth == CV_16U ) - return Ptr(new MorphFilter, DilateVec16u>(kernel, anchor)); + return makePtr, DilateVec16u> >(kernel, anchor); if( depth == CV_16S ) - return Ptr(new MorphFilter, DilateVec16s>(kernel, anchor)); + return makePtr, DilateVec16s> >(kernel, anchor); if( depth == CV_32F ) - return Ptr(new MorphFilter, DilateVec32f>(kernel, anchor)); + return makePtr, DilateVec32f> >(kernel, anchor); if( depth == CV_64F ) - return Ptr(new MorphFilter, DilateVec64f>(kernel, anchor)); + return makePtr, DilateVec64f> >(kernel, anchor); } CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type)); - return Ptr(0); + return Ptr(); } @@ -1020,8 +1020,8 @@ cv::Ptr cv::createMorphologyFilter( int op, int type, InputArr depth == CV_32F ? (double)-FLT_MAX : -DBL_MAX); } - return Ptr(new FilterEngine(filter2D, rowFilter, columnFilter, - type, type, type, _rowBorderType, _columnBorderType, borderValue )); + return makePtr(filter2D, rowFilter, columnFilter, + type, type, type, _rowBorderType, _columnBorderType, borderValue ); } diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 127a9da..a4c478a 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -622,29 +622,29 @@ cv::Ptr cv::getRowSumFilter(int srcType, int sumType, int ksi anchor = ksize/2; if( sdepth == CV_8U && ddepth == CV_32S ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_8U && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_16U && ddepth == CV_32S ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_16U && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_16S && ddepth == CV_32S ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_32S && ddepth == CV_32S ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_16S && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_32F && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_64F && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); CV_Error_( CV_StsNotImplemented, ("Unsupported combination of source format (=%d), and buffer format (=%d)", srcType, sumType)); - return Ptr(0); + return Ptr(); } @@ -658,33 +658,33 @@ cv::Ptr cv::getColumnSumFilter(int sumType, int dstType, i anchor = ksize/2; if( ddepth == CV_8U && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_8U && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_16U && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_16U && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_16S && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_16S && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_32S && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_32F && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_32F && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_64F && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_64F && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); CV_Error_( CV_StsNotImplemented, ("Unsupported combination of sum format (=%d), and destination format (=%d)", sumType, dstType)); - return Ptr(0); + return Ptr(); } @@ -703,8 +703,8 @@ cv::Ptr cv::createBoxFilter( int srcType, int dstType, Size ks Ptr columnFilter = getColumnSumFilter(sumType, dstType, ksize.height, anchor.y, normalize ? 1./(ksize.width*ksize.height) : 1); - return Ptr(new FilterEngine(Ptr(0), rowFilter, columnFilter, - srcType, dstType, sumType, borderType )); + return makePtr(Ptr(), rowFilter, columnFilter, + srcType, dstType, sumType, borderType ); } diff --git a/modules/imgproc/test/test_convhull.cpp b/modules/imgproc/test/test_convhull.cpp index cae75d0..49456c6 100644 --- a/modules/imgproc/test/test_convhull.cpp +++ b/modules/imgproc/test/test_convhull.cpp @@ -1626,7 +1626,7 @@ CV_PerimeterAreaSliceTest::~CV_PerimeterAreaSliceTest() {} void CV_PerimeterAreaSliceTest::run( int ) { - Ptr storage = cvCreateMemStorage(); + Ptr storage(cvCreateMemStorage()); RNG& rng = theRNG(); const double min_r = 90, max_r = 120; -- 2.7.4