【发布时间】:2019-06-13 03:32:42
【问题描述】:
欢迎大家。
我正在尝试显示套接字发送的图片。
有这样一段代码:P.S 是的,是的,我知道这是你见过的最糟糕的事情,但这里是:
while True:
data = s.recv(BUFFER_SIZE)
if data:
print ("received data:", len(data))
try:
myfile = open("t.png", 'wb')
myfile.write(data)
img = cv2.imread('t.png')
if img is not None:
img = cv2.resize(img, (1280, 720))
cv2.imshow("1", img)
cv2.waitKey(1)
except IOError as e:
print(e)
他打开文件,把图像写在那里,然后opencv读取这个图像并显示出来。
opencv如何立即显示图片?
为了不将图片刻录到磁盘读取,立即显示。
【问题讨论】:
-
(与
if not img is None:相比,您应该更喜欢if img is not None:) -
@DorianTurba,好的,任务完成:)
标签: python numpy sockets opencv tcp