Skip to content

Instantly share code, notes, and snippets.

@thepycoder
Last active May 18, 2021 10:24
Show Gist options
  • Save thepycoder/5384455ab9a1ef5b5faab8cb3b675b07 to your computer and use it in GitHub Desktop.
Save thepycoder/5384455ab9a1ef5b5faab8cb3b675b07 to your computer and use it in GitHub Desktop.
def create_pipeline(self):
# Create pipeline and set version
pipeline = dai.Pipeline()
pipeline.setOpenVINOVersion(version=dai.OpenVINO.Version.VERSION_2021_3)
# Camera specific settings
cam = pipeline.createColorCamera()
cam.setPreviewSize(*self.nn_shape)
cam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
cam.setInterleaved(False)
cam.setBoardSocket(dai.CameraBoardSocket.RGB)
cam.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
cam.setPreviewKeepAspectRatio(False)
# Set camera high quality output
cam_xout = pipeline.createXLinkOut()
cam_xout.setStreamName("high_quality_out")
cam_xout.input.setBlocking(False)
# Define a neural network that will make predictions based on the source frames
detection_nn = pipeline.createNeuralNetwork()
detection_nn.setBlobPath(self.nn_path)
detection_nn.input.setBlocking(False)
# Create neural network output
detection_nn_xout = pipeline.createXLinkOut()
detection_nn_xout.setStreamName("detection_out")
detection_nn_xout.input.setBlocking(False)
# Link different inputs and outputs
# Send the resized 'preview' stream to the nn, while the high quality output is sent to another queue
cam.video.link(cam_xout.input)
cam.preview.link(detection_nn.input)
detection_nn.out.link(detection_nn_xout.input)
return pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment