I am unable to read img in OpenCV

Post Reply
johnthomas
Posts: 15
Joined: Tue May 28, 2024 2:56 am

I am unable to read img in OpenCV

Post by johnthomas »

I'm stuck with OpenCV image read function because somehow he can't read an image. Yes the path is correct and the image exist. I watched some tutorial on Youtube to display an image to find the problem without success. I also try to debug to check if my path was wrong but it seem to work perfectly fine so i'm kinda lost. enter image description here

m.opencv.org/t/opencv-4-7-c-17-windows-10-imread-warn-cutoff-empty-return/12089

My issue:

Code: Select all

[ WARN:[email protected]] global loadsave.cpp:248 cv::findDecoder imread_(''): can't open/read file: check file path/integrity OpenCV Exception: OpenCV(4.9.0) C:\GHA-OCV-1_work\ci-gha-workflow\ci-gha-workflow\opencv\modules\highgui\src\window.cpp:449: error: (-215:Assertion failed) !winname.empty() in function 'cv::namedWindow'
Similar issue:
https://github.com/opencv/opencv/issues/24632
https://foru

Console app C++ 17 X64 unicode Compiler: VS 2022

Program

Code: Select all

#include <iostream>
#include <opencv2/opencv.hpp>
#include <Windows.h>

int main()
{
    try {
        cv::Mat img = cv::imread("C:\\Users\\S06\\Downloads\\panneau.jpg", cv::IMREAD_COLOR);
        cv::namedWindow("Image", cv::WINDOW_AUTOSIZE);
        cv::imshow("Image", img);
        cv::waitKey(0);
    }
    catch (const cv::Exception& e) {
        std::cerr << "OpenCV Exception: " << e.what() << std::endl;
        system("pause");
        return -1;
    } catch (const std::exception& e) {
        std::cerr << "Standard Exception: " << e.what() << std::endl;
        system("pause");
        return -1;
    } catch (...) {
        std::cerr << "Unknown Exception" << std::endl;
        system("pause");
        return -1;
    }
    system("pause");
    return 0;
}
mary_davis75
Posts: 15
Joined: Tue May 28, 2024 2:59 am

Re: I am unable to read img in OpenCV

Post by mary_davis75 »

I would put those string literals (the file name and window name) into explicit std::string variables, see if it recurs. If it does, step through it in a debugger and observe the in-memory representation of the strings. Maybe even use the debug build of OpenCV in debugging mode to step inside the functions.
Post Reply