When simply grabbing a 1920x1080 image and displaying to screen, the OAK 4D is demonstrating over 5 seconds of latency. This is significantly different from our OAK-D S2 model which is able to grab a 1920x1080 image and display it to screen with nearly imperceptible latency. Is this all explained due to the different connection types (POE vs USB2)? If not, are there any suggestions for how to reduce the OAK-4D latency?

    Shai
    Can you share the script you are using to retrieve the frames? Or are you using OAK viewer?

    Thanks,
    Jaka

    For the OAK-D S2, we are using the pre-made rgb_preview.cpp example (except we changed the resolution output):

    #include <iostream>

    // Includes common necessary includes for development using depthai library

    #include "depthai/depthai.hpp"

    int main() {

    using namespace std;

    // Create pipeline

    dai::Pipeline pipeline;

    // Define source and output

    auto camRgb = pipeline.create<dai::node::ColorCamera>();

    auto xoutRgb = pipeline.create<dai::node::XLinkOut>();

    xoutRgb->setStreamName("rgb");

    // Properties

    camRgb->setPreviewSize(1920, 1080);

    camRgb->setBoardSocket(dai::CameraBoardSocket::CAM_A);

    camRgb->setResolution(dai::ColorCameraProperties::SensorResolution::THE_1080_P);

    camRgb->setInterleaved(false);

    camRgb->setColorOrder(dai::ColorCameraProperties::ColorOrder::RGB);

    camRgb->setFps(30); // Set FPS to 30

    // Linking

    camRgb->preview.link(xoutRgb->input);

    // Connect to device and start pipeline

    dai::Device device(pipeline, dai::UsbSpeed::SUPER);

    cout << "Connected cameras: " << device.getConnectedCameraFeatures() << endl;

    // Print USB speed

    cout << "Usb speed: " << device.getUsbSpeed() << endl;

    // Bootloader version

    if(device.getBootloaderVersion()) {

    cout << "Bootloader version: " << device.getBootloaderVersion()->toString() << endl;

    }

    // Device name

    cout << "Device name: " << device.getDeviceName() << " Product name: " << device.getProductName() << endl;

    // Output queue will be used to get the rgb frames from the output defined above

    auto qRgb = device.getOutputQueue("rgb", 4, false);

    while(true) {

    auto inRgb = qRgb->get<dai::ImgFrame>();

    // Retrieve 'bgr' (opencv format) frame

    cv::imshow("rgb", inRgb->getCvFrame());

    int key = cv::waitKey(1);

    if(key == 'q' || key == 'Q') {

    break;

    }

    }

    return 0;

    }

    For the OAK 4D, we are using the premade camera_output.cpp exampe:

    #include <iostream>

    #include <memory>

    #include <opencv2/opencv.hpp>

    #include "depthai/depthai.hpp"

    #include <chrono>

    int main() {

    // Create device

    std::shared_ptr<dai::Device> device = std::make_shared<dai::Device>();

    // Create pipeline

    dai::Pipeline pipeline(device);

    // Create nodes

    auto cam = pipeline.create<dai::node::Camera>()->build();

    //auto videoQueue = cam->requestOutput(std::make_pair(640, 400))->createOutputQueue();

    std::cout << "FPS: " << cam->getMaxRequestedFps() << std::endl;

    auto videoQueue = cam->requestOutput(std::make_pair(1920, 1080))->createOutputQueue();

    videoQueue->setBlocking(false);

    videoQueue->setMaxSize(1);

    // Start pipeline

    pipeline.start();

    while(true) {

    auto videoIn = videoQueue->get<dai::ImgFrame>();

    if(videoIn == nullptr) continue;

    cv::imshow("video", videoIn->getCvFrame());

    if(cv::waitKey(1) == 'q') {

    break;

    }

    }

    return 0;

    }

      Hi Shai
      I would expect there is a slightly lower latency going from USB connection on the S2 to the POE on the OAK4, but 5 seconds is too much and points toward an issue in your network.
      Are you using WIFI perhaps? Or are there multiple jumps/NATs between your PC and your device?

      Thanks,
      Jaka