1st, I used Visual Studio Code IDE
I have successfully installed OpenCV 4.1.1 at Python 3.7.0.
-
import cv2
-
.
-
print(cv2. version )
-
-
I run the "Getting_started_with_images.py"import cv2
and the following error message comes out.
PS C:\Users\hlaky\Desktop\My_Project>
PS C:\Users\hlaky\Desktop\My_Project> & “C:/Programs Files/Python37/python.exe” c:/Users/hlaky/Desktop/My_Project/Getting_started_with_images.py
Please help me to correct this error.
Thanks,
am not an expert at cv2 but try:
this:
from cv2 import *
img= cv2.imread(‘name of the image’, 0)
print(img)
Looking carefully at your screen caps, it almost appears you are not using “normal” single quotes around “lena.jpg” - they look like the typographic quotes you can get with Microsoft Word. This is corroborated by the squiggly under the code in the screen shot - the editor things something is wrong.
[I may be confused by your font choice in the editor.]
You can use either single quotes or double quotes with python strings. So try replacing
'lena.jpg'
with
"lena.jpg"
And in any case, use the “plain” single or double quotes [Ascii codes 39 and 34, respectively] whenever writing code.