DepthAI
Software Stack

ON THIS PAGE

  • Demo
  • Pipeline
  • Source code

ImageManip multiple operations

Supported on:RVC2RVC4
This example showcases multiple ImageManip operations in a row (one after another):All of this is done within the single ImageManip node in the pipeline. Note that operations order is important, as operations are applied in the order they are set.

Demo

This example requires the DepthAI v3 API, see installation instructions.

Pipeline

Source code

Python

Python
GitHub
1import depthai as dai
2import cv2
3
4pipeline = dai.Pipeline()
5
6camRgb = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_A)
7manip = pipeline.create(dai.node.ImageManip)
8
9
10manip.initialConfig.setOutputSize(1270, 710, dai.ImageManipConfig.ResizeMode.LETTERBOX)
11manip.initialConfig.addCrop(50, 100, 500, 500)
12manip.initialConfig.addFlipVertical()
13manip.initialConfig.setFrameType(dai.ImgFrame.Type.NV12)
14manip.setMaxOutputFrameSize(2709360)
15
16camRgb.requestOutput((1920, 1080)).link(manip.inputImage)
17
18out = manip.out.createOutputQueue()
19
20pipeline.start()
21
22print(manip.initialConfig)
23
24while True:
25    inFrame = out.get()
26    if inFrame is not None:
27        cv2.imshow("Show frame", inFrame.getCvFrame())
28        key = cv2.waitKey(1)
29        if key == ord('q'):
30            break

C++

1#include <memory>
2
3#include "depthai/depthai.hpp"
4#include "depthai/pipeline/datatype/ImgFrame.hpp"
5#include "depthai/pipeline/node/host/Display.hpp"
6
7int main(int argc, char** argv) {
8    std::shared_ptr<dai::Device> device = nullptr;
9    if(argc <= 1) {
10        device = std::make_shared<dai::Device>();
11    } else {
12        device = std::make_shared<dai::Device>(argv[1]);
13    }
14    dai::Pipeline pipeline(device);
15
16    auto camRgb = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_A);
17    auto manip = pipeline.create<dai::node::ImageManip>();
18
19    manip->setMaxOutputFrameSize(4000000);
20    manip->initialConfig->setOutputSize(1280, 720, dai::ImageManipConfig::ResizeMode::LETTERBOX);
21    manip->initialConfig->setBackgroundColor(100, 100, 100);
22    manip->initialConfig->addRotateDeg(45);
23    manip->initialConfig->addCrop(100, 100, 800, 600);
24    manip->initialConfig->addFlipVertical();
25    manip->initialConfig->setFrameType(dai::ImgFrame::Type::RGB888p);
26
27    auto* rgbOut = camRgb->requestOutput({1920, 1080});
28    rgbOut->link(manip->inputImage);
29    auto outputQueue = manip->out.createOutputQueue();
30    pipeline.start();
31    while(pipeline.isRunning()) {
32        auto imgFrame = outputQueue->get<dai::ImgFrame>();
33        cv::imshow("Manipulated Frame", imgFrame->getCvFrame());
34        int key = cv::waitKey(1);
35        if(key == 'q') {
36            break;
37        }
38    }
39}

Need assistance?

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