Imread can't find file, relative path, process current working directory, Visual Studio

While using opencv, we are constantly experiencing errors in exception handling. I have attached a photo, so please leave it in the comments if you can help.Please help me.

image

that should have been a hint. check whether img.empty()

https://docs.opencv.org/master/d3/d63/classcv_1_1Mat.html#abbec3525a852e77998aba034813fded4

I used the same picture as other users, would that still be a problem? For other users, there was no problem.

use an absolute path to your picture file.

relative paths are relative to the current working directory of the process. VS doesn’t run your program in the source directory but the build directory (or elsewhere entirely).

1 Like