DepthAI
Software Stack

ON THIS PAGE

  • Pipeline
  • Source code

Camera isp output

Supported on:RVC2RVC4
This example shows how to use the isp output from the Camera node. Image Signal Processor (ISP) is a key camera component that helps achieve the desired output quality in imaging systems. It is the ISP that converts raw images delivered by an image sensor into a usable form, which can then be used by the embedded vision system for various tasks.This example requires the DepthAI v3 API, see installation instructions.

Pipeline

Source code

Python

Python
GitHub
1import cv2
2import depthai as dai
3
4# Create pipeline
5with dai.Pipeline() as pipeline:
6    # Define source and output
7    cam = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
8    videoQueue = cam.requestOutput((800,400), fps=30).createOutputQueue()
9    videoIsp = cam.requestIspOutput(fps=2).createOutputQueue()
10    # Connect to device and start pipeline
11    pipeline.start()
12    videoIn = videoQueue.get()
13    videoInIsp = videoIsp.get()
14    print(
15        "Standard output resolution = "
16        f"{ videoIn.getCvFrame().shape[1]} x { videoIn.getCvFrame().shape[0]}"
17    )
18    print(
19        f"Isp output resolution = "
20        f"{ videoInIsp.getCvFrame().shape[1]} x { videoInIsp.getCvFrame().shape[0]}"
21    )
22    while pipeline.isRunning():
23        videoIn = videoQueue.tryGet()
24        videoInIsp = videoIsp.tryGet() # Returns 640x400
25        if videoIn:
26            cv2.imshow("video", videoIn.getCvFrame())
27        if videoInIsp:
28            cv2.imshow("videoIsp", videoInIsp.getCvFrame())
29
30        if cv2.waitKey(1) == ord("q"):
31            break

C++

1#include <iostream>
2#include <opencv2/opencv.hpp>
3
4#include "depthai/depthai.hpp"
5
6int main() {
7    using namespace dai;
8    using namespace std;
9
10    dai::Pipeline pipeline;
11
12    auto cam = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_B);
13
14    // Request outputs
15    auto videoOut = cam->requestOutput(std::make_pair(800, 400), std::nullopt, ImgResizeMode::CROP, 30.0f, std::nullopt);
16    auto ispOut = cam->requestIspOutput(2.0f);
17
18    // Create output queues
19    auto videoQueue = videoOut->createOutputQueue();
20    auto ispQueue = ispOut->createOutputQueue();
21
22    pipeline.start();
23
24    // Get first frames and print resolutions
25    auto videoIn = videoQueue->get<dai::ImgFrame>();
26    auto videoInIsp = ispQueue->get<dai::ImgFrame>();
27
28    cout << "Standard output resolution = " << videoIn->getCvFrame().cols << " x " << videoIn->getCvFrame().rows << endl;
29
30    cout << "Isp output resolution = " << videoInIsp->getCvFrame().cols << " x " << videoInIsp->getCvFrame().rows << endl;
31
32    // Main loop
33    while(pipeline.isRunning()) {
34        auto videoIn = videoQueue->tryGet<dai::ImgFrame>();
35        auto videoInIsp = ispQueue->tryGet<dai::ImgFrame>();
36
37        if(videoIn) {
38            cv::imshow("video", videoIn->getCvFrame());
39        }
40        if(videoInIsp) {
41            cv::imshow("videoIsp", videoInIsp->getCvFrame());
42        }
43
44        if(cv::waitKey(1) == 'q') break;
45    }
46
47    return 0;
48}

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.