I am really new to OpenCV and I was wondering why my debug string for empty matrix is running when I check if I have a png in my directory. I can confirm that I do indeed have an image by given name in the specified directory.
relevant code:
cv::Mat imgTrainingNumbers;
imgTrainingNumbers = cv::imread("C:/Users/.../source/repos/AutoTrader/training_chars2.png");
if (imgTrainingNumbers.empty()) { // if unable to open image
std::cout << "error: image not read from file\n\n"; // show error message on command line
return(0); // and exit program
}
the program does run up until it tries to open an image. I am confused, why does it do this and what am I doing wrong?
It is possible that the image you are using is of corrupted data. The imread() function will not return anything to your imgTrainingNumbers matrix if you...
a. have not specified the path correctly
b. the image is not in a proper format/is corrupted
c. some linking issue
Replace the image with something else to test the theory.