MCPcopy Create free account
hub / github.com/creatale/node-dv / cvReshapeMatND

Function cvReshapeMatND

deps/opencv/modules/core/src/array.cpp:2491–2696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2489
2490
2491CV_IMPL CvArr*
2492cvReshapeMatND( const CvArr* arr,
2493 int sizeof_header, CvArr* _header,
2494 int new_cn, int new_dims, int* new_sizes )
2495{
2496 CvArr* result = 0;
2497 int dims, coi = 0;
2498
2499 if( !arr || !_header )
2500 CV_Error( CV_StsNullPtr, "NULL pointer to array or destination header" );
2501
2502 if( new_cn == 0 && new_dims == 0 )
2503 CV_Error( CV_StsBadArg, "None of array parameters is changed: dummy call?" );
2504
2505 dims = cvGetDims( arr );
2506
2507 if( new_dims == 0 )
2508 {
2509 new_sizes = 0;
2510 new_dims = dims;
2511 }
2512 else if( new_dims == 1 )
2513 {
2514 new_sizes = 0;
2515 }
2516 else
2517 {
2518 if( new_dims <= 0 || new_dims > CV_MAX_DIM )
2519 CV_Error( CV_StsOutOfRange, "Non-positive or too large number of dimensions" );
2520 if( !new_sizes )
2521 CV_Error( CV_StsNullPtr, "New dimension sizes are not specified" );
2522 }
2523
2524 if( new_dims <= 2 )
2525 {
2526 CvMat* mat = (CvMat*)arr;
2527 CvMat header;
2528 int* refcount = 0;
2529 int hdr_refcount = 0;
2530 int total_width, new_rows, cn;
2531
2532 if( sizeof_header != sizeof(CvMat) && sizeof_header != sizeof(CvMatND) )
2533 CV_Error( CV_StsBadArg, "The output header should be CvMat or CvMatND" );
2534
2535 if( mat == (CvMat*)_header )
2536 {
2537 refcount = mat->refcount;
2538 hdr_refcount = mat->hdr_refcount;
2539 }
2540
2541 if( !CV_IS_MAT( mat ))
2542 mat = cvGetMat( mat, &header, &coi, 1 );
2543
2544 cn = CV_MAT_CN( mat->type );
2545 total_width = mat->cols * cn;
2546
2547 if( new_cn == 0 )
2548 new_cn = cn;

Callers

nothing calls this directly

Calls 3

cvGetDimsFunction · 0.85
cvGetMatFunction · 0.85
cvGetMatNDFunction · 0.85

Tested by

no test coverage detected