imread working in py but working in ipynb
Hello everyone,
I have a problem with the imread
function. The code that I'm running is the following :
import cv2
image = cv2.imread("T.jpg")
cv2.imshow("test", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Really simple, just to display an image.
The thing is that when I run this in a ipynb file it works, the image display work and when I click any key it shut.
But when I run it in a py file it return this error :
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
I don't understand, everything is the same except the extension of the python file. Image is the same, so it really exist and is not corrupted. Both ipynb and py file are in the same directory, same directory as the "T.jpg" file.
Any ideas? I use vscode, is there a link with that?
Thank you for your answers.
except the relative path from your image to where your program starts , please check vscode settings