此页面由 AI 自动翻译。查看英文原版
DepthAI
软件栈
最后更新

本页目录

  • 流水线
  • 源代码
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

摄像头ISP输出

最后更新
Supported on:RVC2RVC4
本示例展示了如何使用Camera节点的isp输出。图像信号处理器(ISP)是摄像头的一个关键组件,有助于在成像系统中实现所需的输出质量。正是ISP将图像传感器提供的原始图像转换为可用形式,然后嵌入式视觉系统可以使用该形式执行各种任务。此示例需要 DepthAI v3 API,请参阅 安装说明。

流水线

源代码

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

需要帮助?

请访问讨论论坛以获取技术支持或您可能有的任何其他问题。