您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關OpenCV中cvLoadImage()怎么用,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
CV_IMPL IplImage* cvLoadImage( const char* filename, int iscolor ) { return (IplImage*)cv::imread_(filename, iscolor, cv::LOAD_IMAGE ); }
調用成員函數imread_(), 該函數原型如下:
enum { LOAD_CVMAT=0, LOAD_IMAGE=1, LOAD_MAT=2 }; static void* imread_( const string& filename, int flags, int hdrtype, Mat* mat=0 ) { IplImage* image = 0; CvMat *matrix = 0; Mat temp, *data = &temp; ImageDecoder decoder = findDecoder(filename); if( decoder.empty() ) return 0; decoder->setSource(filename); if( !decoder->readHeader() ) return 0; CvSize size; size.width = decoder->width(); size.height = decoder->height(); int type = decoder->type(); if( flags != -1 ) { if( (flags & CV_LOAD_IMAGE_ANYDEPTH) == 0 ) type = CV_MAKETYPE(CV_8U, CV_MAT_CN(type)); if( (flags & CV_LOAD_IMAGE_COLOR) != 0 || ((flags & CV_LOAD_IMAGE_ANYCOLOR) != 0 && CV_MAT_CN(type) > 1) ) type = CV_MAKETYPE(CV_MAT_DEPTH(type), 3); else type = CV_MAKETYPE(CV_MAT_DEPTH(type), 1); } if( hdrtype == LOAD_CVMAT || hdrtype == LOAD_MAT ) { if( hdrtype == LOAD_CVMAT ) { matrix = cvCreateMat( size.height, size.width, type ); temp = cvarrToMat(matrix); } else { mat->create( size.height, size.width, type ); data = mat; } } else { image = cvCreateImage( size, cvIplDepth(type), CV_MAT_CN(type) ); temp = cvarrToMat(image); } if( !decoder->readData( *data )) { cvReleaseImage( &image ); cvReleaseMat( &matrix ); if( mat ) mat->release(); return 0; } return hdrtype == LOAD_CVMAT ? (void*)matrix : hdrtype == LOAD_IMAGE ? (void*)image : (void*)mat; }
此外,還有另外一個版本的cvLoadImageM():
CV_IMPL CvMat* cvLoadImageM( const char* filename, int iscolor ) { return (CvMat*)cv::imread_( filename, iscolor, cv::LOAD_CVMAT ); }
而imread_()還有另外一個版本的函數:
Mat imread( const string& filename, int flags ) { Mat img; imread_( filename, flags, LOAD_MAT, &img ); return img; }
關于“OpenCV中cvLoadImage()怎么用”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。