Imread does not read the file [closed]
OpenCV version: 4.0.1
IDE: Visual Studio 2017
I took code from https://docs.opencv.org/4.0.1/db/deb/...
Here is the project Debug folder, it has the logo file.png and test.jpg
The application is compiled in debug folder.
But when I try to run the application and display one of the images in the application folder, the application writes that imread cannot open the image.
EDIT:
This code shows whether the file is available before imread starts opening it.
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <fstream>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
String imageName("C:\\Users\\Emilia\\Desktop\\VS\\imageFolder\\image.jpg"); // by default
ifstream input(imageName);
if (input)
{
if (input)
{
cout << "Ok! file exists...\n";
}
else
{
cout << "Oops! file not exists...\n";
return -1;
}
}
input.close(); //close file
Mat image;
image = imread(imageName, IMREAD_COLOR); // Read the file
if (image.empty()) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
Here's what the program shows
Please help.
Hi, There is no HappyFish.jpg image inside your folder. Can you verify it?
Why should I HappyFish.jpg? I pass the path with an argument. I tried changing ../data / HappyFish.jpg to test.jpg, it does not help, the library works badly in all aspects.
Can you add your code in question? I have tried the same code with the same image. It is working for me.
and please, no screenshots of code or error msgs here... ;(
@mrjbom, common fact -- noobs NEVER find their images with a 1st attempt. ;)
( they also NEVER expect this to fail ;( )
verify, where your image REALLY is, and try with an absolute path, like
c:/some/folder/my.png
@berak, lol, here is a screenshot of the path to the photo.
screenshot
My code
@mrjbom, again, while you got all my sympathy, -- please do us all a favour, and replace ALL of those with a TEXT version, so it can be properly indexed for search ( to help other noobs ! ), we can simply quote you correctly, etc.
screenshots are for morons, ONLY, try NOT to be one, please.
@berak Okay, how can I bypass the comment length limit? I can't give you everything in TEXT format, if you review a LIMITED number of characters. How?
no, please edit your question and put it all there (we'll help you with the formatting, promised ;)
@berak, i changed the question, look please.