Add warning message to imread()
authornickjackolson <metedurlu@gmail.com>
Sun, 14 Nov 2021 19:43:50 +0000 (20:43 +0100)
committernickjackolson <metedurlu@gmail.com>
Thu, 18 Nov 2021 20:19:05 +0000 (21:19 +0100)
Add a warning message using CV_LOG__WARNING().
This way api behaviour is preserved. Outputs are
the same but user gets an extra warning in case
fopen() fails to access image file for some reason.
This would help new users and also debugging
complex apps which use imread()

Signed-off-by: nickjackolson <metedurlu@gmail.com>
modules/imgcodecs/src/loadsave.cpp

index c8fcbea..bd87c37 100644 (file)
@@ -226,8 +226,10 @@ static ImageDecoder findDecoder( const String& filename ) {
     FILE* f= fopen( filename.c_str(), "rb" );
 
     /// in the event of a failure, return an empty image decoder
-    if( !f )
+    if( !f ) {
+        CV_LOG_WARNING(NULL, "imread_('" << filename << "'): can't open/read file: check file path/integrity");
         return ImageDecoder();
+    }
 
     // read the file signature
     String signature(maxlen, ' ');