本文整理汇总了C++中CV_CALL函数的典型用法代码示例。如果您正苦于以下问题:C++ CV_CALL函数的具体用法?C++ CV_CALL怎么用?C++ CV_CALL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CV_CALL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cvAcc
CV_IMPL void
cvAcc( const void* arr, void* sumarr, const void* maskarr )
{
static CvFuncTable acc_tab;
static CvBigFuncTable accmask_tab;
static int inittab = 0;
CV_FUNCNAME( "cvAcc" );
__BEGIN__;
int type, sumdepth;
int mat_step, sum_step, mask_step = 0;
CvSize size;
CvMat stub, *mat = (CvMat*)arr;
CvMat sumstub, *sum = (CvMat*)sumarr;
CvMat maskstub, *mask = (CvMat*)maskarr;
if( !inittab )
{
icvInitAddTable( &acc_tab, &accmask_tab );
inittab = 1;
}
if( !CV_IS_MAT( mat ) || !CV_IS_MAT( sum ))
{
int coi1 = 0, coi2 = 0;
CV_CALL( mat = cvGetMat( mat, &stub, &coi1 ));
CV_CALL( sum = cvGetMat( sum, &sumstub, &coi2 ));
if( coi1 + coi2 != 0 )
CV_ERROR( CV_BadCOI, "" );
}
if( CV_MAT_DEPTH( sum->type ) != CV_32F )
CV_ERROR( CV_BadDepth, "" );
if( !CV_ARE_CNS_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
sumdepth = CV_MAT_DEPTH( sum->type );
if( sumdepth != CV_32F && (maskarr != 0 || sumdepth != CV_64F))
CV_ERROR( CV_BadDepth, "Bad accumulator type" );
if( !CV_ARE_SIZES_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
size = cvGetMatSize( mat );
type = CV_MAT_TYPE( mat->type );
mat_step = mat->step;
sum_step = sum->step;
if( !mask )
{
CvFunc2D_2A func=(CvFunc2D_2A)acc_tab.fn_2d[CV_MAT_DEPTH(type)];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "Unsupported type combination" );
size.width *= CV_MAT_CN(type);
if( CV_IS_MAT_CONT( mat->type & sum->type ))
{
size.width *= size.height;
mat_step = sum_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step, sum->data.ptr, sum_step, size ));
}
else
{
CvFunc2D_3A func = (CvFunc2D_3A)accmask_tab.fn_2d[type];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
CV_CALL( mask = cvGetMat( mask, &maskstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( !CV_ARE_SIZES_EQ( mat, mask ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
mask_step = mask->step;
if( CV_IS_MAT_CONT( mat->type & sum->type & mask->type ))
{
size.width *= size.height;
mat_step = sum_step = mask_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step, mask->data.ptr, mask_step,
sum->data.ptr, sum_step, size ));
}
__END__;
}
示例2: cvPointPolygonTest
CV_IMPL double
cvPointPolygonTest( const CvArr* _contour, CvPoint2D32f pt, int measure_dist )
{
double result = 0;
CV_FUNCNAME( "cvCheckPointPolygon" );
__BEGIN__;
CvSeqBlock block;
CvContour header;
CvSeq* contour = (CvSeq*)_contour;
CvSeqReader reader;
int i, total, counter = 0;
int is_float;
double min_dist_num = FLT_MAX, min_dist_denom = 1;
CvPoint ip = {0,0};
if( !CV_IS_SEQ(contour) )
{
CV_CALL( contour = cvPointSeqFromMat( CV_SEQ_KIND_CURVE + CV_SEQ_FLAG_CLOSED,
_contour, &header, &block ));
}
else if( CV_IS_SEQ_POLYGON(contour) )
{
if( contour->header_size == sizeof(CvContour) && !measure_dist )
{
CvRect r = ((CvContour*)contour)->rect;
if( pt.x < r.x || pt.y < r.y ||
pt.x >= r.x + r.width || pt.y >= r.y + r.height )
return -100;
}
}
else if( CV_IS_SEQ_CHAIN(contour) )
{
CV_ERROR( CV_StsBadArg,
"Chains are not supported. Convert them to polygonal representation using cvApproxChains()" );
}
else
CV_ERROR( CV_StsBadArg, "Input contour is neither a valid sequence nor a matrix" );
total = contour->total;
is_float = CV_SEQ_ELTYPE(contour) == CV_32FC2;
cvStartReadSeq( contour, &reader, -1 );
if( !is_float && !measure_dist && (ip.x = cvRound(pt.x)) == pt.x && (ip.y = cvRound(pt.y)) == pt.y )
{
// the fastest "pure integer" branch
CvPoint v0, v;
CV_READ_SEQ_ELEM( v, reader );
for( i = 0; i < total; i++ )
{
int dist;
v0 = v;
CV_READ_SEQ_ELEM( v, reader );
if( (v0.y <= ip.y && v.y <= ip.y) ||
(v0.y > ip.y && v.y > ip.y) ||
(v0.x < ip.x && v.x < ip.x) )
{
if( ip.y == v.y && (ip.x == v.x || (ip.y == v0.y &&
((v0.x <= ip.x && ip.x <= v.x) || (v.x <= ip.x && ip.x <= v0.x)))) )
EXIT;
continue;
}
dist = (ip.y - v0.y)*(v.x - v0.x) - (ip.x - v0.x)*(v.y - v0.y);
if( dist == 0 )
EXIT;
if( v.y < v0.y )
dist = -dist;
counter += dist > 0;
}
result = counter % 2 == 0 ? -100 : 100;
}
else
{
CvPoint2D32f v0, v;
CvPoint iv;
if( is_float )
{
CV_READ_SEQ_ELEM( v, reader );
}
else
{
CV_READ_SEQ_ELEM( iv, reader );
v = cvPointTo32f( iv );
}
if( !measure_dist )
{
for( i = 0; i < total; i++ )
{
double dist;
v0 = v;
if( is_float )
{
CV_READ_SEQ_ELEM( v, reader );
//.........这里部分代码省略.........
示例3: cvAbsDiff
CV_IMPL void
cvAbsDiff( const void* srcarr1, const void* srcarr2, void* dstarr )
{
static CvFuncTable adiff_tab;
static int inittab = 0;
CV_FUNCNAME( "cvAbsDiff" );
__BEGIN__;
int coi1 = 0, coi2 = 0, coi3 = 0;
CvMat srcstub1, *src1 = (CvMat*)srcarr1;
CvMat srcstub2, *src2 = (CvMat*)srcarr2;
CvMat dststub, *dst = (CvMat*)dstarr;
int src1_step, src2_step, dst_step;
CvSize size;
int type;
if( !inittab )
{
icvInitAbsDiffTable( &adiff_tab );
inittab = 1;
}
CV_CALL( src1 = cvGetMat( src1, &srcstub1, &coi1 ));
CV_CALL( src2 = cvGetMat( src2, &srcstub2, &coi2 ));
CV_CALL( dst = cvGetMat( dst, &dststub, &coi3 ));
if( coi1 != 0 || coi2 != 0 || coi3 != 0 )
CV_ERROR( CV_BadCOI, "" );
if( !CV_ARE_SIZES_EQ( src1, src2 ) )
CV_ERROR_FROM_CODE( CV_StsUnmatchedSizes );
size = icvGetMatSize( src1 );
type = CV_ARR_TYPE(src1->type);
if( !CV_ARE_SIZES_EQ( src1, dst ))
CV_ERROR_FROM_CODE( CV_StsUnmatchedSizes );
if( !CV_ARE_TYPES_EQ( src1, src2 ))
CV_ERROR_FROM_CODE( CV_StsUnmatchedFormats );
if( !CV_ARE_TYPES_EQ( src1, dst ))
CV_ERROR_FROM_CODE( CV_StsUnmatchedFormats );
size.width *= CV_ARR_CN( type );
src1_step = src1->step;
src2_step = src2->step;
dst_step = dst->step;
if( CV_IS_ARR_CONT( src1->type & src2->type & dst->type ))
{
size.width *= size.height;
size.height = 1;
src1_step = src2_step = dst_step = CV_STUB_STEP;
}
{
CvFunc2D_3A func = (CvFunc2D_3A)
(adiff_tab.fn_2d[CV_ARR_DEPTH(type)]);
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
IPPI_CALL( func( src1->data.ptr, src1_step, src2->data.ptr, src2_step,
dst->data.ptr, dst_step, size ));
}
__END__;
}
示例4: cvCreateFGDStatModel
// Function cvCreateFGDStatModel initializes foreground detection process
// parameters:
// first_frame - frame from video sequence
// parameters - (optional) if NULL default parameters of the algorithm will be used
// p_model - pointer to CvFGDStatModel structure
CV_IMPL CvBGStatModel*
cvCreateFGDStatModel( IplImage* first_frame, CvFGDStatModelParams* parameters )
{
CvFGDStatModel* p_model = 0;
CV_FUNCNAME( "cvCreateFGDStatModel" );
__BEGIN__;
int i, j, k, pixel_count, buf_size;
CvFGDStatModelParams params;
if( !CV_IS_IMAGE(first_frame) )
CV_ERROR( CV_StsBadArg, "Invalid or NULL first_frame parameter" );
if (first_frame->nChannels != 3)
CV_ERROR( CV_StsBadArg, "first_frame must have 3 color channels" );
// Initialize parameters:
if( parameters == NULL )
{
params.Lc = CV_BGFG_FGD_LC;
params.N1c = CV_BGFG_FGD_N1C;
params.N2c = CV_BGFG_FGD_N2C;
params.Lcc = CV_BGFG_FGD_LCC;
params.N1cc = CV_BGFG_FGD_N1CC;
params.N2cc = CV_BGFG_FGD_N2CC;
params.delta = CV_BGFG_FGD_DELTA;
params.alpha1 = CV_BGFG_FGD_ALPHA_1;
params.alpha2 = CV_BGFG_FGD_ALPHA_2;
params.alpha3 = CV_BGFG_FGD_ALPHA_3;
params.T = CV_BGFG_FGD_T;
params.minArea = CV_BGFG_FGD_MINAREA;
params.is_obj_without_holes = 1;
params.perform_morphing = 1;
}
else
{
params = *parameters;
}
CV_CALL( p_model = (CvFGDStatModel*)cvAlloc( sizeof(*p_model) ));
memset( p_model, 0, sizeof(*p_model) );
p_model->type = CV_BG_MODEL_FGD;
p_model->release = (CvReleaseBGStatModel)icvReleaseFGDStatModel;
p_model->update = (CvUpdateBGStatModel)icvUpdateFGDStatModel;;
p_model->params = params;
// Initialize storage pools:
pixel_count = first_frame->width * first_frame->height;
buf_size = pixel_count*sizeof(p_model->pixel_stat[0]);
CV_CALL( p_model->pixel_stat = (CvBGPixelStat*)cvAlloc(buf_size) );
memset( p_model->pixel_stat, 0, buf_size );
buf_size = pixel_count*params.N2c*sizeof(p_model->pixel_stat[0].ctable[0]);
CV_CALL( p_model->pixel_stat[0].ctable = (CvBGPixelCStatTable*)cvAlloc(buf_size) );
memset( p_model->pixel_stat[0].ctable, 0, buf_size );
buf_size = pixel_count*params.N2cc*sizeof(p_model->pixel_stat[0].cctable[0]);
CV_CALL( p_model->pixel_stat[0].cctable = (CvBGPixelCCStatTable*)cvAlloc(buf_size) );
memset( p_model->pixel_stat[0].cctable, 0, buf_size );
for( i = 0, k = 0; i < first_frame->height; i++ ) {
for( j = 0; j < first_frame->width; j++, k++ )
{
p_model->pixel_stat[k].ctable = p_model->pixel_stat[0].ctable + k*params.N2c;
p_model->pixel_stat[k].cctable = p_model->pixel_stat[0].cctable + k*params.N2cc;
}
}
// Init temporary images:
CV_CALL( p_model->Ftd = cvCreateImage(cvSize(first_frame->width, first_frame->height), IPL_DEPTH_8U, 1));
CV_CALL( p_model->Fbd = cvCreateImage(cvSize(first_frame->width, first_frame->height), IPL_DEPTH_8U, 1));
CV_CALL( p_model->foreground = cvCreateImage(cvSize(first_frame->width, first_frame->height), IPL_DEPTH_8U, 1));
CV_CALL( p_model->background = cvCloneImage(first_frame));
CV_CALL( p_model->prev_frame = cvCloneImage(first_frame));
CV_CALL( p_model->storage = cvCreateMemStorage());
__END__;
if( cvGetErrStatus() < 0 )
{
CvBGStatModel* base_ptr = (CvBGStatModel*)p_model;
if( p_model && p_model->release )
p_model->release( &base_ptr );
else
cvFree( &p_model );
//.........这里部分代码省略.........
示例5: icvLoadTreeCascadeClassifier
CvIntHaarClassifier* icvLoadTreeCascadeClassifier( const char* filename, int step,
int* splits )
{
CvTreeCascadeClassifier* ptr = NULL;
CvTreeCascadeNode** nodes = NULL;
CV_FUNCNAME( "icvLoadTreeCascadeClassifier" );
__BEGIN__;
size_t data_size;
CvStageHaarClassifier* stage;
char stage_name[PATH_MAX];
char* suffix;
int i, num;
FILE* f;
int result, parent=0, next=0;
int stub;
if( !splits ) splits = &stub;
*splits = 0;
data_size = sizeof( *ptr );
CV_CALL( ptr = (CvTreeCascadeClassifier*) cvAlloc( data_size ) );
memset( ptr, 0, data_size );
ptr->eval = icvEvalTreeCascadeClassifier;
ptr->release = icvReleaseTreeCascadeClassifier;
sprintf( stage_name, "%s/", filename );
suffix = stage_name + strlen( stage_name );
for( i = 0; ; i++ )
{
sprintf( suffix, "%d/%s", i, CV_STAGE_CART_FILE_NAME );
f = fopen( stage_name, "r" );
if( !f ) break;
fclose( f );
}
num = i;
if( num < 1 ) EXIT;
data_size = sizeof( *nodes ) * num;
CV_CALL( nodes = (CvTreeCascadeNode**) cvAlloc( data_size ) );
for( i = 0; i < num; i++ )
{
sprintf( suffix, "%d/%s", i, CV_STAGE_CART_FILE_NAME );
f = fopen( stage_name, "r" );
CV_CALL( stage = (CvStageHaarClassifier*)
icvLoadCARTStageHaarClassifierF( f, step ) );
result = ( f && stage ) ? fscanf( f, "%d%d", &parent, &next ) : 0;
if( f ) fclose( f );
if( result != 2 )
{
num = i;
break;
}
printf( "Stage %d loaded\n", i );
if( parent >= i || (next != -1 && next != i + 1) )
CV_ERROR( CV_StsError, "Invalid tree links" );
CV_CALL( nodes[i] = icvCreateTreeCascadeNode() );
nodes[i]->stage = stage;
nodes[i]->idx = i;
nodes[i]->parent = (parent != -1 ) ? nodes[parent] : NULL;
nodes[i]->next = ( next != -1 ) ? nodes[i] : NULL;
nodes[i]->child = NULL;
}
for( i = 0; i < num; i++ )
{
if( nodes[i]->next )
{
(*splits)++;
nodes[i]->next = nodes[i+1];
}
if( nodes[i]->parent && nodes[i]->parent->child == NULL )
{
nodes[i]->parent->child = nodes[i];
}
}
ptr->root = nodes[0];
ptr->next_idx = num;
__END__;
cvFree( &nodes );
return (CvIntHaarClassifier*) ptr;
}
示例6: cvSVD
CV_IMPL void
cvSVD( CvArr* aarr, CvArr* warr, CvArr* uarr, CvArr* varr, int flags )
{
uchar* buffer = 0;
int local_alloc = 0;
CV_FUNCNAME( "cvSVD" );
__BEGIN__;
CvMat astub, *a = (CvMat*)aarr;
CvMat wstub, *w = (CvMat*)warr;
CvMat ustub, *u = (CvMat*)uarr;
CvMat vstub, *v = (CvMat*)varr;
CvMat tmat;
uchar* tw = 0;
int type, nm, mn;
int buf_size, pix_size;
int t_svd = 0; // special case: a->rows < a->cols
if( !CV_IS_ARR( a ))
CV_CALL( a = cvGetMat( a, &astub ));
if( !CV_IS_ARR( w ))
CV_CALL( w = cvGetMat( w, &wstub ));
if( !CV_ARE_TYPES_EQ( a, w ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
nm = MIN( a->width, a->height );
mn = MAX( a->width, a->height );
if( (w->width == 1 || w->height == 1) &&
CV_IS_ARR_CONT( w->type ) && w->width*w->height == nm )
{
tw = w->data.ptr;
}
else if( !CV_ARE_SIZES_EQ( w, a ))
{
CV_ERROR( CV_StsBadSize, "W must be either continuous vector of "
"size MIN(A->width,A->height) or matrix of "
"the same size as A" );
}
if( u )
{
if( !CV_IS_ARR( u ))
CV_CALL( u = cvGetMat( u, &ustub ));
if( !CV_ARE_TYPES_EQ( a, u ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( u->width != u->height || u->height != a->height )
CV_ERROR( CV_StsUnmatchedSizes, "U matrix must be square and have the same "
"linear size as number of rows in A" );
if( u->data.ptr == a->data.ptr )
CV_ERROR( CV_StsBadArg, "U can not be equal A" );
}
else
{
u = &ustub;
u->data.ptr = 0;
u->step = 0;
}
if( v )
{
if( !CV_IS_ARR( v ))
CV_CALL( v = cvGetMat( v, &vstub ));
if( !CV_ARE_TYPES_EQ( a, v ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( v->width != v->height || v->width != a->width )
CV_ERROR( CV_StsUnmatchedSizes, "V matrix must be square and have the same "
"linear size as number of columns in A" );
if( v->data.ptr == a->data.ptr || v->data.ptr == u->data.ptr )
CV_ERROR( CV_StsBadArg, "V can not be equal U or A" );
}
else
{
v = &vstub;
v->data.ptr = 0;
v->step = 0;
}
type = CV_ARR_TYPE( a->type );
pix_size = icvPixSize[type];
buf_size = nm*2 + mn;
if( a->rows < a->cols )
{
CvMat* t;
CV_SWAP( u, v, t );
flags = (flags & CV_SVD_U_T ? CV_SVD_V_T : 0)|
(flags & CV_SVD_V_T ? CV_SVD_U_T : 0);
//.........这里部分代码省略.........
示例7: cvSegmentImage
CV_IMPL CvSeq*
cvSegmentImage(const CvArr* srcarr, CvArr* dstarr,
double canny_threshold,
double ffill_threshold,
CvMemStorage* storage) {
CvSeq* root = 0;
CvMat* gray = 0;
CvMat* canny = 0;
//CvMat* temp = 0;
void* stack = 0;
CV_FUNCNAME("cvSegmentImage");
__BEGIN__;
CvMat srcstub, *src;
CvMat dststub, *dst;
CvMat* mask;
CvSize size;
CvPoint pt;
int ffill_lw_up = cvRound(fabs(ffill_threshold));
CvSeq* prev_seq = 0;
CV_CALL(src = cvGetMat(srcarr, &srcstub));
CV_CALL(dst = cvGetMat(dstarr, &dststub));
size = cvGetSize(src);
CV_CALL(gray = cvCreateMat(size.height, size.width, CV_8UC1));
CV_CALL(canny = cvCreateMat(size.height, size.width, CV_8UC1));
//CV_CALL( temp = cvCreateMat( size.height/2, size.width/2, CV_8UC3 ));
CV_CALL(stack = cvAlloc(size.width * size.height * sizeof(Seg)));
cvCvtColor(src, gray, CV_BGR2GRAY);
cvCanny(gray, canny, 0/*canny_threshold*0.4*/, canny_threshold, 3);
cvThreshold(canny, canny, 1, 1, CV_THRESH_BINARY);
//cvZero( canny );
//color_derv( src, canny, canny_threshold );
//cvPyrDown( src, temp );
//cvPyrUp( temp, dst );
//src = dst;
mask = canny; // a new name for new role
// make a non-zero border.
cvRectangle(mask, cvPoint(0, 0), cvPoint(size.width - 1, size.height - 1), cvScalarAll(1), 1);
for (pt.y = 0; pt.y < size.height; pt.y++) {
for (pt.x = 0; pt.x < size.width; pt.x++) {
if (mask->data.ptr[mask->step* pt.y + pt.x] == 0) {
CvConnectedComp region;
int avgVal[3] = { 0, 0, 0 };
icvSegmFloodFill_Stage1(src->data.ptr, src->step,
mask->data.ptr, mask->step,
size, pt, avgVal,
ffill_lw_up, ffill_lw_up,
®ion, stack);
/*avgVal[0] = (avgVal[0] + 15) & -32;
if( avgVal[0] > 255 )
avgVal[0] = 255;
avgVal[1] = (avgVal[1] + 15) & -32;
if( avgVal[1] > 255 )
avgVal[1] = 255;
avgVal[2] = (avgVal[2] + 15) & -32;
if( avgVal[2] > 255 )
avgVal[2] = 255;*/
if (storage) {
CvSeq* tmpseq = icvGetComponent(mask->data.ptr, mask->step,
region.rect, storage);
if (tmpseq != 0) {
((CvContour*)tmpseq)->color = avgVal[0] + (avgVal[1] << 8) + (avgVal[2] << 16);
tmpseq->h_prev = prev_seq;
if (prev_seq) {
prev_seq->h_next = tmpseq;
} else {
root = tmpseq;
}
prev_seq = tmpseq;
}
}
icvSegmFloodFill_Stage2(dst->data.ptr, dst->step,
mask->data.ptr, mask->step,
size, avgVal,
region.rect);
}
}
}
__END__;
//cvReleaseMat( &temp );
cvReleaseMat(&gray);
cvReleaseMat(&canny);
cvFree(&stack);
//.........这里部分代码省略.........
示例8: CV_FUNCNAME
void OptFlowEMD::calculate_flow(IplImage* imageT, IplImage* imageTMinus1, IplImage* velx, IplImage* vely, IplImage* abs){
#ifdef __CV_BEGIN__
__CV_BEGIN__
#else
__BEGIN__
#endif
CV_FUNCNAME( "OptFlowGenGrad::calculate_flow" );
CvMat stubA, *srcA = (CvMat*)imageT; // stubA takes the new header data for the matrix according to ROI
CvMat stubB, *srcB = (CvMat*)imageTMinus1;
CvMat stubx, *vel_x = (CvMat*)velx;
CvMat stuby, *vel_y = (CvMat*)vely;
CvMat stubAbs, *abs_ = NULL;
if (abs != NULL)
abs_ = (CvMat*)abs;
// see GetMat function doc: This returns a matrix header with the current image ROI!
// this gives basically a view on the ROI, stubA takes the header data of the matrix
// srcA is pointed to this new 'augmented' data-header
CV_CALL( srcA = cvGetMat( srcA, &stubA ));
CV_CALL( srcB = cvGetMat( srcB, &stubB ));
CV_CALL( vel_x = cvGetMat( vel_x, &stubx ));
CV_CALL( vel_y = cvGetMat( vel_y, &stuby ));
if (abs_ != NULL)
CV_CALL( abs_ = cvGetMat ( abs_, &stubAbs ));
if( !CV_ARE_TYPES_EQ( srcA, srcB ))
CV_ERROR( CV_StsUnmatchedFormats, "Source images have different formats" );
if( !CV_ARE_TYPES_EQ( vel_x, vel_y ))
CV_ERROR( CV_StsUnmatchedFormats, "Destination images have different formats" );
if (abs_ != NULL)
if (!CV_ARE_TYPES_EQ( vel_x, abs_))
CV_ERROR( CV_StsUnmatchedFormats, "Destination images have different formats" );
if( !CV_ARE_SIZES_EQ( srcA, srcB ) ||
!CV_ARE_SIZES_EQ( vel_x, vel_y ) ||
!CV_ARE_SIZES_EQ( srcA, vel_x ))
CV_ERROR( CV_StsUnmatchedSizes, "Some images have different sizes" );
if(abs_ != NULL)
if (!CV_ARE_SIZES_EQ( srcA, abs_))
CV_ERROR( CV_StsUnmatchedSizes, "Some images have different sizes" );
if( CV_MAT_TYPE( srcA->type ) != CV_8UC1)
CV_ERROR( CV_StsUnsupportedFormat, "Source images must have 8uC1 type");
if( CV_MAT_TYPE( vel_x->type ) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Destination images must have 32fC1 type" );
if( srcA->step != srcB->step ||
vel_x->step != vel_y->step)
CV_ERROR( CV_BadStep, "source and destination images have different step" );
if (abs_ != NULL)
if (vel_x->step != abs_->step)
CV_ERROR( CV_BadStep, "source and destination images have different step" );
if (abs_ != NULL){
IPPI_CALL( calcOptFlowEMD( (uchar*)srcA->data.ptr, (uchar*)srcB->data.ptr, srcA->step, cvGetMatSize( srcA ),
vel_x->data.fl, vel_y->data.fl, vel_x->step,
abs_->data.fl));
}
else{
IPPI_CALL( calcOptFlowEMD( (uchar*)srcA->data.ptr, (uchar*)srcB->data.ptr, srcA->step, cvGetMatSize( srcA ),
vel_x->data.fl, vel_y->data.fl, vel_x->step,
NULL));
}
#ifdef __CV_END__
__CV_END__
#else
__END__
#endif
}
示例9: cvFindExtrinsicCameraParams3
bool
cvFindExtrinsicCameraParams3( const CvMat* obj_points,
const CvMat* img_points, const CvMat* A,
const CvMat* dist_coeffs,
CvMat* r_vec, CvMat* t_vec )
{
bool fGood = true;
const int max_iter = 20;
CvMat *_M = 0, *_Mxy = 0, *_m = 0, *_mn = 0, *_L = 0, *_J = 0;
CV_FUNCNAME( "cvFindExtrinsicCameraParams3" );
__BEGIN__;
int i, j, count;
double a[9], k[4] = { 0, 0, 0, 0 }, R[9], ifx, ify, cx, cy;
double Mc[3] = {0, 0, 0}, MM[9], U[9], V[9], W[3];
double JtJ[6*6], JtErr[6], JtJW[6], JtJV[6*6], delta[6], param[6];
CvPoint3D64f* M = 0;
CvPoint2D64f *m = 0, *mn = 0;
CvMat _a = cvMat( 3, 3, CV_64F, a );
CvMat _R = cvMat( 3, 3, CV_64F, R );
CvMat _r = cvMat( 3, 1, CV_64F, param );
CvMat _t = cvMat( 3, 1, CV_64F, param + 3 );
CvMat _Mc = cvMat( 1, 3, CV_64F, Mc );
CvMat _MM = cvMat( 3, 3, CV_64F, MM );
CvMat _U = cvMat( 3, 3, CV_64F, U );
CvMat _V = cvMat( 3, 3, CV_64F, V );
CvMat _W = cvMat( 3, 1, CV_64F, W );
CvMat _JtJ = cvMat( 6, 6, CV_64F, JtJ );
CvMat _JtErr = cvMat( 6, 1, CV_64F, JtErr );
CvMat _JtJW = cvMat( 6, 1, CV_64F, JtJW );
CvMat _JtJV = cvMat( 6, 6, CV_64F, JtJV );
CvMat _delta = cvMat( 6, 1, CV_64F, delta );
CvMat _param = cvMat( 6, 1, CV_64F, param );
CvMat _dpdr, _dpdt;
if( !CV_IS_MAT(obj_points) || !CV_IS_MAT(img_points) ||
!CV_IS_MAT(A) || !CV_IS_MAT(r_vec) || !CV_IS_MAT(t_vec) )
CV_ERROR( CV_StsBadArg, "One of required arguments is not a valid matrix" );
count = MAX(obj_points->cols, obj_points->rows);
CV_CALL( _M = cvCreateMat( 1, count, CV_64FC3 ));
CV_CALL( _Mxy = cvCreateMat( 1, count, CV_64FC2 ));
CV_CALL( _m = cvCreateMat( 1, count, CV_64FC2 ));
CV_CALL( _mn = cvCreateMat( 1, count, CV_64FC2 ));
M = (CvPoint3D64f*)_M->data.db;
m = (CvPoint2D64f*)_m->data.db;
mn = (CvPoint2D64f*)_mn->data.db;
CV_CALL( cvConvertPointsHomogenious( obj_points, _M ));
CV_CALL( cvConvertPointsHomogenious( img_points, _m ));
CV_CALL( cvConvert( A, &_a ));
if( dist_coeffs )
{
CvMat _k;
if( !CV_IS_MAT(dist_coeffs) ||
CV_MAT_DEPTH(dist_coeffs->type) != CV_64F &&
CV_MAT_DEPTH(dist_coeffs->type) != CV_32F ||
dist_coeffs->rows != 1 && dist_coeffs->cols != 1 ||
dist_coeffs->rows*dist_coeffs->cols*CV_MAT_CN(dist_coeffs->type) != 4 )
CV_ERROR( CV_StsBadArg,
"Distortion coefficients must be 1x4 or 4x1 floating-point vector" );
_k = cvMat( dist_coeffs->rows, dist_coeffs->cols,
CV_MAKETYPE(CV_64F,CV_MAT_CN(dist_coeffs->type)), k );
CV_CALL( cvConvert( dist_coeffs, &_k ));
}
if( CV_MAT_DEPTH(r_vec->type) != CV_64F && CV_MAT_DEPTH(r_vec->type) != CV_32F ||
r_vec->rows != 1 && r_vec->cols != 1 ||
r_vec->rows*r_vec->cols*CV_MAT_CN(r_vec->type) != 3 )
CV_ERROR( CV_StsBadArg, "Rotation vector must be 1x3 or 3x1 floating-point vector" );
if( CV_MAT_DEPTH(t_vec->type) != CV_64F && CV_MAT_DEPTH(t_vec->type) != CV_32F ||
t_vec->rows != 1 && t_vec->cols != 1 ||
t_vec->rows*t_vec->cols*CV_MAT_CN(t_vec->type) != 3 )
CV_ERROR( CV_StsBadArg,
"Translation vector must be 1x3 or 3x1 floating-point vector" );
ifx = 1./a[0]; ify = 1./a[4];
cx = a[2]; cy = a[5];
// normalize image points
// (unapply the intrinsic matrix transformation and distortion)
for( i = 0; i < count; i++ )
{
double x = (m[i].x - cx)*ifx, y = (m[i].y - cy)*ify, x0 = x, y0 = y;
// compensate distortion iteratively
if( dist_coeffs )
for( j = 0; j < 5; j++ )
{
double r2 = x*x + y*y;
double icdist = 1./(1 + k[0]*r2 + k[1]*r2*r2);
double delta_x = 2*k[2]*x*y + k[3]*(r2 + 2*x*x);
double delta_y = k[2]*(r2 + 2*y*y) + 2*k[3]*x*y;
x = (x0 - delta_x)*icdist;
//.........这里部分代码省略.........
示例10: cvDrlse_edge
CV_IMPL void cvDrlse_edge(CvArr * srcphi,
CvArr * srcgrad,
CvArr * dstarr,
double lambda,
double mu,
double alfa,
double epsilon,
int timestep,
int iter)
{
CV_FUNCNAME( "cvDrlse_edge" );
__BEGIN__;
CvMat sstub1, sstub2, *phi, *grad;
CvMat dstub, *dst;
CvMat *gradx=0, *grady=0, *phi_0=0, *phix=0, *phiy=0;
CvMat *s=0, *Nx=0, *Ny=0, *curvature=0, *distRegTerm=0;
CvMat *diracPhi=0, *areaTerm=0, *edgeTerm=0;
CvMat *temp1=0, *temp2=0, *temp3=0, *ones=0;
CvSize size;
int i;
CV_CALL( phi = cvGetMat(srcphi, &sstub1 ));
CV_CALL( grad = cvGetMat(srcgrad, &sstub2 ));
CV_CALL( dst = cvGetMat(dstarr, &dstub));
if( CV_MAT_TYPE(phi->type) != CV_32FC1)
CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
if( CV_MAT_TYPE(grad->type) != CV_32FC1)
CV_ERROR( CV_StsUnsupportedFormat, "Only-32bit, 1-channel input images are supported" );
if( !CV_ARE_SIZES_EQ( phi, grad ))
CV_ERROR( CV_StsUnmatchedSizes, "The input images must have the same size" );
size = cvGetMatSize( phi );
//Initialization
gradx = cvCreateMat(size.height, size.width, CV_32FC1 );
grady = cvCreateMat(size.height, size.width, CV_32FC1 );
phi_0 = cvCreateMat(size.height, size.width, CV_32FC1 );
phix = cvCreateMat(size.height, size.width, CV_32FC1 );
phiy = cvCreateMat(size.height, size.width, CV_32FC1 );
Nx = cvCreateMat(size.height, size.width, CV_32FC1 );
Ny = cvCreateMat(size.height, size.width, CV_32FC1 );
s = cvCreateMat(size.height, size.width, CV_32FC1 );
curvature= cvCreateMat(size.height, size.width, CV_32FC1 );
distRegTerm= cvCreateMat(size.height, size.width, CV_32FC1 );
diracPhi = cvCreateMat(size.height, size.width, CV_32FC1 );
areaTerm = cvCreateMat(size.height, size.width, CV_32FC1 );
edgeTerm = cvCreateMat(size.height, size.width, CV_32FC1 );
temp1 = cvCreateMat(size.height, size.width, CV_32FC1 );
temp2 = cvCreateMat(size.height, size.width, CV_32FC1 );
temp3 = cvCreateMat(size.height, size.width, CV_32FC1 );
ones = cvCreateMat(size.height, size.width, CV_32FC1 );
cvSetZero(gradx);
cvSetZero(grady);
cvSetZero(phix);
cvSetZero(phiy);
cvSetZero(Nx);
cvSetZero(Ny);
cvSetZero(s);
cvSetZero(curvature);
cvSetZero(distRegTerm);
cvSetZero(diracPhi);
cvSetZero(areaTerm);
cvSetZero(edgeTerm);
cvSetZero(temp1);
cvSetZero(temp2);
cvSetZero(temp3);
cvSet(ones, cvScalar(1.0f));
//--------------BEGIN----------------------
cvSobel(grad, gradx, 1, 0, 1);
cvSobel(grad, grady, 0, 1, 1);
cvMul(gradx, ones, gradx, 0.25f);
cvMul(grady, ones, grady, 0.25f);
cvCopy(phi, dst);
for(i=0; i<iter; i++){
cvNeumannBoundCond(dst, dst);
cvSobel(dst, phix, 1, 0, 1);
cvSobel(dst, phiy, 0, 1, 1);
cvCalS(dst,s);
cvDiv(phix, s, Nx, 0.25f);
cvDiv(phiy, s, Ny, 0.25f);
cvCurvature(Nx, Ny, curvature);
cvDistReg(dst, distRegTerm);
cvDirac(dst, diracPhi, epsilon); //Compute driacPhi;
cvMul(diracPhi, grad, areaTerm); //Compute areaTerm
cvMul(gradx, Nx, gradx); //------------------//
cvMul(grady, Ny, grady); // Computing //
cvAdd(gradx, grady, temp1); // //
cvMul(diracPhi, temp1, temp2); // edgeTerm //
cvMul(areaTerm, curvature, temp3); // //
cvAdd(temp2, temp3, edgeTerm); //------------------//
cvMul(distRegTerm, ones, distRegTerm, mu); // distRegTerm = mu * distRegTerm
cvMul(edgeTerm, ones, edgeTerm, lambda); // edgeTerm = lambda * edgeTerm
//.........这里部分代码省略.........
示例11: cvDRLSE
CvPoint*
cvDRLSE(const CvArr * image,
const CvArr * mask,
int *length,
double lambda,
double alfa,
double epsilon,
int timestep,
int ITER_ext,
int ITER_int,
int flag)
{
IplImage sstub1, sstub2, *msk, *img, *marker, *levelset;
CvMat *ones, *Ix, *Iy, *phi, *f, *g;
CvSize size;
int comp_count =0, iStep;
float* fPtr;
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* contours = 0;
CvPoint pt= cvPoint(0,0), *point=NULL;
double mu = 0.2f/double(timestep);
char c;
CV_FUNCNAME( "cvDRLSE" );
__BEGIN__;
CV_CALL( msk = cvGetImage(mask, &sstub1 ));
CV_CALL( img = cvGetImage(image, &sstub2 ));
cvSmooth(img, img, CV_GAUSSIAN, 5, 5, 1.5f);
size = cvGetSize(img);
levelset = cvCreateImage(size, IPL_DEPTH_8U, 1);
ones = cvCreateMat(size.height, size.width, CV_32FC1);
Ix = cvCreateMat(size.height, size.width, CV_32FC1);
Iy = cvCreateMat(size.height, size.width, CV_32FC1);
phi = cvCreateMat(size.height, size.width, CV_32FC1);
f = cvCreateMat(size.height, size.width, CV_32FC1);
g = cvCreateMat(size.height, size.width, CV_32FC1);
marker = cvCreateImage(size, IPL_DEPTH_32S, 1);
cvSet(ones, cvScalar(1.0f));
cvSobel(img, Ix, 1, 0, 1);
cvSobel(img, Iy, 0, 1, 1);
cvMul(Ix, Ix, Ix, 0.25f*0.25f);
cvMul(Iy, Iy, Iy, 0.25f*0.25f);
cvAdd(Ix, Iy, f);
cvAdd(f, ones, f);
cvDiv(NULL, f, g, 1.0f);
cvFindContours( msk, storage, &contours, sizeof(CvContour),CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE );
cvZero(marker);
for( ; contours != 0; contours = contours->h_next, comp_count++ )
{
cvDrawContours( marker, contours, cvScalarAll(255),cvScalarAll(255), -1, -1, 8);
}
iStep = phi->step/sizeof(fPtr[0]);
fPtr = phi->data.fl;
for (int j=0; j<size.height; j++)
for (int i=0; i<size.width; i++) {
int idx = CV_IMAGE_ELEM( marker, int, j, i );
if (idx >0 )
if (flag == CV_LSE_SHR)
fPtr[i+iStep*j]=-2.0f;
else
fPtr[i+iStep*j]=2.0f;
else
if (flag == CV_LSE_SHR)
fPtr[i+iStep*j]=2.0f;
else
fPtr[i+iStep*j]=-2.0f;
}
for (int i=0; i<ITER_ext; i++) {
cvDrlse_edge(phi, g, phi, lambda, mu, alfa, epsilon, timestep, ITER_int);
loadBar(i+1, ITER_ext, 50);
}
cvDrlse_edge(phi, g, phi, lambda, mu, 0.0f, epsilon, timestep, ITER_int);
cvZero(msk);
if (flag == CV_LSE_SHR)
cvThreshold(phi, msk, 0.0f, 255, CV_THRESH_BINARY_INV);
else
cvThreshold(phi, msk, 0.0f, 255, CV_THRESH_BINARY);
cvFindContours(msk, storage, &contours, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
if(!contours) return 0;
*length = contours->total;
//if(*length<10) return 0;
point = new CvPoint[*length];
CvSeqReader reader;
cvStartReadSeq(contours, &reader);
for (int i = 0; i < *length; i++){
CV_READ_SEQ_ELEM(pt, reader);
point[i]=pt;
}
//clean up
//.........这里部分代码省略.........
示例12: cvDistReg
CV_IMPL void cvDistReg(const CvArr* srcarr,
CvArr* dstarr)
{
CV_FUNCNAME("cvDistReg");
__BEGIN__;
CvMat sstub, *src;
CvMat dstub, *dst;
CvMat* src_dx=0, *src_dy=0, *s=0, *ps=0;
CvMat* dps_x=0, *dps_y=0, *del=0, *ones=0;
CvSize size;
int i, j, iStep_s, iStep_ps;
float* fPtr_s, *fPtr_ps;
float temp_s=0.0f, temp_ps=0.0f;
float flag_s1=0.0f, flag_s2=0.0f, flag_ps1=0.0f, flag_ps2=0.0f;
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 );
s = cvCreateMat(size.height, size.width, CV_32FC1 );
ps = cvCreateMat(size.height, size.width, CV_32FC1 );
dps_x = cvCreateMat(size.height, size.width, CV_32FC1 );
dps_y = cvCreateMat(size.height, size.width, CV_32FC1 );
del = cvCreateMat(size.height, size.width, CV_32FC1 );
ones = cvCreateMat(size.height, size.width, CV_32FC1 );
cvSetZero(src_dx);
cvSetZero(src_dy);
cvSetZero(s);
cvSetZero(ps);
cvSetZero(dps_x);
cvSetZero(dps_y);
cvSetZero(del);
cvSet(ones, cvScalar(1.0f));
iStep_s = s->step / sizeof(fPtr_s[0]);
fPtr_s = s->data.fl;
iStep_ps= ps->step/ sizeof(fPtr_ps[0]);
fPtr_ps = ps->data.fl;
cvSobel(src, src_dx, 1, 0, 1);
cvSobel(src, src_dy, 0, 1, 1);
cvMul(src_dx, ones, src_dx, 0.25f);
cvMul(src_dy, ones, src_dy, 0.25f);
cvCalS(src,s);
for (j=0; j<size.height; j++){
for (i=0; i<size.width; i++){
temp_s = fPtr_s[i+iStep_s*j];
if (int(temp_s*10000)>=0 && int(temp_s*10000)<=10000) {
flag_s1 = 1.0f;
} else {
flag_s1 = 0.0f;
}
if (int(temp_s*10000) > 10000) {
flag_s2 = 1.0f;
} else {
flag_s2 = 0.0f;
}
temp_ps = flag_s1*sin(2*PI*temp_s)/2/PI+flag_s2*(temp_s-1.0f);
if (int(temp_ps*10000) == 0) {
flag_ps1 = 0.0f;
} else {
flag_ps1 = 1.0f;
}
if (int(temp_s*10000) == 0) {
flag_ps2 = 0.0f;
} else {
flag_ps2 = 1.0f;
}
fPtr_ps[i+iStep_ps*j] = (flag_ps1*temp_ps+1.0f-flag_ps1)/(flag_ps2*temp_s+1.0f-flag_ps2);
if ((flag_ps2*temp_s+1.0f-flag_ps2)==0){
printf("Something wrong in last: temp_s = %f, flag_ps2 = %f\n", temp_s, flag_ps2);
exit(0);
}
}
}
cvMul(ps, src_dx, dps_x);
cvMul(ps, src_dy, dps_y);
cvSub(dps_x, src_dx, dps_x);
cvSub(dps_y, src_dy, dps_y);
cvCurvature(dps_x, dps_y, dst);
cvLaplace(src,del,1);
cvMul(del, ones, del, 0.2f);
cvAdd(dst, del, dst);
cvReleaseMat(&src_dx);
cvReleaseMat(&src_dy);
cvReleaseMat(&s);
//.........这里部分代码省略.........
示例13: cvRunningAvg
CV_IMPL void
cvRunningAvg( const void* arrY, void* arrU,
double alpha, const void* maskarr )
{
static CvFuncTable acc_tab;
static CvBigFuncTable accmask_tab;
static int inittab = 0;
CV_FUNCNAME( "cvRunningAvg" );
__BEGIN__;
int coi1, coi2;
int type;
int mat_step, sum_step, mask_step = 0;
CvSize size;
CvMat stub, *mat = (CvMat*)arrY;
CvMat sumstub, *sum = (CvMat*)arrU;
CvMat maskstub, *mask = (CvMat*)maskarr;
if( !inittab )
{
icvInitAddWeightedTable( &acc_tab, &accmask_tab );
inittab = 1;
}
CV_CALL( mat = cvGetMat( mat, &stub, &coi1 ));
CV_CALL( sum = cvGetMat( sum, &sumstub, &coi2 ));
if( coi1 != 0 || coi2 != 0 )
CV_ERROR( CV_BadCOI, "" );
if( !CV_ARE_CNS_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( CV_MAT_DEPTH( sum->type ) != CV_32F )
CV_ERROR( CV_BadDepth, "" );
if( !CV_ARE_SIZES_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
size = cvGetMatSize( mat );
type = CV_MAT_TYPE( mat->type );
mat_step = mat->step;
sum_step = sum->step;
if( !mask )
{
CvAddWeightedFunc func = (CvAddWeightedFunc)acc_tab.fn_2d[CV_MAT_DEPTH(type)];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
size.width *= CV_MAT_CN(type);
if( CV_IS_MAT_CONT( mat->type & sum->type ))
{
size.width *= size.height;
mat_step = sum_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step,
sum->data.ptr, sum_step, size, (float)alpha ));
}
else
{
CvAddWeightedMaskFunc func = (CvAddWeightedMaskFunc)accmask_tab.fn_2d[type];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
CV_CALL( mask = cvGetMat( mask, &maskstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( !CV_ARE_SIZES_EQ( mat, mask ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
mask_step = mask->step;
if( CV_IS_MAT_CONT( mat->type & sum->type & mask->type ))
{
size.width *= size.height;
mat_step = sum_step = mask_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step, mask->data.ptr, mask_step,
sum->data.ptr, sum_step, size, (float)alpha ));
}
__END__;
}
示例14: cvMultiplyAcc
CV_IMPL void
cvMultiplyAcc( const void* arrA, const void* arrB,
void* acc, const void* maskarr )
{
static CvFuncTable acc_tab;
static CvBigFuncTable accmask_tab;
static int inittab = 0;
CV_FUNCNAME( "cvMultiplyAcc" );
__BEGIN__;
int coi1, coi2, coi3;
int type;
int mat1_step, mat2_step, sum_step, mask_step = 0;
CvSize size;
CvMat stub1, *mat1 = (CvMat*)arrA;
CvMat stub2, *mat2 = (CvMat*)arrB;
CvMat sumstub, *sum = (CvMat*)acc;
CvMat maskstub, *mask = (CvMat*)maskarr;
if( !inittab )
{
icvInitAddProductTable( &acc_tab, &accmask_tab );
inittab = 1;
}
CV_CALL( mat1 = cvGetMat( mat1, &stub1, &coi1 ));
CV_CALL( mat2 = cvGetMat( mat2, &stub2, &coi2 ));
CV_CALL( sum = cvGetMat( sum, &sumstub, &coi3 ));
if( coi1 != 0 || coi2 != 0 || coi3 != 0 )
CV_ERROR( CV_BadCOI, "" );
if( !CV_ARE_CNS_EQ( mat1, mat2 ) || !CV_ARE_CNS_EQ( mat1, sum ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( CV_MAT_DEPTH( sum->type ) != CV_32F )
CV_ERROR( CV_BadDepth, "" );
if( !CV_ARE_SIZES_EQ( mat1, sum ) || !CV_ARE_SIZES_EQ( mat2, sum ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
size = cvGetMatSize( mat1 );
type = CV_MAT_TYPE( mat1->type );
mat1_step = mat1->step;
mat2_step = mat2->step;
sum_step = sum->step;
if( !mask )
{
CvFunc2D_3A func = (CvFunc2D_3A)acc_tab.fn_2d[CV_MAT_DEPTH(type)];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
size.width *= CV_MAT_CN(type);
if( CV_IS_MAT_CONT( mat1->type & mat2->type & sum->type ))
{
size.width *= size.height;
mat1_step = mat2_step = sum_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat1->data.ptr, mat1_step, mat2->data.ptr, mat2_step,
sum->data.ptr, sum_step, size ));
}
else
{
CvFunc2D_4A func = (CvFunc2D_4A)accmask_tab.fn_2d[type];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
CV_CALL( mask = cvGetMat( mask, &maskstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( !CV_ARE_SIZES_EQ( mat1, mask ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
mask_step = mask->step;
if( CV_IS_MAT_CONT( mat1->type & mat2->type & sum->type & mask->type ))
{
size.width *= size.height;
mat1_step = mat2_step = sum_step = mask_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat1->data.ptr, mat1_step, mat2->data.ptr, mat2_step,
mask->data.ptr, mask_step,
sum->data.ptr, sum_step, size ));
}
__END__;
}
示例15: icvConvertPointsHomogenious
//.........这里部分代码省略.........
if( s_dims < d_dims - 1 || s_dims > d_dims + 1 )
CV_ERROR( CV_StsUnmatchedSizes,
"The dimensionalities of input and output "
"point sets differ too much" );
if( s_dims == d_dims - 1 )
{
if( d_count == dst->rows )
{
ones = cvGetSubRect( dst, &_ones, cvRect( s_dims, 0, 1, d_count ));
dst = cvGetSubRect( dst, &_dst, cvRect( 0, 0, s_dims, d_count ));
}
else
{
ones = cvGetSubRect( dst, &_ones, cvRect( 0, s_dims, d_count, 1 ));
dst = cvGetSubRect( dst, &_dst, cvRect( 0, 0, d_count, s_dims ));
}
}
if( s_dims <= d_dims )
{
if( src->rows == dst->rows && src->cols == dst->cols )
{
if( CV_ARE_TYPES_EQ( src, dst ) )
cvCopy( src, dst );
else
cvConvert( src, dst );
}
else
{
if( !CV_ARE_TYPES_EQ( src, dst ))
{
CV_CALL( temp = cvCreateMat( src->rows, src->cols, dst->type ));
cvConvert( src, temp );
src = temp;
}
cvTranspose( src, dst );
}
if( ones )
cvSet( ones, cvRealScalar(1.) );
}
else
{
int s_plane_stride, s_stride, d_plane_stride, d_stride, elem_size;
if( !CV_ARE_TYPES_EQ( src, dst ))
{
CV_CALL( temp = cvCreateMat( src->rows, src->cols, dst->type ));
cvConvert( src, temp );
src = temp;
}
elem_size = CV_ELEM_SIZE(src->type);
if( s_count == src->cols )
s_plane_stride = src->step / elem_size, s_stride = 1;
else
s_stride = src->step / elem_size, s_plane_stride = 1;
if( d_count == dst->cols )
d_plane_stride = dst->step / elem_size, d_stride = 1;
else
d_stride = dst->step / elem_size, d_plane_stride = 1;