Skip to content

Instantly share code, notes, and snippets.

@mrtj
Last active June 20, 2022 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrtj/e30b73a751d73f7586a7e36669043c56 to your computer and use it in GitHub Desktop.
Save mrtj/e30b73a751d73f7586a7e36669043c56 to your computer and use it in GitHub Desktop.
Example usage of backpack.annotation module
import panoramasdk
from backpack.annotation import (
Point, LabelAnnotation, RectAnnotation, TimestampAnnotation,
OpenCVImageAnnotationDriver,
PanoramaMediaAnnotationDriver
)
class Application(panoramasdk.node):
def __init__(self):
super().__init__()
# self.skyline = ...
self.panorama_driver = PanoramaMediaAnnotationDriver()
self.cv2_driver = OpenCVImageAnnotationDriver()
# called from video processing loop:
def process_streams(self):
streams = self.inputs.video_in.get()
for idx, stream in enumerate(streams):
annotations = [
TimestampAnnotation(),
RectAnnotation(point1=Point(0.1, 0.1), point2=Point(0.9, 0.9)),
LabelAnnotation(point=Point(0.5, 0.5), text='Hello World!')
]
self.panorama_driver.render(annotations, stream)
# TODO: eventually multiplex streams to a single frame
if idx == 0:
rendered = self.cv2_driver.render(annotations, stream.image.copy())
# self.skyline.put(rendered)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment