Skip to content

Instantly share code, notes, and snippets.

@J3698
Created September 7, 2021 16:45
Show Gist options
  • Save J3698/f14cebd835e7370c74fd88b881e74385 to your computer and use it in GitHub Desktop.
Save J3698/f14cebd835e7370c74fd88b881e74385 to your computer and use it in GitHub Desktop.
Run the OAK pipeline
def run_pipeline(pipeline):
with depthai.Device(pipeline) as device:
q_nn = device.getOutputQueue("nn", maxSize=4, blocking=False)
while True:
in_nn = q_nn.tryGet()
if in_nn is not None:
# get data
output = in_nn.getAllLayerNames()[-1]
data = np.array(in_nn.getLayerFp16(output))
# format data as image
data = data.reshape(3, 256, 256).transpose(1, 2, 0).astype(np.uint8)
data = cv2.resize(data, (1024, 1020))
# show image
cv2.imshow("preview", data)
# quit if user presses q
if cv2.waitKey(1) == ord('q'):
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment