SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape [closed]

asked 2019-04-12 09:27:06 -0500

updated 2019-04-13 09:48:50 -0500

supra56 gravatar image

code:

import cv2
import numpy as np
img=cv2.imread("C:\Users\ravik_000\Desktop\photo",1)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

please tell me what is the reason why im not reading the image and show it on the screen.

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2019-04-12 10:13:14.284486

Comments

1

please use forward slashes (/) or double backslashes(\\), else python will interpret \U(in C:\Users) as a unicode escape sequence.

again, NOT an opencv problem, you will encounter this with EVERY path or string on your os.

berak gravatar imageberak ( 2019-04-12 10:15:54 -0500 )edit

missing filename + extension. img=cv2.imread("C:\Users\ravik_000\Desktop\photo/filename.extension",1)

supra56 gravatar imagesupra56 ( 2019-04-13 09:50:15 -0500 )edit

Btw, follow @berak's example. I'm using linux.

supra56 gravatar imagesupra56 ( 2019-04-13 09:51:54 -0500 )edit