【发布时间】:2020-05-05 23:35:45
【问题描述】:
我知道这是一个菜鸟问题,但我找不到任何关于它的信息。
我正在编写一个 .py 程序,用于将摄像机的输入(服务器端)传输到另一台 pc(客户端),我正在使用 opencv,我可以轻松地从摄像机读取数据并对其进行操作。 现在,在我的服务器端,当我收到 GET 请求时,我会使用此代码进行响应
def test():
img = start(0,0)#return a cv2 image elaborated and standard cv2 image color scale
return str(img)#send to the client the img in string format
客户端收到正确的数据,我保存了serverSide的str(img)和从客户端收到的str,它们是一样的。
这是客户端代码:
txt = resp.text#get the text who's received back
txt = np.array(txt)#convert to a numpy array
#print(txt) #debug
cv2.imshow('image',txt)#show image
问题出在客户端的最后一行,给我这个错误
TypeError: Expected Ptr for argument 'mat'
但是 txt 字符串是一个 numpy 数组,其中的数据与客户端完全相同(顺便说一句,如果我在服务器端显示 img 就可以了),有什么建议吗?
真的需要帮助
(完整代码:https://github.com/ThomasAndreatta/opencvServer/tree/master)
【问题讨论】:
-
您可能需要转换为不同的数据类型。尝试使用 converto() 函数
-
请按照Gist中的说明进行操作
标签: python opencv flask numpy-ndarray