Exemplo n.º 1
0
def draw_ts(frame: VideoFrame) -> bool:
    font = cv2.FONT_HERSHEY_SIMPLEX
    msgs = frame.messages()
    for m in msgs:
        data = json.loads(m)
        if start_ts is not None:
            data["ts"] = int(start_ts) + int(data["timestamp"] / 1000000000)
        else:
            data["ts"] = int(time.time())
        frame_ts = data["ts"]
        frame.remove_message(m)
        frame.add_message(json.dumps(data))
    with frame.data() as mat:
        cv2.putText(mat, str(frame_ts), (20, 20), font, 1, (255, 255, 255), 2)
    return True
 def process_frame(self, frame: VideoFrame) -> bool:
     try:
         logger.debug('Python Bridge.process_frame() method invoked!')
         for message in frame.messages():
             frame.remove_message(message)
             msg_dict = {
                 "name": self._edgex_device,
                 "cmd": self._edgex_command,
                 "method": "get",
                 self._edgex_resource: message
             }
             msg_dict = json.dumps(msg_dict)
             frame.add_message(msg_dict)
         logger.debug('Done!')
     except Exception:
         print_message("Error processing frame: {}".format(
             traceback.print_exc()))
     return True
    def process_frame(self, frame: VideoFrame) -> bool:

        msgs = frame.messages()

        for m in msgs:
            data = json.loads(m)
            if self.ts is not None:
                ts = int(ciso8601.parse_datetime(self.ts).timestamp())
                data["ts"] = int(ts) + int(data["timestamp"] / 1000000000)
            else:
                data["ts"] = int(time.time())

            self.fs = data["ts"]
            frame.remove_message(m)
            frame.add_message(json.dumps(data))
            # print(data)
        with frame.data() as mat:
            cv2.putText(mat, str(self.fs), (20, 20), font, 0.5,
                        (255, 255, 255), 2)
        return True
Exemplo n.º 4
0
 def frame_callback(self, frame: VideoFrame):
     for message in frame.messages():
         m = json.loads(message)
         #if iot_hub_manager is not None:
         iot_hub_manager.send_message_to_upstream(json.dumps(message))
         print(m)