fix: frame msg created with bad id and timestamp

This commit is contained in:
Cyrille Nofficial 2022-01-28 12:51:10 +01:00
parent 35dd8d957a
commit 863cddbc17

View File

@ -1,8 +1,8 @@
import datetime
import logging
import paho.mqtt.client as mqtt
import events.events_pb2
from google.protobuf.timestamp_pb2 import Timestamp
import depthai as dai
import cv2
@ -63,11 +63,11 @@ class FramePublisher:
is_success, im_buf_arr = cv2.imencode(".jpg", im_resize)
byte_im = im_buf_arr.tobytes()
timestamp = Timestamp()
now = datetime.datetime.now()
frame_msg = events.events_pb2.FrameMessage()
frame_msg.id.name = "robocar-oak-camera-oak"
frame_msg.id.id = str(timestamp.ToMilliseconds())
frame_msg.id.created_at.FromMilliseconds(timestamp.ToMilliseconds())
frame_msg.id.id = str(int(now.timestamp() * 1000))
frame_msg.id.created_at.FromDatetime(now)
frame_msg.frame = byte_im
logger.debug("publish frame event to %s", self._frame_topic)