本文整理汇总了C++中ImageDecoder::release方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageDecoder::release方法的具体用法?C++ ImageDecoder::release怎么用?C++ ImageDecoder::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageDecoder
的用法示例。
在下文中一共展示了ImageDecoder::release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findDecoder
static void*
imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
{
CV_Assert(!buf.empty() && buf.isContinuous());
IplImage* image = 0;
CvMat *matrix = 0;
Mat temp, *data = &temp;
String filename;
ImageDecoder decoder = findDecoder(buf);
if( !decoder )
return 0;
if( !decoder->setSource(buf) )
{
filename = tempfile();
FILE* f = fopen( filename.c_str(), "wb" );
if( !f )
return 0;
size_t bufSize = buf.cols*buf.rows*buf.elemSize();
if( fwrite( buf.ptr(), 1, bufSize, f ) != bufSize )
{
fclose( f );
CV_Error( CV_StsError, "failed to write image data to temporary file" );
}
if( fclose(f) != 0 )
{
CV_Error( CV_StsError, "failed to write image data to temporary file" );
}
decoder->setSource(filename);
}
if( !decoder->readHeader() )
{
decoder.release();
if ( !filename.empty() )
{
if ( remove(filename.c_str()) != 0 )
{
CV_Error( CV_StsError, "unable to remove temporary file" );
}
}
return 0;
}
CvSize size;
size.width = decoder->width();
size.height = decoder->height();
int type = decoder->type();
if( (flags & IMREAD_LOAD_GDAL) != IMREAD_LOAD_GDAL && flags != IMREAD_UNCHANGED )
{
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);
}
bool code = decoder->readData( *data );
decoder.release();
if ( !filename.empty() )
{
if ( remove(filename.c_str()) != 0 )
{
CV_Error( CV_StsError, "unable to remove temporary file" );
}
}
if( !code )
{
cvReleaseImage( &image );
cvReleaseMat( &matrix );
if( mat )
mat->release();
return 0;
}
//.........这里部分代码省略.........