]> rtime.felk.cvut.cz Git - opencv.git/blobdiff - opencv/src/cv/cvmser.cpp
added const in MSER::operator()
[opencv.git] / opencv / src / cv / cvmser.cpp
index 50caa4810035fb9951a7af059b19ea0189ce05ae..11a2346204eddb043174ffc7badd9fd9fb4cb86b 100644 (file)
@@ -541,7 +541,7 @@ icvExtractMSER_8UC1_Pass( int* ioptr,
                        }
                        *imgptr += 0x10000;
                }
-               int i = imgptr-ioptr;
+               int i = (int)(imgptr-ioptr);
                ptsptr->pt = cvPoint( i&stepmask, i>>stepgap );
                // get the current location
                icvAccumulateMSERComp( comptr, ptsptr );
@@ -1239,14 +1239,10 @@ cvExtractMSER( CvArr* _img,
        CvMat maskhdr, *mask = _mask ? cvGetMat( _mask, &maskhdr ) : 0;
        CvSeq* contours = 0;
 
-       CV_FUNCNAME( "cvExtractMSER" );
-
-       __BEGIN__;
-
-       CV_ASSERT(src != 0);
-       CV_ASSERT(CV_MAT_TYPE(src->type) == CV_8UC1 || CV_MAT_TYPE(src->type) == CV_8UC3);
-       CV_ASSERT(mask == 0 || (CV_ARE_SIZES_EQ(src, mask) && CV_MAT_TYPE(mask->type) == CV_8UC1));
-       CV_ASSERT(storage != 0);
+       CV_Assert(src != 0);
+       CV_Assert(CV_MAT_TYPE(src->type) == CV_8UC1 || CV_MAT_TYPE(src->type) == CV_8UC3);
+       CV_Assert(mask == 0 || (CV_ARE_SIZES_EQ(src, mask) && CV_MAT_TYPE(mask->type) == CV_8UC1));
+       CV_Assert(storage != 0);
 
        contours = *_contours = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvSeq*), storage );
 
@@ -1262,6 +1258,39 @@ cvExtractMSER( CvArr* _img,
                        icvExtractMSER_8UC3( src, mask, contours, storage, params );
                        break;
        }
+}
+
+
+namespace cv
+{
+
+MSER::MSER()
+{
+    *(CvMSERParams*)this = cvMSERParams();
+}
+
+MSER::MSER( int _delta, int _min_area, int _max_area,
+      float _max_variation, float _min_diversity,
+      int _max_evolution, double _area_threshold,
+      double _min_margin, int _edge_blur_size )
+{
+    *(CvMSERParams*)this = cvMSERParams(_delta, _min_area, _max_area, _max_variation,
+        _min_diversity, _max_evolution, _area_threshold, _min_margin, _edge_blur_size);
+}
+
+void MSER::operator()( const Mat& image, vector<vector<Point> >& dstcontours, const Mat& mask ) const
+{
+    CvMat _image = image, _mask, *pmask = 0;
+    if( mask.data )
+        pmask = &(_mask = mask);
+    MemStorage storage(cvCreateMemStorage(0));
+    Seq<CvSeq*> contours;
+    cvExtractMSER( &_image, pmask, &contours.seq, storage, *(const CvMSERParams*)this );
+    SeqIterator<CvSeq*> it = contours.begin();
+    size_t i, ncontours = contours.size();
+    dstcontours.resize(ncontours);
+    for( i = 0; i < ncontours; i++, ++it )
+        Seq<Point>(*it).copyTo(dstcontours[i]);
+}
 
-       __END__;
 }