File size: 689 Bytes
f4392e4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import pyarrow as pa
from dora import DoraStatus
import cv2
import os
CAMERA_WIDTH = 960
CAMERA_HEIGHT = 540
ENCODING = os.getenv("ENCODING", ".jpg")
class Operator:
"""
Infering object from images
"""
def on_event(
self,
dora_event,
send_output,
) -> DoraStatus:
if dora_event["type"] == "INPUT":
frame = (
dora_event["value"].to_numpy().reshape((CAMERA_HEIGHT, CAMERA_WIDTH, 3))
)
retval, buffer = cv2.imencode(ENCODING, frame)
if retval:
send_output("encoded_image", pa.array([buffer]), dora_event["metadata"])
return DoraStatus.CONTINUE
|