Doesn't working image window

Hello
I’m practicing coding in opencv pycham.
I want to load the image, and I specified the exact path name,
The image window does not appear.
I’ve tried various methods, but I can’t load all the images.
Please help me. Thank you.

import cv2
import numpy as np

src = cv2.imread("newproject/Lena.png")


cv2.imshow('src', src)
cv2.waitKey(0)
cv2.destroyAllWindows()

and error is

C:\Users\ㅇㅇㅇ\PycharmProjects\newproject\venv\Scripts\python.exe C:\Users\ㅇㅇㅇ\PycharmProjects\newproject\openopic.py
[ WARN:0@0.027] global loadsave.cpp:244 cv::findDecoder imread_(‘newproject/Lena.png’): can’t open/read file: check file path/integrity
Traceback (most recent call last):
File “C:\Users\ㅇㅇㅇ\PycharmProjects\newproject\openopic.py”, line 8, in
cv2.imshow(‘src’, src)
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:971: error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow’

Process finished with exit code 1

1 Like

the window is working, your image did not load (path problem)

try NOT to use that ide (you have NO IDEA, what the cwd is) , it’ll only harm you !

as you see i think i typed right…
(sorry if i didnt’t)… i had to upload image to show path , and image is in folder…

so, it is looking for another folder called newproject (which does not exist)

if you’re unsure, use absolute pathes

please learn what a current working directory is.