图像未使用imshow()OpenCV显示

2024-04-18 21:24:05 发布

您现在位置:Python中文网/ 问答频道 /正文

在加载图像并尝试显示时,我遇到了一个奇怪的问题(但没有错误)。下面是我使用的代码:

import numpy as np  
import cv2  

# I'm using the full-path in the actual document   
img = cv2.imread('shapes.jpg')  
gray = cv2.imread('shapes.jpg',0)  

#not displaying anything currently  
cv2.imshow('gray', img)  
cv2.waitKey(0)  
cv2.destroyAllWindows()  

我得到的是top part of a window。当使用cv2.namedWindow('gray', cv2.WINDOW_NORMAL)时,我能够最大化图像,并且我可以看到它确实加载了图像,但是它是surrounded by gray。在

有什么想法吗?在


Tags: the代码图像importnumpyimgas错误