V
V
vvafree2017-04-24 12:20:13
Programming
vvafree, 2017-04-24 12:20:13

Why is the imread() function acting weird in opencv 3.1 when running in Visual Studio 2015?

Good afternoon. Faced a strange problem with the imread() function.
If we write like this:

Mat image_source = imread("C://Users//deus//Documents//MEGA//test_radius//Debug//k_image.jpg", CV_LOAD_IMAGE_GRAYSCALE);

That image is loading.
if so
Mat image_source = imread("k_image.jpg", CV_LOAD_IMAGE_GRAYSCALE);

That does not load, although the docks indicate that everything should be loaded.
For the experiment, I threw the file into the Debug folder, where the exe is compiled, and even into the project folder. It does not find the k_image.jpg image.
After asking Google, the problem was not solved. There were suggestions to use instead of Debug - Release, it did not give any effect.
Then I changed "k_image.jpg" to "k_image.jpg.jpg" to no avail either. The point is that he takes the image from the folder in which the .exe is located.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2017-04-24
@gbg

You need to manually get the path to the EXE file (GetModuleFileName()), then cut out the exe name from there and insert the file name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question