• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CV_MAT_TYPE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CV_MAT_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ CV_MAT_TYPE函数的具体用法?C++ CV_MAT_TYPE怎么用?C++ CV_MAT_TYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CV_MAT_TYPE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: cvLSHQuery

void cvLSHQuery(CvLSH* lsh, const CvMat* data, CvMat* indices, CvMat* dist, int k, int emax) {
  int dims;

  switch (lsh->type) {
  case CV_32FC1: dims = lsh->u.lsh_32f->dims(); break;
  case CV_64FC1: dims = lsh->u.lsh_64f->dims(); break;
  default: assert(0); return;
  }

  if (k<1)
    CV_Error(CV_StsOutOfRange, "k must be positive");
  if (CV_MAT_TYPE(data->type) != lsh->type)
    CV_Error(CV_StsUnsupportedFormat, "type of data and constructed LSH must agree");
  if (dims != data->cols)
    CV_Error(CV_StsBadSize, "data must be n x d, where d is what was used to construct LSH");
  if (dist->rows != data->rows || dist->cols != k)
    CV_Error(CV_StsBadSize, "dist must be n x k for n x d data");
  if (dist->rows != indices->rows || dist->cols != indices->cols)
    CV_Error(CV_StsBadSize, "dist and indices must be same size");
  if (CV_MAT_TYPE(dist->type) != CV_64FC1)
    CV_Error(CV_StsUnsupportedFormat, "dist must be CV_64FC1");
  if (CV_MAT_TYPE(indices->type) != CV_32SC1)
    CV_Error(CV_StsUnsupportedFormat, "indices must be CV_32SC1");

  switch (lsh->type) {
  case CV_32FC1: lsh->u.lsh_32f->query(data->data.fl, data->rows,
				       k, emax, dist->data.db, indices->data.i); break;
  case CV_64FC1: lsh->u.lsh_64f->query(data->data.db, data->rows,
				       k, emax, dist->data.db, indices->data.i); break;
  default: assert(0); return;
  }
}
开发者ID:09beezahmad,项目名称:opencv,代码行数:32,代码来源:lsh.cpp


示例2: CV_MAT_TYPE

int grow_mat::init(int r, int c, int type, int maxrows, int maxcols)
{
	int no_max = 0;
	if (maxrows==0) {maxrows=r*_expand_factor;no_max=1;}
	if (maxcols==0) {maxcols=c*_expand_factor;no_max=1;}
	if (type==0) type=CV_64FC1;
	if (r<=0 || c<=0 || maxrows<0 || maxcols<0 || r>maxrows || c>maxcols)
		return 0;

	// 为了和mini_solver的set_solver一致,允许再次初始化!
	if (_mat)
	{
		// 若矩阵_mat存在,且类型相同,表示客户想改变大小。
		int mat_type = CV_MAT_TYPE(_mat->type);
		if (CV_MAT_TYPE(type)==mat_type)
		{
			return resize(r,c);
		}
	}

	if(_mat) cvReleaseMat(&_mat);
	if (no_max)
		_mat = cvCreateMat(r, c, type);
	else
		_mat = cvCreateMat(maxrows, maxcols, type);
	if (_mat==0) return 0;
	if (_zero_flag) cvSetZero(_mat);
	cvGetSubRect(_mat, this, cvRect(0,0,c,r));
	return 1;
}
开发者ID:strengthliu,项目名称:acow,代码行数:30,代码来源:growmat.cpp


示例3: cvLSHAdd

void cvLSHAdd(CvLSH* lsh, const CvMat* data, CvMat* indices) {
  int dims, n;
  int* ret_indices = 0;

  switch (lsh->type) {
  case CV_32FC1: dims = lsh->u.lsh_32f->dims(); break;
  case CV_64FC1: dims = lsh->u.lsh_64f->dims(); break;
  default: assert(0); return;
  }

  n = data->rows;

  if (dims != data->cols)
    CV_Error(CV_StsBadSize, "data must be n x d, where d is what was used to construct LSH");

  if (CV_MAT_TYPE(data->type) != lsh->type)
    CV_Error(CV_StsUnsupportedFormat, "type of data and constructed LSH must agree");
  if (indices) {
    if (CV_MAT_TYPE(indices->type) != CV_32SC1)
      CV_Error(CV_StsUnsupportedFormat, "indices must be CV_32SC1");
    if (indices->rows * indices->cols != n)
      CV_Error(CV_StsBadSize, "indices must be n x 1 or 1 x n for n x d data");
    ret_indices = indices->data.i;
  }

  switch (lsh->type) {
  case CV_32FC1: lsh->u.lsh_32f->add(data->data.fl, n, ret_indices); break;
  case CV_64FC1: lsh->u.lsh_64f->add(data->data.db, n, ret_indices); break;
  default: assert(0); return;
  }
}
开发者ID:09beezahmad,项目名称:opencv,代码行数:31,代码来源:lsh.cpp


示例4: cvCalcOpticalFlowLK

/*F///////////////////////////////////////////////////////////////////////////////////////
//    Name:    cvCalcOpticalFlowLK
//    Purpose: Optical flow implementation
//    Context:
//    Parameters:
//             srcA, srcB - source image
//             velx, vely - destination image
//    Returns:
//
//    Notes:
//F*/
CV_IMPL void
cvCalcOpticalFlowLK(const void* srcarrA, const void* srcarrB, CvSize winSize,
                    void* velarrx, void* velarry) {
    CvMat stubA, *srcA = cvGetMat(srcarrA, &stubA);
    CvMat stubB, *srcB = cvGetMat(srcarrB, &stubB);
    CvMat stubx, *velx = cvGetMat(velarrx, &stubx);
    CvMat stuby, *vely = cvGetMat(velarry, &stuby);

    if (!CV_ARE_TYPES_EQ(srcA, srcB)) {
        CV_Error(CV_StsUnmatchedFormats, "Source images have different formats");
    }

    if (!CV_ARE_TYPES_EQ(velx, vely)) {
        CV_Error(CV_StsUnmatchedFormats, "Destination images have different formats");
    }

    if (!CV_ARE_SIZES_EQ(srcA, srcB) ||
            !CV_ARE_SIZES_EQ(velx, vely) ||
            !CV_ARE_SIZES_EQ(srcA, velx)) {
        CV_Error(CV_StsUnmatchedSizes, "");
    }

    if (CV_MAT_TYPE(srcA->type) != CV_8UC1 ||
            CV_MAT_TYPE(velx->type) != CV_32FC1)
        CV_Error(CV_StsUnsupportedFormat, "Source images must have 8uC1 type and "
                 "destination images must have 32fC1 type");

    if (srcA->step != srcB->step || velx->step != vely->step) {
        CV_Error(CV_BadStep, "source and destination images have different step");
    }

    IPPI_CALL(icvCalcOpticalFlowLK_8u32fR((uchar*)srcA->data.ptr, (uchar*)srcB->data.ptr,
                                          srcA->step, cvGetMatSize(srcA), winSize,
                                          velx->data.fl, vely->data.fl, velx->step));
}
开发者ID:353,项目名称:viewercv,代码行数:46,代码来源:optflowlk.cpp


示例5: CVAPI

CVAPI(void) cvShowImageEx(const char * id, const CvArr * arr,
                          const int cm)
{
  CvMat * src, src_stub;
  double minval, maxval, maxdiff; CvPoint minloc, maxloc;
  int type = cvGetElemType(arr);
  CvMat * disp, * src_scaled;
  int i, j;
  
  if (!CV_IS_MAT(arr))
    src = cvGetMat(arr, &src_stub);
  else{
    src = (CvMat*)arr;
  }

  src = cvCloneMat(src);
  if ( (src->rows<60) || (src->rows<60) )
  {
    CvMat * orig = cvCloneMat(src);
    int scale=60./MIN(orig->rows, orig->cols);
    cvReleaseMat(&src);
    src = cvCreateMat(orig->rows*scale, orig->cols*scale,
                      CV_MAT_TYPE(orig->type));
    int m,n;
    if (CV_MAT_TYPE(src->type)==CV_64F){
      for (m=0;m<orig->rows;m++) {
      for (n=0;n<orig->cols;n++) {
      for (i=0;i<scale;i++) {
      for (j=0;j<scale;j++) {
        CV_MAT_ELEM(*src, double, m*scale+i, n*scale+j) = CV_MAT_ELEM(*orig, double, m, n);
      }
      }
      }
      }
    }else if (CV_MAT_TYPE(src->type)==CV_32F){
开发者ID:liangfu,项目名称:dnn,代码行数:35,代码来源:cvext_io.cpp


示例6: cvCornerMinEigenVal

CV_IMPL void
cvCornerMinEigenVal( const void* srcarr, void* eigenvarr,
                     int block_size, int aperture_size )
{
    CV_FUNCNAME( "cvCornerMinEigenVal" );

    __BEGIN__;

    CvMat stub, *src = (CvMat*)srcarr;
    CvMat eigstub, *eigenv = (CvMat*)eigenvarr;

    CV_CALL( src = cvGetMat( srcarr, &stub ));
    CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));

    if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
            CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
        CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );

    if( !CV_ARE_SIZES_EQ( src, eigenv ))
        CV_ERROR( CV_StsUnmatchedSizes, "" );

    CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_MINEIGENVAL ));

    __END__;
}
开发者ID:cybertk,项目名称:opencv,代码行数:25,代码来源:cvcorner.cpp


示例7: cvCornerHarris

CV_IMPL void
cvCornerHarris( const CvArr* srcarr, CvArr* harris_responce,
                int block_size, int aperture_size, double k )
{
    CV_FUNCNAME( "cvCornerHarris" );

    __BEGIN__;

    CvMat stub, *src = (CvMat*)srcarr;
    CvMat eigstub, *eigenv = (CvMat*)harris_responce;

    CV_CALL( src = cvGetMat( srcarr, &stub ));
    CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));

    if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
            CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
        CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );

    if( !CV_ARE_SIZES_EQ( src, eigenv ))
        CV_ERROR( CV_StsUnmatchedSizes, "" );

    CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_HARRIS, k ));

    __END__;
}
开发者ID:cybertk,项目名称:opencv,代码行数:25,代码来源:cvcorner.cpp


示例8: cvCornerEigenValsAndVecs

CV_IMPL void
cvCornerEigenValsAndVecs( const void* srcarr, void* eigenvarr,
                          int block_size, int aperture_size )
{
    CV_FUNCNAME( "cvCornerEigenValsAndVecs" );

    __BEGIN__;

    CvMat stub, *src = (CvMat*)srcarr;
    CvMat eigstub, *eigenv = (CvMat*)eigenvarr;

    CV_CALL( src = cvGetMat( srcarr, &stub ));
    CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));

    if( CV_MAT_CN(eigenv->type)*eigenv->cols != src->cols*6 ||
            eigenv->rows != src->rows )
        CV_ERROR( CV_StsUnmatchedSizes, "Output array should be 6 times "
                  "wider than the input array and they should have the same height");

    if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
            CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
        CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );

    CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_EIGENVALSVECS ));

    __END__;
}
开发者ID:cybertk,项目名称:opencv,代码行数:27,代码来源:cvcorner.cpp


示例9: icvConvertIntToDecimal

void icvConvertIntToDecimal(const int ndigits, CvMat * src, CvMat * dst)
{
  const int nsamples = src->rows;
  const int nnumbers = src->cols;
  assert(dst->rows==nsamples);
  assert(CV_MAT_TYPE(src->type)==CV_32S);
  assert(CV_MAT_TYPE(dst->type)==CV_32F);
  CvMat * values = cvCreateMat(ndigits,10,CV_32F);
  int stepsize = ndigits*10*sizeof(float);
  for (int ii=0;ii<nsamples;ii++){
#if 0 // debug
    fprintf(stderr,"number: ");
    for (int jj=0;jj<nnumbers;jj++){
      fprintf(stderr,"%d ",CV_MAT_ELEM(*src,int,ii,jj));
    }
#endif
    for (int jj=0;jj<nnumbers;jj++){
      cvZero(values);
      int number = CV_MAT_ELEM(*src,int,ii,jj);
      for (int kk=0;kk<ndigits;kk++){
        int pos = cvFloor((number%int(pow(10.f,kk+1)))/pow(10.f,kk));
        CV_MAT_ELEM(*values,float,kk,pos)=1;
      }
      memcpy(dst->data.ptr+stepsize*(nnumbers*ii+jj),values->data.ptr,stepsize);
    }
#if 0 // debug
    fprintf(stderr,"\noutput:\n");
    cvPrintf(stderr,"%.0f ",dst,cvRect(0,ii,dst->cols,1));
#endif
  }
  cvReleaseMat(&values);
}
开发者ID:liangfu,项目名称:dnn,代码行数:32,代码来源:transfer_svhn_dram.cpp


示例10: cvSolvePoly

void cvSolvePoly(const CvMat* a, CvMat *r, int maxiter, int fig) {
  int m = a->rows * a->cols;
  int n = r->rows * r->cols;

  __BEGIN__;
  CV_FUNCNAME("cvSolvePoly");

  if (CV_MAT_TYPE(a->type) != CV_32FC1 && 
      CV_MAT_TYPE(a->type) != CV_64FC1)
    CV_ERROR(CV_StsUnsupportedFormat, "coeffs must be either CV_32FC1 or CV_64FC1");
  if (CV_MAT_TYPE(r->type) != CV_32FC2 && 
      CV_MAT_TYPE(r->type) != CV_64FC2)
    CV_ERROR(CV_StsUnsupportedFormat, "roots must be either CV_32FC2 or CV_64FC2");
  if (CV_MAT_DEPTH(a->type) != CV_MAT_DEPTH(r->type))
    CV_ERROR(CV_StsUnmatchedFormats, "coeffs and roots must have same depth");

  if (m - 1 != n)
    CV_ERROR(CV_StsUnmatchedFormats, "must have n + 1 coefficients");

  switch (CV_MAT_DEPTH(a->type)) {
  case CV_32F:
    icvFindPolynomialRoots(a->data.fl, r->data.fl, n, maxiter, fig);
    break;
  case CV_64F:
    icvFindPolynomialRoots(a->data.db, r->data.db, n, maxiter, fig);
    break;
  }

  __END__;
}
开发者ID:JackJone,项目名称:opencv,代码行数:30,代码来源:cxutils.cpp


示例11: cvBoundingRect

/* Calculates bounding rectagnle of a point set or retrieves already calculated */
CV_IMPL  CvRect
cvBoundingRect( CvArr* array, int update )
{
    CvRect  rect = { 0, 0, 0, 0 };
    CvContour contour_header;
    CvSeq* ptseq = 0;
    CvSeqBlock block;

    CvMat stub, *mat = 0;
    int calculate = update;

    if( CV_IS_SEQ( array ))
    {
        ptseq = (CvSeq*)array;
        if( !CV_IS_SEQ_POINT_SET( ptseq ))
            CV_Error( CV_StsBadArg, "Unsupported sequence type" );

        if( ptseq->header_size < (int)sizeof(CvContour))
        {
            update = 0;
            calculate = 1;
        }
    }
    else
    {
        mat = cvGetMat( array, &stub );
        if( CV_MAT_TYPE(mat->type) == CV_32SC2 ||
            CV_MAT_TYPE(mat->type) == CV_32FC2 )
        {
            ptseq = cvPointSeqFromMat(CV_SEQ_KIND_GENERIC, mat, &contour_header, &block);
            mat = 0;
        }
        else if( CV_MAT_TYPE(mat->type) != CV_8UC1 &&
                CV_MAT_TYPE(mat->type) != CV_8SC1 )
            CV_Error( CV_StsUnsupportedFormat,
                "The image/matrix format is not supported by the function" );
        update = 0;
        calculate = 1;
    }

    if( !calculate )
        return ((CvContour*)ptseq)->rect;

    if( mat )
    {
        rect = cv::maskBoundingRect(cv::cvarrToMat(mat));
    }
    else if( ptseq->total )
    {
        cv::AutoBuffer<double> abuf;
        rect = cv::pointSetBoundingRect(cv::cvarrToMat(ptseq, false, false, 0, &abuf));
    }
    if( update )
        ((CvContour*)ptseq)->rect = rect;
    return rect;
}
开发者ID:4auka,项目名称:opencv,代码行数:57,代码来源:shapedescr.cpp


示例12: cvNeumannBoundCond

CV_IMPL void cvNeumannBoundCond(const CvArr * srcarr,
                                CvArr * dstarr)
{
  CV_FUNCNAME("cvNeumannBoundCond");
    
  __BEGIN__;
  CvMat sstub, *src;
  CvMat dstub, *dst;
  CvSize size;
  int i, j;
  float * ptr_src, * ptr_dst;
  int iStep_src, iStep_dst;
    
  CV_CALL( src = cvGetMat(srcarr, &sstub ));
  CV_CALL( dst = cvGetMat(dstarr, &dstub ));
    
  if( CV_MAT_TYPE(src->type) != CV_32FC1)
    CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
  if( CV_MAT_TYPE(dst->type) != CV_32FC1)
    CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
  if( !CV_ARE_SIZES_EQ(src, dst))
    CV_ERROR( CV_StsUnmatchedSizes, "The input images must have the same size" );
    
  size = cvGetMatSize( src );
  cvCopy(src, dst);
    
  ptr_src = src->data.fl;
  iStep_src = src->step / sizeof(ptr_src[0]);
  ptr_dst = dst->data.fl;
  iStep_dst = dst->step / sizeof(ptr_dst[0]);
    
  ptr_dst[0] = ptr_src[2+iStep_src*2];                                       
  //dst(0,0)=src(3,3)
  ptr_dst[size.width-1] = ptr_src[size.width-3+iStep_src*2];                 
  //dst(0,col-1)=src(3,col-3)
  ptr_dst[iStep_dst*(size.height-1)] = ptr_src[2+iStep_src*(size.height-3)];     
  //dst(row-1,0)=src(row-3,3)
  ptr_dst[size.width-1+iStep_dst*(size.height-1)] = ptr_src[size.width-3+iStep_dst*(size.height-3)]; 
  //dst(row-1,col-1)=src(row-3,col-3)
    
  for(i = 1; i < size.width-1; i++){
    ptr_dst[i] = ptr_src[i+iStep_src*2];
    ptr_dst[i+iStep_dst*(size.height-1)]=ptr_src[i+iStep_src*(size.height-3)];
  }
    
  for(j = 1; j < size.height-1; j++){
    ptr_dst[iStep_dst*j] = ptr_src[2+iStep_src*j];
    ptr_dst[size.width-1+iStep_dst*j]=ptr_src[size.width-3+iStep_src*j];
  }
    
  __END__;
}
开发者ID:Foued70,项目名称:ActiveContour,代码行数:52,代码来源:common.cpp


示例13: cvCalS

CV_IMPL void cvCalS(const CvArr* srcarr,
                    CvArr* dstarr)
{
    CV_FUNCNAME("cvCalS");
    
    __BEGIN__;
    CvMat sstub, *src;
    CvMat dstub, *dst;
    CvMat* src_dx=0, *src_dy=0;
    CvSize size;
    int i, j;
    int iStep;
    float* fPtr;
    
    CV_CALL( src = cvGetMat(srcarr, &sstub ));
    CV_CALL( dst = cvGetMat(dstarr, &dstub ));
    
    if( CV_MAT_TYPE(src->type) != CV_32FC1)
        CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
    
    if( CV_MAT_TYPE(dst->type) != CV_32FC1)
        CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
    
    if( !CV_ARE_SIZES_EQ( src, dst ))
        CV_ERROR( CV_StsUnmatchedSizes, "The input images must have the same size" );
    
    size = cvGetMatSize( src );
    
    src_dx  = cvCreateMat(size.height, size.width, CV_32FC1 );
    src_dy  = cvCreateMat(size.height, size.width, CV_32FC1 );
    cvSetZero(src_dx);
    cvSetZero(src_dy);
    
    iStep = dst->step / sizeof(fPtr[0]);
    fPtr = dst->data.fl;
    
    cvSobel(src, src_dx, 1, 0, 1);
    cvSobel(src, src_dy, 0, 1, 1);
    cvMul(src_dx, src_dx, src_dx, 0.25f*0.25f); //rescale gradient
    cvMul(src_dy, src_dy, src_dy, 0.25f*0.25f); //rescale gradient
    cvAdd(src_dx, src_dy, dst);
    
    for(j=0; j<size.height; j++){
        for (i=0; i<size.width; i++)
            fPtr[i+iStep*j] = sqrt(fPtr[i+iStep*j])+SMALLNUM;
    }
    cvReleaseMat(&src_dx);
    cvReleaseMat(&src_dy);
    
    __END__;
}
开发者ID:Foued70,项目名称:ActiveContour,代码行数:51,代码来源:drlse_edge.cpp


示例14: cvCurvature

CV_IMPL void cvCurvature(const CvArr* srcarr_x, 
                         const CvArr* srcarr_y,
                         CvArr* dstarr)
{
    CV_FUNCNAME("cvCurvature");
    
    __BEGIN__;
    
    CvMat sstub_x, sstub_y, *src_x, *src_y;
    CvMat dstub, *dst;
    CvSize size;
    CvMat *Nxx=0, *Nyy=0, *ones=0;
    
    CV_CALL( src_x = cvGetMat(srcarr_x, &sstub_x ));
    CV_CALL( src_y = cvGetMat(srcarr_y, &sstub_y ));
    CV_CALL( dst = cvGetMat(dstarr, &dstub ));
    
    if( CV_MAT_TYPE(src_x->type) != CV_32FC1)
        CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
    
    if( CV_MAT_TYPE(src_y->type) != CV_32FC1)
        CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
    
    if( CV_MAT_TYPE(dst->type) != CV_32FC1)
        CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
    
    if( !CV_ARE_SIZES_EQ( src_x, src_y ))
        CV_ERROR( CV_StsUnmatchedSizes, "The input images must have the same size" );
    
    size = cvGetMatSize( src_x );
    Nxx = cvCreateMat(size.height, size.width, CV_32FC1 );
    Nyy = cvCreateMat(size.height, size.width, CV_32FC1 );
    ones= cvCreateMat(size.height, size.width, CV_32FC1 );
    cvSetZero(Nxx);
    cvSetZero(Nyy);
    cvSet(ones, cvScalar(1.0f));
    
    cvSobel(src_x, Nxx, 1, 0, 1);
    cvSobel(src_y, Nyy, 0, 1, 1);
    cvMul(Nxx, ones, Nxx, 0.25f);
    cvMul(Nyy, ones, Nyy, 0.25f);
    cvAdd(Nxx, Nyy, dst);
    cvReleaseMat(&Nxx);
    cvReleaseMat(&Nyy);
    cvReleaseMat(&ones);
    
    __END__;
    
}
开发者ID:Foued70,项目名称:ActiveContour,代码行数:49,代码来源:drlse_edge.cpp


示例15: cvMatNDToMat

static Mat cvMatNDToMat(const CvMatND* m, bool copyData)
{
    Mat thiz;

    if( !m )
        return thiz;
    thiz.datastart = thiz.data = m->data.ptr;
    thiz.flags |= CV_MAT_TYPE(m->type);
    int _sizes[CV_MAX_DIM];
    size_t _steps[CV_MAX_DIM];

    int d = m->dims;
    for( int i = 0; i < d; i++ )
    {
        _sizes[i] = m->dim[i].size;
        _steps[i] = m->dim[i].step;
    }

    setSize(thiz, d, _sizes, _steps);
    finalizeHdr(thiz);

    if( copyData )
    {
        Mat temp(thiz);
        thiz.release();
        temp.copyTo(thiz);
    }

    return thiz;
}
开发者ID:AliMiraftab,项目名称:opencv,代码行数:30,代码来源:matrix_c.cpp


示例16: cvImgToObs_DCT

CV_IMPL void
cvImgToObs_DCT( const void* arr, float *obs, CvSize dctSize,
                CvSize obsSize, CvSize delta )
{
    CV_FUNCNAME( "cvImgToObs_DCT" );

    __BEGIN__;

    CvMat stub, *mat = (CvMat*)arr;

    CV_CALL( mat = cvGetMat( arr, &stub ));

    switch( CV_MAT_TYPE( mat->type ))
    {
    case CV_8UC1:
        IPPI_CALL( icvImgToObs_DCT_8u32f_C1R( mat->data.ptr, mat->step,
                                           cvGetMatSize(mat), obs,
                                           dctSize, obsSize, delta ));
        break;
    case CV_32FC1:
        IPPI_CALL( icvImgToObs_DCT_32f_C1R( mat->data.fl, mat->step,
                                           cvGetMatSize(mat), obs,
                                           dctSize, obsSize, delta ));
        break;
    default:
        CV_ERROR( CV_StsUnsupportedFormat, "" );
    }

    __END__;
}
开发者ID:runaway,项目名称:OpenCV1.1,代码行数:30,代码来源:cvhmmobs.cpp


示例17: cvCreateSeq

/* Create empty sequence: */
CV_IMPL CvSeq *
cvCreateSeq( int seq_flags, size_t header_size, size_t elem_size, CvMemStorage* storage )
{
    CvSeq *seq = 0;

    if( !storage )
        CV_Error( CV_StsNullPtr, "" );
    if( header_size < sizeof( CvSeq ) || elem_size <= 0 )
        CV_Error( CV_StsBadSize, "" );

    /* allocate sequence header */
    seq = (CvSeq*)cvMemStorageAlloc( storage, header_size );
    memset( seq, 0, header_size );

    seq->header_size = (int)header_size;
    seq->flags = (seq_flags & ~CV_MAGIC_MASK) | CV_SEQ_MAGIC_VAL;
    {
        int elemtype = CV_MAT_TYPE(seq_flags);
        int typesize = CV_ELEM_SIZE(elemtype);

        if( elemtype != CV_SEQ_ELTYPE_GENERIC && elemtype != CV_USRTYPE1 &&
            typesize != 0 && typesize != (int)elem_size )
            CV_Error( CV_StsBadSize,
            "Specified element size doesn't match to the size of the specified element type "
            "(try to use 0 for element type)" );
    }
    seq->elem_size = (int)elem_size;
    seq->storage = storage;

    cvSetSeqBlockSize( seq, (int)((1 << 10)/elem_size) );

    return seq;
}
开发者ID:baoson2211,项目名称:opencv,代码行数:34,代码来源:datastructs.cpp


示例18: loadIntraMess

void pix_opencv_patreco :: loadIntraMess (t_symbol *filename)
{
	CvMat* intrinsic_matrix;

	if ( filename->s_name[0] == 0 ) {
		error("no filename passed to loadIntra message");
		return;
	}
	if ( filename == NULL ) { error("%s is not a valid matrix", filename->s_name); return;}
	intrinsic_matrix = (CvMat*)cvLoad(filename->s_name, 0, 0, 0);// TODO crash when passing non-XML file
  
	if (intrinsic_matrix == NULL) {
		intrinsic_matrix = 	cvCreateMat(3, 3, CV_32FC1);
		error("can't open file %s", filename->s_name);
		//~ resetCorrectionMatrix();
	}
	else if ( intrinsic_matrix->rows != 3 || intrinsic_matrix->cols != 3 || CV_MAT_TYPE(intrinsic_matrix->type) != CV_32FC1 ) {
		error("%s is not a valid intrinsic matrix", filename->s_name);
		cvReleaseMat(&intrinsic_matrix);
		intrinsic_matrix = 	cvCreateMat(3, 3, CV_32FC1);
		//~ resetCorrectionMatrix();
	}
	else post("load transformation matrix from %s",filename->s_name);
	
	m_cameraMatrix = cvarrToMat(intrinsic_matrix);

	t_atom intra_out[9];
	for ( int i = 0 ; i < 9 ; i++ ){
		SETFLOAT(&intra_out[i], CV_MAT_ELEM( *intrinsic_matrix, float, i%3, i/3));
	}		
	outlet_anything( this->m_dataout, gensym("intrinsic_matrix"), 9, intra_out);
}
开发者ID:avilleret,项目名称:pix_opencv,代码行数:32,代码来源:pix_opencv_patreco.cpp


示例19: scale_input

void CvANN_MLP::scale_input( const CvMat* _src, CvMat* _dst ) const
{
    int i, j, cols = _src->cols;
    double* dst = _dst->data.db;
    const double* w = weights[0];
    int step = _src->step;

    if( CV_MAT_TYPE( _src->type ) == CV_32F )
    {
        const float* src = _src->data.fl;
        step /= sizeof(src[0]);
        
        for( i = 0; i < _src->rows; i++, src += step, dst += cols )
            for( j = 0; j < cols; j++ )
                dst[j] = src[j]*w[j*2] + w[j*2+1];
    }
    else
    {
        const double* src = _src->data.db;
        step /= sizeof(src[0]);
        
        for( i = 0; i < _src->rows; i++, src += step, dst += cols )
            for( j = 0; j < cols; j++ )
                dst[j] = src[j]*w[j*2] + w[j*2+1];
    }
}
开发者ID:cybertk,项目名称:opencv,代码行数:26,代码来源:mlann_mlp.cpp


示例20: loadDistMess

void pix_opencv_patreco :: loadDistMess (t_symbol *filename)
{
	CvMat* distortion_coeffs;
		
	if ( filename->s_name[0] == 0 ) {
		error("no filename passed to loadDist message");
		return;
	}
	if ( filename == NULL ) { error("NULL pointer passed to function loadDist"); return;}
	distortion_coeffs = (CvMat*)cvLoad(filename->s_name); // TODO crash when passing non-XML file
	
	if (distortion_coeffs == NULL) { 
		distortion_coeffs = 	cvCreateMat(5, 1, CV_32FC1);
		error("can't open file %s", filename->s_name);
		//~ resetCorrectionMatrix();
	}
	else if( distortion_coeffs->rows != 5 || distortion_coeffs->cols != 1 || CV_MAT_TYPE(distortion_coeffs->type) != CV_32FC1 ) {
		error("%s is not a valid distortions coeffs file", filename->s_name);
		cvReleaseMat(&distortion_coeffs);
		distortion_coeffs = 	cvCreateMat(3, 3, CV_32FC1);
		//~ resetCorrectionMatrix();
	}
	else post("load distortion coefficients from %s",filename->s_name);
	
	m_distortions = cvarrToMat(distortion_coeffs);

	t_atom dist_out[5];
	for ( int i = 0 ; i < 5 ; i++ ){
		SETFLOAT(&dist_out[i], CV_MAT_ELEM( *distortion_coeffs, float, i, 0));
	}		
	outlet_anything( m_dataout, gensym("distortion_coeffs"), 5, dist_out);
	 
}
开发者ID:avilleret,项目名称:pix_opencv,代码行数:33,代码来源:pix_opencv_patreco.cpp



注:本文中的CV_MAT_TYPE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CV_NO_GUI_ERROR函数代码示例发布时间:2022-05-30
下一篇:
C++ CV_MAT_DEPTH函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap