examples
Script
script_camera_control.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
using namespace
std
;
8
9
// Start defining a pipeline
10
dai::Pipeline
pipeline;
11
12
// Define a source - color camera
13
auto
colorCam = pipeline.
create
<
dai::node::ColorCamera
>();
14
15
// Script node
16
auto
script = pipeline.
create
<
dai::node::Script
>();
17
script->setScript(R
"(
18
import time
19
ctrl = CameraControl()
20
ctrl.setCaptureStill(True)
21
while True:
22
time.sleep(1)
23
node.io['out'].send(ctrl)
24
)");
25
26
// XLinkOut
27
auto
xout = pipeline.
create
<
dai::node::XLinkOut
>();
28
xout->
setStreamName
(
"still"
);
29
30
// Connections
31
script->outputs[
"out"
].link(colorCam->inputControl);
32
colorCam->
still
.
link
(xout->input);
33
34
// Connect to device with pipeline
35
dai::Device
device(pipeline);
36
while
(
true
) {
37
auto
img = device.
getOutputQueue
(
"still"
)->get<
dai::ImgFrame
>();
38
cv::imshow(
"still"
, img->getCvFrame());
39
if
(cv::waitKey(1) ==
'q'
) {
40
break
;
41
}
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::node::ColorCamera
ColorCamera node. For use with color sensors.
Definition:
ColorCamera.hpp:16
dai::node::ColorCamera::still
Output still
Definition:
ColorCamera.hpp:76
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::Script
Definition:
Script.hpp:15
dai::ImgFrame
Definition:
ImgFrame.hpp:25
dai::Device
Definition:
Device.hpp:21
std
Definition:
Node.hpp:366
main
int main()
Definition:
script_camera_control.cpp:6
dai::Node::Output::link
void link(const Input &in)
Definition:
Node.cpp:84
dai::node::XLinkOut::setStreamName
void setStreamName(const std::string &name)
Definition:
XLinkOut.cpp:13
depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19