zmq图像流冻结

时间:2019-06-19 16:49:31

标签: python opencv zeromq

嗨,我正在尝试创建zmq图像流以便在另一台机器上进行图像处理并发送回已处理的图像,但是由于某种原因我在连接方面遇到了麻烦,我出现了怪异的抖动,图像只是冻结了几帧 这是我的代码

    context = zmq.Context(1)
    socket = context.socket(zmq.REQ)
    socket.bind("tcp://*:%s" % port)
    p = Process(target=self.camera_process, args=(cam_name, port))
    p.start()
    pipeline = SettingsManager().cams[cam_name]["pipelines"]["pipeline0"]
    while True:
        # start = time.time(
        _, image = cv_sink.grabFrame(image)
        socket.send_pyobj({'image': image,
                           'pipeline': pipeline})
        # end = time.time()
        image = socket.recv_pyobj()

以及另一台机器

    context = zmq.Context(1)
    socket = context.socket(zmq.REP)
    socket.connect("tcp://localhost:%s" % port)

    while True:
        obj = socket.recv_pyobj()
        image = obj['image']
        # curr_pipeline = obj["pipeline"]
        # hsv_image = self._hsv_threshold(curr_pipeline["hue"],
        #                                 curr_pipeline["saturation"], curr_pipeline["value"],
        #                                 image, curr_pipeline["erode"], curr_pipeline["dilate"])
        # contours = self.find_contours(hsv_image)
        # filtered_contours = self.filter_contours(contours, cam_area, curr_pipeline["area"], curr_pipeline["ratio"],
        #                                          curr_pipeline["extent"])
        # res = self.draw_image(input_image=image, is_binary=False, rectangles=filtered_contours)
        socket.send_pyobj(image)

一些libs arent“直接”打开opencv,但是我得到的图像是开放的cv格式图像,而我试图做的是在另一台机器上处理当前所有图像处理都被有意关闭的情况,并且仍然我有这个奇怪的滞后link to a video with the lag。谢谢你的帮助

0 个答案:

没有答案