OpenCV Thumbnail Creation Guide
In OpenCV, you can use the cv2.resize() function to create a thumbnail image. This function resizes the image to a specified size.
Here is an example code showing how to resize an image to a specified width and height:
import cv2
# 读取图像
image = cv2.imread('image.jpg')
# 缩放图像
width = 200 # 指定缩略图的宽度
height = 200 # 指定缩略图的高度
resized_image = cv2.resize(image, (width, height))
# 保存缩略图
cv2.imwrite('thumbnail.jpg', resized_image)
In the sample code, the cv2.imread() function is used to read an image from a file. Then, the image is resized to a specified width and height using the cv2.resize() function. Finally, the thumbnail is saved to a file using the cv2.imwrite() function.
Please note that the width and height of the thumbnail should be set based on the actual requirements.