Created
September 7, 2021 16:45
-
-
Save J3698/f14cebd835e7370c74fd88b881e74385 to your computer and use it in GitHub Desktop.
Run the OAK pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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