rgb_video.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 // Includes common necessary includes for development using depthai library
4 #include "depthai/depthai.hpp"
5 
6 int main() {
7  // Create pipeline
8  dai::Pipeline pipeline;
9 
10  // Define source and output
11  auto camRgb = pipeline.create<dai::node::ColorCamera>();
12  auto xoutVideo = pipeline.create<dai::node::XLinkOut>();
13 
14  xoutVideo->setStreamName("video");
15 
16  // Properties
19  camRgb->setVideoSize(1920, 1080);
20 
21  xoutVideo->input.setBlocking(false);
22  xoutVideo->input.setQueueSize(1);
23 
24  // Linking
25  camRgb->video.link(xoutVideo->input);
26 
27  // Connect to device and start pipeline
28  dai::Device device(pipeline);
29 
30  auto video = device.getOutputQueue("video");
31 
32  while(true) {
33  auto videoIn = video->get<dai::ImgFrame>();
34 
35  // Get BGR frame from NV12 encoded video frame to show with opencv
36  // Visualizing the frame on slower hosts might have overhead
37  cv::imshow("video", videoIn->getCvFrame());
38 
39  int key = cv::waitKey(1);
40  if(key == 'q' || key == 'Q') {
41  return 0;
42  }
43  }
44  return 0;
45 }
dai::node::XLinkOut
XLinkOut node. Sends messages over XLink.
Definition: XLinkOut.hpp:14
dai::Pipeline
Represents the pipeline, set of nodes and connections between them.
Definition: Pipeline.hpp:100
dai::CameraBoardSocket::CAM_A
@ CAM_A
dai::node::ColorCamera
ColorCamera node. For use with color sensors.
Definition: ColorCamera.hpp:16
dai::Device::getOutputQueue
std::shared_ptr< DataOutputQueue > getOutputQueue(const std::string &name)
Definition: Device.cpp:86
depthai.hpp
dai::Pipeline::create
std::shared_ptr< N > create()
Definition: Pipeline.hpp:145
dai::node::ColorCamera::setBoardSocket
void setBoardSocket(CameraBoardSocket boardSocket)
Definition: ColorCamera.cpp:35
dai::ImgFrame
Definition: ImgFrame.hpp:25
dai::ColorCameraProperties::SensorResolution::THE_1080_P
@ THE_1080_P
1920 × 1080
dai::node::ColorCamera::video
Output video
Definition: ColorCamera.hpp:62
dai::Device
Definition: Device.hpp:21
main
int main()
Definition: rgb_video.cpp:6


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19