convert array (CvMat or IplImage) to IplImage
| 2774 | |
| 2775 | // convert array (CvMat or IplImage) to IplImage |
| 2776 | CV_IMPL IplImage* |
| 2777 | cvGetImage( const CvArr* array, IplImage* img ) |
| 2778 | { |
| 2779 | IplImage* result = 0; |
| 2780 | const IplImage* src = (const IplImage*)array; |
| 2781 | int depth; |
| 2782 | |
| 2783 | if( !img ) |
| 2784 | CV_Error( CV_StsNullPtr, "" ); |
| 2785 | |
| 2786 | if( !CV_IS_IMAGE_HDR(src) ) |
| 2787 | { |
| 2788 | const CvMat* mat = (const CvMat*)src; |
| 2789 | |
| 2790 | if( !CV_IS_MAT_HDR(mat)) |
| 2791 | CV_Error( CV_StsBadFlag, "" ); |
| 2792 | |
| 2793 | if( mat->data.ptr == 0 ) |
| 2794 | CV_Error( CV_StsNullPtr, "" ); |
| 2795 | |
| 2796 | depth = cvIplDepth(mat->type); |
| 2797 | |
| 2798 | cvInitImageHeader( img, cvSize(mat->cols, mat->rows), |
| 2799 | depth, CV_MAT_CN(mat->type) ); |
| 2800 | cvSetData( img, mat->data.ptr, mat->step ); |
| 2801 | |
| 2802 | result = img; |
| 2803 | } |
| 2804 | else |
| 2805 | { |
| 2806 | result = (IplImage*)src; |
| 2807 | } |
| 2808 | |
| 2809 | return result; |
| 2810 | } |
| 2811 | |
| 2812 | |
| 2813 | /****************************************************************************************\ |
no test coverage detected