OPENCV读取显示图像
时间: 2023-05-30 10:06:37 浏览: 70
1. 导入opencv库
```python
import cv2
```
2. 读取图像并显示
```python
# 读取图像
img = cv2.imread('path/to/image.jpg')
# 显示图像
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
其中,`path/to/image.jpg`为要读取的图像路径,`cv2.imshow('image', img)`中的`image`为显示窗口的名称,`img`为要显示的图像。
`cv2.waitKey(0)`中的参数为等待按键输入的时间,单位为毫秒,0表示一直等待,直到按下任意键。
`cv2.destroyAllWindows()`用于关闭所有打开的窗口。