Skip to content

Instantly share code, notes, and snippets.

@thepycoder
Last active May 18, 2021 11:07
Show Gist options
  • Save thepycoder/79a4693acec8943aeba4de6c978e7c8b to your computer and use it in GitHub Desktop.
Save thepycoder/79a4693acec8943aeba4de6c978e7c8b to your computer and use it in GitHub Desktop.
def run(self):
pipeline = self.create_pipeline()
# Pipeline defined, now the device is connected to
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()
# Set queues to be read from later
self.high_quality_out = device.getOutputQueue(name="high_quality_out", maxSize=4, blocking=False)
self.detection_out = device.getOutputQueue(name="detection_out", maxSize=4, blocking=False)
# Create a separate thread which will read the final frames from a queue
# and ingest them in a virtual webcam
t = threading.Thread(target=self.pipe_to_virtual_webcam)
t.start()
# Start processing the detections frame by frame by reading from the 2 queues above
final_frame = self.process_detections()
# Add the final frame (with background replaced) to the queue for the virtual webcam to read from
self.webcam_queue.put(cv2.cvtColor(final_frame, cv2.COLOR_BGR2RGB))
# Wait for thread to finish
t.join()
self.webcam_queue.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment