]> rtime.felk.cvut.cz Git - opencv.git/commitdiff
CV_ISOLATED_ISO flag added + a few minor bug fixes and cleanups
authorvp153 <vp153@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Wed, 23 Nov 2005 14:54:44 +0000 (14:54 +0000)
committervp153 <vp153@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08>
Wed, 23 Nov 2005 14:54:44 +0000 (14:54 +0000)
git-svn-id: https://code.ros.org/svn/opencv/trunk@409 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08

opencv/include/opencv/cv.hpp
opencv/src/cv/cvcorner.cpp
opencv/src/cv/cvfilter.cpp

index 335ead92616087aa054401d7e82f336c6aa482bf..5f08ce5d239a83a12922a1b0f86d54b9167c7f15 100644 (file)
@@ -52,6 +52,7 @@
 #define CV_START   1
 #define CV_END     2
 #define CV_MIDDLE  4
+#define CV_ISOLATED_ROI 8
 
 typedef void (*CvRowFilterFunc)( const uchar* src, uchar* dst, void* params );
 typedef void (*CvColumnFilterFunc)( uchar** src, uchar* dst, int dst_step, int count, void* params );
@@ -103,7 +104,7 @@ public:
     */
     virtual int process( const CvMat* _src, CvMat* _dst,
                          CvRect _src_roi=cvRect(0,0,-1,-1),
-                         CvPoint _dst_origin=cvPoint(0,0), int _phase=0 );
+                         CvPoint _dst_origin=cvPoint(0,0), int _flags=0 );
     /* retrieve various parameters of the filtering object */
     int get_src_type() const { return src_type; }
     int get_dst_type() const { return dst_type; }
index f3f8ada5057ffbc4cf305c144d47df9cbcf216ea..5ab7d87bb11ab26627046750461eadcc9b959fdd 100644 (file)
@@ -203,7 +203,7 @@ icvCornerEigenValsVecs( const CvMat* src, CvMat* eigenv, int block_size,
     int aperture_size0 = aperture_size;
     int temp_step = 0, d_step;
     uchar* shifted_ptr = 0;
-    int depth, d_depth, datatype;
+    int depth, d_depth;
     int stage = CV_START;
     CvSobelFixedIPPFunc ipp_sobel_vert = 0, ipp_sobel_horiz = 0;
     CvFilterFixedIPPFunc ipp_scharr_vert = 0, ipp_scharr_horiz = 0;
@@ -212,7 +212,6 @@ icvCornerEigenValsVecs( const CvMat* src, CvMat* eigenv, int block_size,
     CvPoint el_anchor;
     double factorx, factory;
     bool use_ipp = false;
-    CvMat _cov2, *cov2 = &_cov2;
 
     if( block_size < 3 || !(block_size & 1) )
         CV_ERROR( CV_StsOutOfRange, "averaging window size must be an odd number >= 3" );
@@ -223,7 +222,6 @@ icvCornerEigenValsVecs( const CvMat* src, CvMat* eigenv, int block_size,
     
     depth = CV_MAT_DEPTH(src->type);
     d_depth = depth == CV_8U ? CV_16S : CV_32F;
-    datatype = depth == CV_8U ? cv8u : cv32f;
 
     size = cvGetMatSize(src);
     aligned_width = cvAlign(size.width, 4);
@@ -281,7 +279,6 @@ icvCornerEigenValsVecs( const CvMat* src, CvMat* eigenv, int block_size,
     CV_CALL( Dx = cvCreateMat( max_dy, aligned_width, d_depth ));
     CV_CALL( Dy = cvCreateMat( max_dy, aligned_width, d_depth ));
     CV_CALL( cov = cvCreateMat( max_dy + block_size + 1, size.width, CV_32FC3 ));
-    _cov2 = *cov;
     CV_CALL( sqrt_buf = cvCreateMat( 2, size.width, CV_32F ));
     Dx->cols = Dy->cols = size.width;
 
@@ -373,9 +370,8 @@ icvCornerEigenValsVecs( const CvMat* src, CvMat* eigenv, int block_size,
         if( y + stripe_size.height >= size.height )
             stage = stage & CV_START ? CV_START + CV_END : CV_END;
 
-        cov->rows = stripe_size.height;
-        stripe_size.height = blur_filter.process(cov,cov2,
-            cvRect(0,0,-1,-1),cvPoint(0,0),stage);
+        stripe_size.height = blur_filter.process(cov,cov,
+            cvRect(0,0,-1,stripe_size.height),cvPoint(0,0),stage+CV_ISOLATED_ROI);
 
         if( op_type == ICV_MINEIGENVAL )
             icvCalcMinEigenVal( cov->data.fl, cov->step,
@@ -503,7 +499,7 @@ cvPreCornerDetect( const void* srcarr, void* dstarr, int aperture_size )
     int i, j, y, dst_y = 0, max_dy, delta = 0;
     int temp_step = 0, d_step;
     uchar* shifted_ptr = 0;
-    int depth, d_depth, datatype;
+    int depth, d_depth;
     int stage = CV_START;
     CvSobelFixedIPPFunc ipp_sobel_vert = 0, ipp_sobel_horiz = 0,
                         ipp_sobel_vert_second = 0, ipp_sobel_horiz_second = 0,
@@ -535,7 +531,6 @@ cvPreCornerDetect( const void* srcarr, void* dstarr, int aperture_size )
     
     depth = CV_MAT_DEPTH(src->type);
     d_depth = depth == CV_8U ? CV_16S : CV_32F;
-    datatype = depth == CV_8U ? cv8u : cv32f;
 
     size = cvGetMatSize(src);
     aligned_width = cvAlign(size.width, 4);
index 61cacf2744c599b44569bf1828eb609e0f510e13..c5443d25938ab1534953bc7dba53513257472531 100644 (file)
@@ -129,7 +129,7 @@ void CvBaseImageFilter::init( int _max_width, int _src_type, int _dst_type,
 
     __BEGIN__;
 
-    int total_buf_sz, src_pix_sz, work_pix_sz, row_tab_sz, bsz;
+    int total_buf_sz, src_pix_sz, row_tab_sz, bsz;
     uchar* ptr;
 
     if( !(buffer && _max_width <= max_width && _src_type == src_type &&
@@ -171,7 +171,6 @@ void CvBaseImageFilter::init( int _max_width, int _src_type, int _dst_type,
     buf_size = cvAlign( buf_size, ALIGN );
 
     src_pix_sz = CV_ELEM_SIZE(src_type);
-    work_pix_sz = CV_ELEM_SIZE(work_type);
     border_tab_sz1 = anchor.x*src_pix_sz;
     border_tab_sz = (ksize.width-1)*src_pix_sz;
     bsz = cvAlign( border_tab_sz*sizeof(int), ALIGN );
@@ -411,7 +410,7 @@ int CvBaseImageFilter::fill_cyclic_buffer( const uchar* src, int src_step,
 
 
 int CvBaseImageFilter::process( const CvMat* src, CvMat* dst,
-                                CvRect src_roi, CvPoint dst_origin, int phase )
+                                CvRect src_roi, CvPoint dst_origin, int flags )
 {
     int rows_processed = 0;
 
@@ -440,9 +439,11 @@ int CvBaseImageFilter::process( const CvMat* src, CvMat* dst,
     __BEGIN__;
 
     int i, width, _src_y1, _src_y2;
-    int src_y, src_y1, src_y2, dst_y, width_n;
+    int src_x, src_y, src_y1, src_y2, dst_y;
     int pix_size = CV_ELEM_SIZE(src_type);
     uchar *sptr = 0, *dptr;
+    int phase = flags & (CV_START|CV_END|CV_MIDDLE);
+    bool isolated_roi = (flags & CV_ISOLATED_ROI) != 0;
 
     if( !CV_IS_MAT(src) )
         CV_ERROR( CV_StsBadArg, "" );
@@ -451,25 +452,35 @@ int CvBaseImageFilter::process( const CvMat* src, CvMat* dst,
         CV_ERROR( CV_StsUnmatchedFormats, "" );
 
     width = src->cols;
-    _src_y1 = 0;
-    _src_y2 = src->rows;
 
     if( src_roi.width == -1 && src_roi.x == 0 )
         src_roi.width = width;
 
     if( src_roi.height == -1 && src_roi.y == 0 )
     {
-        src_roi.y = _src_y1;
-        src_roi.height = _src_y2 - _src_y1;
+        src_roi.y = 0;
+        src_roi.height = src->rows;
     }
 
     if( src_roi.width > max_width ||
         src_roi.x < 0 || src_roi.width < 0 ||
-        src_roi.y < _src_y1 || src_roi.height < 0 ||
+        src_roi.y < 0 || src_roi.height < 0 ||
         src_roi.x + src_roi.width > width ||
-        src_roi.y + src_roi.height > _src_y2 )
+        src_roi.y + src_roi.height > src->rows )
         CV_ERROR( CV_StsOutOfRange, "Too large source image or its ROI" );
 
+    src_x = src_roi.x;
+    _src_y1 = 0;
+    _src_y2 = src->rows;
+
+    if( isolated_roi )
+    {
+        src_roi.x = 0;
+        width = src_roi.width;
+        _src_y1 = src_roi.y;
+        _src_y2 = src_roi.y + src_roi.height;
+    }
+
     if( !CV_IS_MAT(dst) )
         CV_ERROR( CV_StsBadArg, "" );
 
@@ -494,7 +505,6 @@ int CvBaseImageFilter::process( const CvMat* src, CvMat* dst,
     dst_y = dst_origin.y;
     src_y1 = src_roi.y;
     src_y2 = src_roi.y + src_roi.height;
-    width_n = src_roi.width*pix_size;
 
     if( phase & CV_START )
     {
@@ -526,10 +536,7 @@ int CvBaseImageFilter::process( const CvMat* src, CvMat* dst,
     }
     
     dptr = dst->data.ptr + dst_origin.y*dst->step + dst_origin.x*CV_ELEM_SIZE(dst_type);
-    src_y1 -= _src_y1;
-    src_y2 -= _src_y1;
-    
-    sptr = src->data.ptr + src_y1*src->step + src_roi.x*pix_size;
+    sptr = src->data.ptr + src_y1*src->step + src_x*pix_size;
         
     for( src_y = src_y1; src_y < src_y2; )
     {
@@ -1821,8 +1828,8 @@ void CvSepFilter::init_sobel_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, int
     {
         CvMat* kernel = k == 0 ? _kx : _ky;
         int order = k == 0 ? dx : dy;
-        int n = kernel->cols + kernel->rows - 1;
-        int type = CV_MAT_TYPE(kernel->type), step;
+        int n = kernel->cols + kernel->rows - 1, step;
+        int type = CV_MAT_TYPE(kernel->type);
         double scale = !normalize ? 1. : 1./(1 << (n-order-1));
         int iscale = 1;
 
@@ -1887,11 +1894,11 @@ void CvSepFilter::init_sobel_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, int
         for( i = 0; i < n; i++ )
         {
             if( type == CV_32SC1 )
-                kernel->data.i[i] = kerI[i]*iscale;
+                kernel->data.i[i*step] = kerI[i]*iscale;
             else if( type == CV_32FC1 )
-                kernel->data.fl[i] = (float)(kerI[i]*scale);
+                kernel->data.fl[i*step] = (float)(kerI[i]*scale);
             else
-                kernel->data.db[i] = kerI[i]*scale;
+                kernel->data.db[i*step] = kerI[i]*scale;
         }
     }
 
@@ -1921,8 +1928,8 @@ void CvSepFilter::init_scharr_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, in
     {
         CvMat* kernel = k == 0 ? _kx : _ky;
         int order = k == 0 ? dx : dy;
-        int n = kernel->cols + kernel->rows - 1;
-        int type = CV_MAT_TYPE(kernel->type), step;
+        int n = kernel->cols + kernel->rows - 1, step;
+        int type = CV_MAT_TYPE(kernel->type);
         double scale = !normalize ? 1. : order == 0 ? 1./16 : 1./2;
         int iscale = 1;
 
@@ -1947,11 +1954,11 @@ void CvSepFilter::init_scharr_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, in
         for( i = 0; i < n; i++ )
         {
             if( type == CV_32SC1 )
-                kernel->data.i[i] = kerI[i]*iscale;
+                kernel->data.i[i*step] = kerI[i]*iscale;
             else if( type == CV_32FC1 )
-                kernel->data.fl[i] = (float)(kerI[i]*scale);
+                kernel->data.fl[i*step] = (float)(kerI[i]*scale);
             else
-                kernel->data.db[i] = kerI[i]*scale;
+                kernel->data.db[i*step] = kerI[i]*scale;
         }
     }
 
@@ -2517,8 +2524,7 @@ cvFilter2D( const CvArr* _src, CvArr* _dst, const CvMat* kernel, CvPoint anchor
     int coi1 = 0, coi2 = 0;
     CvMat srcstub, *src = (CvMat*)_src;
     CvMat dststub, *dst = (CvMat*)_dst;
-    CvSize size;
-    int type, depth;
+    int type;
 
     CV_CALL( src = cvGetMat( src, &srcstub, &coi1 ));
     CV_CALL( dst = cvGetMat( dst, &dststub, &coi2 ));
@@ -2534,9 +2540,6 @@ cvFilter2D( const CvArr* _src, CvArr* _dst, const CvMat* kernel, CvPoint anchor
     if( !CV_ARE_TYPES_EQ( src, dst ))
         CV_ERROR( CV_StsUnmatchedFormats, "" );
 
-    size = cvGetMatSize( src );
-    depth = CV_MAT_DEPTH(type);
-
     if( icvFilter_8u_C1R_p && (src->rows >= ipp_lower_limit || src->cols >= ipp_lower_limit) )
     {
         CvFilterIPPFunc ipp_func =