Pipeline
Source code
Python
C++
Python
PythonGitHub
1#!/usr/bin/env python3
2import depthai as dai
3from pathlib import Path
4from argparse import ArgumentParser
5
6scriptDir = Path(__file__).resolve().parent
7examplesRoot = (scriptDir / Path('../')).resolve() # This resolves the parent directory correctly
8models = examplesRoot / 'models'
9videoPath = models / 'construction_vest.mp4'
10
11parser = ArgumentParser()
12parser.add_argument("--webSocketPort", type=int, default=8765)
13parser.add_argument("--httpPort", type=int, default=8082)
14parser.add_argument("-i", "--inputVideo", default=videoPath, help="Input video name")
15args = parser.parse_args()
16
17remoteConnector = dai.RemoteConnection(webSocketPort=args.webSocketPort, httpPort=args.httpPort)
18# Create pipeline
19with dai.Pipeline() as pipeline:
20 replay = pipeline.create(dai.node.ReplayVideo)
21 replay.setReplayVideoFile(Path(args.inputVideo))
22 detectionNetwork = pipeline.create(dai.node.DetectionNetwork).build(
23 replay, dai.NNModelDescription("yolov6-nano")
24 )
25
26 remoteConnector.addTopic("detections", detectionNetwork.out, "img")
27 remoteConnector.addTopic("images", replay.out, "img")
28
29 pipeline.start()
30 remoteConnector.registerPipeline(pipeline)
31
32 while pipeline.isRunning():
33 key = remoteConnector.waitKey(1)
34 if key == ord("q"):
35 print("Got q key from the remote connection!")
36 breakNeed assistance?
Head over to Discussion Forum for technical support or any other questions you might have.