Software Stack
DepthAI
  • DepthAI Components
    • AprilTags
    • Benchmark
    • Camera
    • Calibration
    • DetectionNetwork
    • EdgeDetector
    • Events
    • FeatureTracker
    • HostNodes
    • ImageAlign
    • ImageManip
    • IMU
    • Misc
    • Model Zoo
    • NeuralNetwork
    • ObjectTracker
    • RecordReplay
    • RGBD
    • Script
    • SpatialDetectionNetwork
    • SpatialLocationCalculator
    • StereoDepth
    • Sync
    • SystemLogger
    • VideoEncoder
    • Visualizer
    • Warp
    • RVC2-specific
  • Advanced Tutorials
  • API Reference
  • Tools

ON THIS PAGE

  • Events
  • Pipeline
  • Source code

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.This example requires the DepthAI v3 API, see installation instructions.

Pipeline

Source code

Python
C++

Python

Python
GitHub
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            break

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.