我想使用带opencv的python3.7显示图像。这是我的代码
ini_imagename = r'C:\Users\lydie\OneDrive\Images\newer_calibration_image.png'
theimageA = cv2.imread(ini_imagename)
cv2.imshow('image', theimageA)
不显示图像。我只有一个空的窗口,它像这样打开:window opened
退出前检查图像是否已加载并等待按键:
ini_imagename = r'C:\Users\lydie\OneDrive\Images\newer_calibration_image.png'
theimageA = cv2.imread(ini_imagename)
if theimageA is None:
print('image not loaded')
else:
cv2.imshow('image', theimageA)
cv2.waitKey(0) # waits until a key is pressed
cv2.destroyAllWindows() # destroys the window showing image