From 036b13ee05c793a765d621aa785b078fcf08fe03 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Wed, 21 Jan 2015 14:01:21 +0300 Subject: [PATCH] Fixed GDAL loader check --- modules/imgcodecs/src/loadsave.cpp | 10 +++++----- modules/imgcodecs/test/test_grfmt.cpp | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/imgcodecs/src/loadsave.cpp b/modules/imgcodecs/src/loadsave.cpp index c06b42aded..8526a4a3f0 100644 --- a/modules/imgcodecs/src/loadsave.cpp +++ b/modules/imgcodecs/src/loadsave.cpp @@ -247,7 +247,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 ) ImageDecoder decoder; #ifdef HAVE_GDAL - if( (flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL ){ + if(flags != IMREAD_UNCHANGED && (flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL ){ decoder = GdalDecoder().newDecoder(); }else{ #endif @@ -275,7 +275,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 ) // grab the decoded type int type = decoder->type(); - if( flags != -1 ) + if( flags != IMREAD_UNCHANGED ) { if( (flags & CV_LOAD_IMAGE_ANYDEPTH) == 0 ) type = CV_MAKETYPE(CV_8U, CV_MAT_CN(type)); @@ -336,7 +336,7 @@ imreadmulti_(const String& filename, int flags, std::vector& mats) ImageDecoder decoder; #ifdef HAVE_GDAL - if ((flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL){ + if (flags != IMREAD_UNCHANGED && (flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL){ decoder = GdalDecoder().newDecoder(); } else{ @@ -362,7 +362,7 @@ imreadmulti_(const String& filename, int flags, std::vector& mats) { // grab the decoded type int type = decoder->type(); - if (flags != -1) + if (flags != IMREAD_UNCHANGED) { if ((flags & CV_LOAD_IMAGE_ANYDEPTH) == 0) type = CV_MAKETYPE(CV_8U, CV_MAT_CN(type)); @@ -508,7 +508,7 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 ) size.height = decoder->height(); int type = decoder->type(); - if( flags != -1 ) + if( flags != IMREAD_UNCHANGED ) { if( (flags & CV_LOAD_IMAGE_ANYDEPTH) == 0 ) type = CV_MAKETYPE(CV_8U, CV_MAT_CN(type)); diff --git a/modules/imgcodecs/test/test_grfmt.cpp b/modules/imgcodecs/test/test_grfmt.cpp index d1610ae7fc..423d030a0c 100644 --- a/modules/imgcodecs/test/test_grfmt.cpp +++ b/modules/imgcodecs/test/test_grfmt.cpp @@ -104,7 +104,8 @@ TEST(Imgcodecs_imread, regression) ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_COLOR)); ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_ANYDEPTH)); ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_ANYCOLOR)); - ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_LOAD_GDAL)); + if (i != 2) // GDAL does not support hdr + ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_LOAD_GDAL)); } } @@ -684,7 +685,7 @@ public: compare(IMREAD_COLOR); compare(IMREAD_ANYDEPTH); compare(IMREAD_ANYCOLOR); - compare(IMREAD_LOAD_GDAL); + // compare(IMREAD_LOAD_GDAL); // GDAL does not support multi-page TIFFs } };