jakaskerl
I somehow got it to work with the MRE, maybe there were some issues in my original script. Are there any improvements I can make to this MRE code:
#!/usr/bin/env python3
import depthai as dai
import time
import os
import cv2
import keyboard
# Create pipeline
pipeline = dai.Pipeline()
# Define sources and output
camRgb = pipeline.create(dai.node.ColorCamera)
xoutPrev = pipeline.create(dai.node.XLinkOut)
xoutPrev.setStreamName('preview')
camRgb.setBoardSocket(dai.CameraBoardSocket.RGB)
fps = 30
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
camRgb.video.link(xoutPrev.input)
with dai.Device(pipeline) as device:
qPreview = device.getOutputQueue(name="preview", maxSize=10,blocking=False)
# The .h265 file is a raw stream file (not playable yet)
temp = dict()
fc = 0
starttime = time.time()
totaltime = 0
getImgs = False
try:
while True:
if getImgs and time.time()-starttime <= 1:
frame = qPreview.tryGet()
if frame is not None:
fc += 1
frame_name = f"{int(time.time()*1000)}.jpeg"
temp[frame_name] = frame
elif getImgs:
totaltime = time.time() - starttime
print(f"Total frame count: {fc}")
print(f"Total time run: {totaltime}")
print(f"FPS: {fc/totaltime}")
output_folder = rf".\testPhotos"
for filename, f in temp.items():
pathout = f"../testPhotos/{filename}"
f = f.getCvFrame()
cv2.imwrite(pathout,f)
getImgs = False
temp.clear()
fc = 0
totaltime = 0
if not getImgs:
keyboard.wait("c")
getImgs = True
starttime = time.time()
except KeyboardInterrupt:
pass