【问题标题】:How i can pixelate a image from opencv video capture in real time [closed]我如何实时像素化来自opencv视频捕获的图像[关闭]
【发布时间】:2020-12-25 07:47:37
【问题描述】:

eu estou com um problema para pixelizar as imagens em escala de cinza da webcam em tempo real e transformar em uma martiz。 Segue o codigo

'''导入 cv2 导入matplotlib

捕获 = cv2.VideoCapture(0) x=0 而(真):

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 pixelate


【解决方案1】:

这里是如何在 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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    • 2014-08-25
    • 1970-01-01
    • 2017-02-13
    • 1970-01-01
    • 2018-08-10
    相关资源
    最近更新 更多