Ask Your Question

c++ imread filepath in windows

asked 2020-07-26 12:20:48 -0600

updated 2020-08-05 22:47:39 -0600

supra56 gravatar image


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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2020-07-26 12:36:04 -0600

berak gravatar image

change ALL occurences of \to either \\ or / (not only the last)

(it's not even an opencv specific problem, you'll have to do this, whenever you encounter a file path in c++ on win)

edit flag offensive delete link more


Thank you for your time. I tried double backslash or forward and double forward slashes to no avail.

DasBoomer gravatar imageDasBoomer ( 2020-07-26 12:53:37 -0600 )edit

You are correct, it turns out the tutorial code was faulty. My my, where has packt gone?

DasBoomer gravatar imageDasBoomer ( 2020-07-26 13:03:55 -0600 )edit

Question Tools

1 follower


Asked: 2020-07-26 12:17:45 -0600

Seen: 1,666 times

Last updated: Aug 05 '20