Events
This example shows how to use the EventsManager to send custom events, including file data and RGB camera frames, with associated tags and metadata.EventsManager node is currently in "early access preview". Please use the depthai-core develop branch to have access to the latest features and fixes.
Pipeline
Source code
Python
C++
Python
PythonGitHub
1#!/usr/bin/env python3
2
3import cv2
4import depthai as dai
5import numpy as np
6import time
7
8
9# Create pipeline
10with dai.Pipeline() as pipeline:
11 # Define sources and outputs
12 camRgb = pipeline.create(dai.node.Camera).build()
13 # Properties
14
15 qRgb = camRgb.requestOutput((256,256)).createOutputQueue()
16
17 eventMan = dai.EventsManager()
18 eventMan.setLogResponse(True)
19
20 eventMan.sendEvent("test1", None, [], ["tag1", "tag2"], {"key1": "value1"})
21 time.sleep(2)
22 fileData = dai.EventData(b'Hello, world!', "hello.txt", "text/plain")
23 eventMan.sendEvent("test2", None, [fileData], ["tag1", "tag2"], {"key1": "value1"})
24 pipeline.start()
25
26 frame = None
27 counter = 0
28
29
30 eventSent = False
31 while pipeline.isRunning():
32 inRgb: dai.ImgFrame = qRgb.get()
33 if inRgb is not None:
34 frame = inRgb.getCvFrame()
35 if not eventSent:
36 eventMan.sendSnap("rgb", inRgb, [], ["tag1", "tag2"], {"key1": "value1"})
37 eventSent = True
38
39 if frame is not None:
40 cv2.imshow("rgb", frame)
41
42 if cv2.waitKey(1) == ord("q"):
43 pipeline.stop()
44 breakNeed assistance?
Head over to Discussion Forum for technical support or any other questions you might have.