DepthAI
Software Stack

ON THIS PAGE

  • Pipeline
  • Source code

Camera output

Supported on:RVC2RVC4
Example showcases DepthAIv3's functionality to request an output stream directly from the Camera node, instead of having to create and configure an ImageManip node.
Python
1output = camera_node.requestOutput(
2    size=(640, 480),
3    type=dai.ImgFrame.Type.BGR888p,
4    resize_mode=dai.ImgResizeMode.CROP,
5    fps=15
6)
Resize mode can be either CROP, STRETCH, or LETTERBOX, which come into play if there's a missmatch between sensor aspect ratio (AR) and requested aspect ratio. For more information (pros/cons of each) check Input frame AR missmatch documentation.Camera Multiple Outputs example showcases how to request multiple outputs from the Camera node.This example requires the DepthAI v3 API, see installation instructions.

Pipeline

Source code

Python

Python
GitHub
1#!/usr/bin/env python3
2
3import cv2
4import depthai as dai
5
6# Create pipeline
7with dai.Pipeline() as pipeline:
8    # Define source and output
9    cam = pipeline.create(dai.node.Camera).build()
10    videoQueue = cam.requestOutput((640,400)).createOutputQueue()
11
12    # Connect to device and start pipeline
13    pipeline.start()
14    while pipeline.isRunning():
15        videoIn = videoQueue.get()
16        assert isinstance(videoIn, dai.ImgFrame)
17        cv2.imshow("video", videoIn.getCvFrame())
18
19        if cv2.waitKey(1) == ord("q"):
20            break

C++

1#include <iostream>
2#include <memory>
3#include <opencv2/opencv.hpp>
4
5#include "depthai/depthai.hpp"
6
7int main() {
8    // Create device
9    std::shared_ptr<dai::Device> device = std::make_shared<dai::Device>();
10
11    // Create pipeline
12    dai::Pipeline pipeline(device);
13
14    // Create nodes
15    auto cam = pipeline.create<dai::node::Camera>()->build();
16    auto videoQueue = cam->requestOutput(std::make_pair(640, 400))->createOutputQueue();
17
18    // Start pipeline
19    pipeline.start();
20
21    while(true) {
22        auto videoIn = videoQueue->get<dai::ImgFrame>();
23        if(videoIn == nullptr) continue;
24
25        cv::imshow("video", videoIn->getCvFrame());
26
27        if(cv::waitKey(1) == 'q') {
28            break;
29        }
30    }
31
32    return 0;
33}

Need assistance?

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