| 3571 | |
| 3572 | |
| 3573 | static void* |
| 3574 | icvReadMat( CvFileStorage* fs, CvFileNode* node ) |
| 3575 | { |
| 3576 | void* ptr = 0; |
| 3577 | CvMat* mat; |
| 3578 | const char* dt; |
| 3579 | CvFileNode* data; |
| 3580 | int rows, cols, elem_type; |
| 3581 | |
| 3582 | rows = cvReadIntByName( fs, node, "rows", -1 ); |
| 3583 | cols = cvReadIntByName( fs, node, "cols", -1 ); |
| 3584 | dt = cvReadStringByName( fs, node, "dt", 0 ); |
| 3585 | |
| 3586 | if( rows < 0 || cols < 0 || !dt ) |
| 3587 | CV_Error( CV_StsError, "Some of essential matrix attributes are absent" ); |
| 3588 | |
| 3589 | elem_type = icvDecodeSimpleFormat( dt ); |
| 3590 | |
| 3591 | data = cvGetFileNodeByName( fs, node, "data" ); |
| 3592 | if( !data ) |
| 3593 | CV_Error( CV_StsError, "The matrix data is not found in file storage" ); |
| 3594 | |
| 3595 | int nelems = icvFileNodeSeqLen( data ); |
| 3596 | if( nelems > 0 && nelems != rows*cols*CV_MAT_CN(elem_type) ) |
| 3597 | CV_Error( CV_StsUnmatchedSizes, |
| 3598 | "The matrix size does not match to the number of stored elements" ); |
| 3599 | |
| 3600 | if( nelems > 0 ) |
| 3601 | { |
| 3602 | mat = cvCreateMat( rows, cols, elem_type ); |
| 3603 | cvReadRawData( fs, data, mat->data.ptr, dt ); |
| 3604 | } |
| 3605 | else if( rows == 0 && cols == 0 ) |
| 3606 | mat = cvCreateMatHeader( 0, 1, elem_type ); |
| 3607 | else |
| 3608 | mat = cvCreateMatHeader( rows, cols, elem_type ); |
| 3609 | |
| 3610 | ptr = mat; |
| 3611 | return ptr; |
| 3612 | } |
| 3613 | |
| 3614 | |
| 3615 | /******************************* CvMatND ******************************/ |
nothing calls this directly
no test coverage detected