Python 如何从opencv视频捕获实时对图像进行像素化
eu estou com将问题视为图像,并在网络摄像头中以真实的速度转换图像。塞格·奥科迪戈 “进口cv2 导入matplotlib 捕获=cv2.VideoCapture0 x=0 尽管如此:Python 如何从opencv视频捕获实时对图像进行像素化,python,opencv,pixelate,Python,Opencv,Pixelate,eu estou com将问题视为图像,并在网络摄像头中以真实的速度转换图像。塞格·奥科迪戈 “进口cv2 导入matplotlib 捕获=cv2.VideoCapture0 x=0 尽管如此: ret, frame = capture.read() grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('video gray', grayFrame) cv2.imshow('video original', frame
ret, frame = capture.read()
grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('video gray', grayFrame)
cv2.imshow('video original', frame)
print(grayFrame)
w, h = (16, 16)
temp = cv2.resize(input, (w, h), interpolation=cv2.INTER_LINEAR)
cv2.imshow('video original', output)
if cv2.waitKey(1) == 27:
break'''
下面是如何在Python/OpenCV中实现这一点 首先,使用INTER_区域调整大小。此外,向下调整大小并备份 输入:
用英语写
import cv2
# read the input
img = cv2.imread("barn.jpg")
hh, ww = img.shape[:2]
# resize down, then back up
w, h = (16, 16)
result = cv2.resize(img, (w, h), interpolation=cv2.INTER_AREA)
result = cv2.resize(result, (ww, hh), interpolation=cv2.INTER_AREA)
# save result
cv2.imwrite("barn_pixelated.png", result)
# show result
cv2.imshow("result", result)
cv2.waitKey(0)
cv2.destroyAllWindows()