-1

I've tried to google this to no avail. Please help me understand what is wrong with this file path:

Mat lena = imread("C:\Users\dasboomer\Desktop\Building-Computer-Vision-Projects-with-OpenCV4-and-CPlusPlus-master\Chapter03/lena.jpg");

I've tried changing:

  • backslash to double backslash
  • backslash to forward slash
  • backslash to double forward slash

Thank you for your assistance

Das Boomer
  • 25
  • 5
  • Does this answer your question? [imread not working in Opencv](https://stackoverflow.com/questions/7417637/imread-not-working-in-opencv) – Kanad Jul 26 '20 at 17:48

1 Answers1

1

\ is used for an escape sequence.

Instead, use the below lines of code:

Mat lena = imread("C:\\Users\\dasboomer\\Desktop\\Building-Computer-Vision-Projects-with-OpenCV4-and-CPlusPlus-master\\Chapter03\\lena.jpg");

or

Mat lena = imread("C:/Users/dasboomer/Desktop/Building-Computer-Vision-Projects-with-OpenCV4-and-CPlusPlus-master/Chapter03/lena.jpg");
Rahul Kedia
  • 1,400
  • 6
  • 18
  • You are correct, it turns out the tutorial code was faulty. My my, where has packt gone? – Das Boomer Jul 26 '20 at 18:03
  • Hi Rahul! Yes. For some reason, the code that follows was flagging it as not loaded. // Create windows namedWindow("Lena", WINDOW_NORMAL); // Checking if Lena image has been loaded if (!lena.data) { cout << "Lena image missing!" << endl; return -1; } – Das Boomer Jul 26 '20 at 20:26