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

本页目录

  • Pipeline
  • 源代码

Camera 视频最大分辨率

Supported on:RVC2RVC4
使用 OpenCV 在主机上以最高可用分辨率显示摄像头流。此示例使用 Camera 节点和 requestFullResolutionOutput(useHighestResolution=True) 来请求传感器的最高分辨率流。此示例需要 DepthAI v3 API,请参阅 安装说明

Pipeline

源代码

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    # In some cases (IMX586), this requires an 8k screen to be able to see the full resolution at once
11    videoQueue = cam.requestFullResolutionOutput(useHighestResolution=True).createOutputQueue()
12
13    # Connect to device and start pipeline
14    pipeline.start()
15    while pipeline.isRunning():
16        videoIn = videoQueue.get()
17        assert isinstance(videoIn, dai.ImgFrame)
18        cv2.imshow("video", videoIn.getCvFrame())
19
20        if cv2.waitKey(1) == ord("q"):
21            break

C++

1#include <atomic>
2#include <csignal>
3#include <iostream>
4#include <memory>
5#include <opencv2/opencv.hpp>
6
7#include "depthai/depthai.hpp"
8
9std::atomic<bool> quitEvent(false);
10
11void signalHandler(int) {
12    quitEvent = true;
13}
14
15int main() {
16    signal(SIGTERM, signalHandler);
17    signal(SIGINT, signalHandler);
18
19    // Create device
20    std::shared_ptr<dai::Device> device = std::make_shared<dai::Device>();
21
22    // Create pipeline
23    dai::Pipeline pipeline(device);
24
25    // Create nodes
26    auto cam = pipeline.create<dai::node::Camera>()->build();
27    // In some cases (IMX586), this requires an 8k screen to be able to see the full resolution at once
28    auto videoQueue = cam->requestFullResolutionOutput()->createOutputQueue();
29
30    // Start pipeline
31    pipeline.start();
32
33    while(pipeline.isRunning() && !quitEvent) {
34        auto videoIn = videoQueue->get<dai::ImgFrame>();
35        if(videoIn == nullptr) continue;
36
37        cv::imshow("video", videoIn->getCvFrame());
38
39        if(cv::waitKey(1) == 'q') {
40            break;
41        }
42    }
43
44    pipeline.stop();
45    pipeline.wait();
46
47    return 0;
48}

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。