Open face 调整图像尺寸大小
时间: 2023-07-19 10:10:44 浏览: 45
要使用OpenCV库中的resize函数来调整图像的尺寸大小。
具体步骤如下:
1.导入OpenCV库
```python
import cv2
```
2.读取图像
```python
img = cv2.imread('image.jpg')
```
3.调整图像大小
```python
resized_img = cv2.resize(img, (new_width, new_height), interpolation = cv2.INTER_LINEAR)
```
其中,new_width和new_height是新的图像宽度和高度,interpolation参数指定了调整大小的算法,这里使用了线性插值算法INTER_LINEAR。
4.显示调整后的图像
```python
cv2.imshow('Resized Image', resized_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
完整代码示例:
```python
import cv2
img = cv2.imread('image.jpg')
new_width = 500
new_height = 300
resized_img = cv2.resize(img, (new_width, new_height), interpolation = cv2.INTER_LINEAR)
cv2.imshow('Resized Image', resized_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
注意:调整图像大小可能会导致图像失真,因此要根据具体需求进行调整。