微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Docker容器上运行pyzmq基本程序的问题

如何解决在Docker容器上运行pyzmq基本程序的问题

我在docker容器中运行以下代码,将视频从流光发送到查看器。以下代码无需在docker容器中运行即可完美运行。

import base64
import cv2
import zmq
context = zmq.Context()
footage_socket = context.socket(zmq.PUB)
footage_socket.connect('tcp://192.168.56.102:5555')
videoFile = "test.mp4"
camera = cv2.VideoCapture(videoFile)  
while True:
 try:
    grabbed,frame = camera.read()  #
    frame = cv2.resize(frame,(224,224))  
    encoded,buffer = cv2.imencode('.jpg',frame)
    jpg_as_text = base64.b64encode(buffer)
    footage_socket.send(jpg_as_text)

except KeyboardInterrupt:
    camera.release()
    cv2.destroyAllWindows()
    break

当我尝试运行上面的代码时,我检索到以下错误

OpenCV(3.4.1) Error: Assertion Failed (ssize.width > 0 && ssize.height > 0) in resize,file    /opencv-3.4.1/modules/imgproc/src/resize.cpp,line 4044
Traceback (most recent call last):
File "streamer.py",line 13,in <module>
  frame = cv2.resize(frame,224))  # resize the frame
cv2.error: OpenCV(3.4.1) /opencv-3.4.1/modules/imgproc/src/resize.cpp:4044: error: (-215)    ssize.width > 0 && ssize.height > 0 in function resize

非常感谢您的帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。