Hi jakaskerl
Please see attached screenshots, runs using video or preview of the below simple program (OAK with IMX582, using an OAK with IMX378 fps pretty much doubles)
Can you please let me know if you can reproduce my results, if there is anything wrong with my code, if there is a way to make a (simple) conversion to RGB from the ISP without losing so much fps.
Thanks!
#!/usr/bin/env python3
import depthai as dai
import time
from string import Template
from pathlib import Path
import os
import sys
import argparse
import cv2
import numpy as np
import json
from collections import namedtuple
deviceIP = "192.168.1.201"
sensorResolution = dai.ColorCameraProperties.SensorResolution.THE_4_K
standaloneMode = False
PREVIEW = True
outW = 640
outH = 640
def main():
SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
dist_path = SCRIPT_DIRECTORY + '.'
# Start defining a pipeline
pipeline = dai.Pipeline()
# Define output Xlinks for local display on host
videoOutStream = pipeline.create(dai.node.XLinkOut)
videoOutStream.setStreamName("rgb")
cam = setupCamera(pipeline, sensorResolution, outW, outH)
if PREVIEW:
cam.preview.link(videoOutStream.input)
else: cam.video.link(videoOutStream.input)
device_info = None
if deviceIP != "": device_info = dai.DeviceInfo(deviceIP) # connect to selected device ip or discover device
else:
devices = dai.Device.getAllAvailableDevices()
for dev_info in devices:
if dev_info.protocol == dai.X_LINK_TCP_IP:
device_info = dev_info
executeOnHost(pipeline, device_info) # execute on host
#-----------------------------------------------------
def setupCamera(pipeline, sensorResolution, W, H):
camRgb = pipeline.create(dai.node.ColorCamera)
camRgb.setResolution(sensorResolution)
camRgb.setVideoSize(W, H)
camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB) # set preview color order
camRgb.setPreviewSize(W, H)
camRgb.setPreviewKeepAspectRatio(True) # don't distort image
camRgb.setInterleaved(False) # Set planar or interleaved data of preview output frames
if sensorResolution == dai.ColorCameraProperties.SensorResolution.THE_4_K:
camRgb.setIspScale(3, 10)
else: camRgb.setIspScale(7, 10)
#camRgb.setNumFramesPool(4,4,1,2,1) # pool sizes for all outputs (raw, isp, preview, video, still):
camRgb.initialControl.setAutoExposureEnable()
camRgb.initialControl.setAutoExposureCompensation(1)
#camRgb.initialControl.setAutoFocusMode(dai.RawCameraControl.AutoFocusMode.CONTINUOUS_VIDEO)
return camRgb
#-----------------------------------------------------------
def executeOnHost(pipeline, device_info):
with dai.Device(pipeline, device_info) as device:
device.setLogLevel(dai.LogLevel.INFO)
device.setLogOutputLevel(dai.LogLevel.INFO)
device.setSystemInformationLoggingRate(0.0) # Hz 0.0->only once
# Print MxID or IP and sensor on the device
print(f"Device: '{device.getDeviceName()}' {device.getDeviceInfo()} Sensor: {device.getCameraSensorNames()}")
qRgb = device.getOutputQueue(name="rgb", maxSize=8, blocking=False)
frame = None
color2 = (255, 0, 0)
fpsCounter = 0
fps = 0
startTime = time.monotonic()
while True:
inRgb = qRgb.get()
if inRgb is not None:
frame = inRgb.getCvFrame()
cv2.putText(frame, "FPS: {:.2f}".format(fps)+f' preview: {PREVIEW}',
(2, frame.shape[0] - 4), cv2.FONT_HERSHEY_TRIPLEX, 0.6, color2,2)
if frame is not None:
cv2.imshow("rgb", frame)
fpsCounter = fpsCounter + 1
t = time.monotonic()- startTime
if t > 1:
fps = fpsCounter/ t
fpsCounter = 0
startTime = time.monotonic()
if cv2.waitKey(1) == ord('q'):
break
main()
