Ask Your Question
1

c++ imread filepath in windows

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

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

supra56 gravatar image

Greetings,

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
2

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

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

Comments

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 -0500 )edit
1

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 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 72 times

Last updated: Aug 05