zmq image stream freezes

Viewed 108

hi im trying to create a zmq image stream in order to do image processing on another machine and send back the processed image but im having some trouble with the connection for some reason i have this weird jitters and the image just freezes for a few frames here is my code

    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()

and for the other machine

    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)

some of the libs arent "directly" opencv but the image that i get is an open cv format image and what that im trying to do is process that on a different machine currently all the image processing is turned off on purpose and still im having this weird lag link to a video with the lag. thank you for the help

0 Answers
Related