|
|
@ -234,10 +234,11 @@ enum { LOAD_CVMAT=0, LOAD_IMAGE=1, LOAD_MAT=2 }; |
|
|
|
* LOAD_MAT=2 |
|
|
|
* LOAD_MAT=2 |
|
|
|
* } |
|
|
|
* } |
|
|
|
* @param[in] mat Reference to C++ Mat object (If LOAD_MAT) |
|
|
|
* @param[in] mat Reference to C++ Mat object (If LOAD_MAT) |
|
|
|
|
|
|
|
* @param[in] scale_denom Scale value |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static void* |
|
|
|
static void* |
|
|
|
imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 ) |
|
|
|
imread_( const String& filename, int flags, int hdrtype, Mat* mat=0, int scale_denom=1 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IplImage* image = 0; |
|
|
|
IplImage* image = 0; |
|
|
|
CvMat *matrix = 0; |
|
|
|
CvMat *matrix = 0; |
|
|
@ -261,6 +262,9 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 ) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// set the scale_denom in the driver
|
|
|
|
|
|
|
|
decoder->setScale( scale_denom ); |
|
|
|
|
|
|
|
|
|
|
|
/// set the filename in the driver
|
|
|
|
/// set the filename in the driver
|
|
|
|
decoder->setSource(filename); |
|
|
|
decoder->setSource(filename); |
|
|
|
|
|
|
|
|
|
|
@ -316,6 +320,12 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 ) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int testdecoder = decoder->setScale( scale_denom ); // if decoder is JpegDecoder then testdecoder will be 1
|
|
|
|
|
|
|
|
if( (scale_denom > 1 ) & ( testdecoder > 1 ) ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
resize(*mat,*mat,Size(size.width/scale_denom,size.height/scale_denom)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return hdrtype == LOAD_CVMAT ? (void*)matrix : |
|
|
|
return hdrtype == LOAD_CVMAT ? (void*)matrix : |
|
|
|
hdrtype == LOAD_IMAGE ? (void*)image : (void*)mat; |
|
|
|
hdrtype == LOAD_IMAGE ? (void*)image : (void*)mat; |
|
|
|
} |
|
|
|
} |
|
|
@ -411,6 +421,27 @@ Mat imread( const String& filename, int flags ) |
|
|
|
return img; |
|
|
|
return img; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Read an image and resize it |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* This function merely calls the actual implementation above and returns itself. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param[in] filename File to load |
|
|
|
|
|
|
|
* @param[in] flags Flags you wish to set. |
|
|
|
|
|
|
|
* @param[in] scale_denom Scale value |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
Mat imread_reduced( const String& filename, int flags, int scale_denom ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/// create the basic container
|
|
|
|
|
|
|
|
Mat img; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// load the data
|
|
|
|
|
|
|
|
imread_( filename, flags, LOAD_MAT, &img, scale_denom ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// return a reference to the data
|
|
|
|
|
|
|
|
return img; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Read a multi-page image |
|
|
|
* Read a multi-page image |
|
|
|
* |
|
|
|
* |
|
|
|