如何解决我如何实时从OpenCV视频捕获中对图像进行像素化
摄像头的速度和速度,图像的真实性和变形的图像。 Segue o codigo'''''导入cv2 导入matplotlib
capture = cv2.VideoCapture(0) x = 0 while(True):
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_AREA调整大小。此外,调整大小并备份。
输入:
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()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。