-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #940 from luxonis/release_v2.24.0
Release v2.24.0
- Loading branch information
Showing
43 changed files
with
2,089 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <chrono> | ||
#include <iostream> | ||
|
||
#include "depthai/depthai.hpp" | ||
|
||
int main() { | ||
dai::Pipeline pipeline; | ||
|
||
auto script1 = pipeline.create<dai::node::Script>(); | ||
script1->setScript( | ||
R"SCRPT( | ||
from time import sleep | ||
while True: | ||
sleep(1) | ||
b = Buffer(512) | ||
b.setData(bytes(4 * [i for i in range(0, 128)])) | ||
b.setTimestamp(Clock.now()) | ||
node.io['out'].send(b) | ||
)SCRPT"); | ||
|
||
auto script2 = pipeline.create<dai::node::Script>(); | ||
script2->setScript( | ||
R"SCRPT( | ||
from time import sleep | ||
while True: | ||
sleep(0.3) | ||
b = Buffer(512) | ||
b.setData(bytes(4 * [i for i in range(128, 256)])) | ||
b.setTimestamp(Clock.now()) | ||
node.io['out'].send(b) | ||
)SCRPT"); | ||
|
||
auto sync = pipeline.create<dai::node::Sync>(); | ||
sync->setSyncThreshold(std::chrono::milliseconds(100)); | ||
|
||
auto demux = pipeline.create<dai::node::MessageDemux>(); | ||
|
||
auto xout1 = pipeline.create<dai::node::XLinkOut>(); | ||
xout1->setStreamName("xout1"); | ||
auto xout2 = pipeline.create<dai::node::XLinkOut>(); | ||
xout2->setStreamName("xout2"); | ||
|
||
script1->outputs["out"].link(sync->inputs["s1"]); | ||
script2->outputs["out"].link(sync->inputs["s2"]); | ||
sync->out.link(demux->input); | ||
demux->outputs["s1"].link(xout1->input); | ||
demux->outputs["s2"].link(xout2->input); | ||
|
||
dai::Device device(pipeline); | ||
std::cout << "Start" << std::endl; | ||
auto queue1 = device.getOutputQueue("xout1", 10, true); | ||
auto queue2 = device.getOutputQueue("xout2", 10, true); | ||
while(true) { | ||
auto bufS1 = queue1->get<dai::Buffer>(); | ||
auto bufS2 = queue2->get<dai::Buffer>(); | ||
std::cout << "Buffer 1 timestamp: " << bufS1->getTimestamp().time_since_epoch().count() << std::endl; | ||
std::cout << "Buffer 2 timestamp: " << bufS2->getTimestamp().time_since_epoch().count() << std::endl; | ||
std::cout << "----------" << std::endl; | ||
std::this_thread::sleep_for(std::chrono::milliseconds(200)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <iostream> | ||
|
||
// Includes common necessary includes for development using depthai library | ||
#include "depthai/depthai.hpp" | ||
|
||
int main() { | ||
// Create pipeline | ||
dai::Pipeline pipeline; | ||
|
||
// Define sources and outputs | ||
auto monoLeft = pipeline.create<dai::node::MonoCamera>(); | ||
auto monoRight = pipeline.create<dai::node::MonoCamera>(); | ||
auto color = pipeline.create<dai::node::ColorCamera>(); | ||
auto stereo = pipeline.create<dai::node::StereoDepth>(); | ||
auto sync = pipeline.create<dai::node::Sync>(); | ||
|
||
auto xoutGrp = pipeline.create<dai::node::XLinkOut>(); | ||
|
||
// XLinkOut | ||
xoutGrp->setStreamName("xout"); | ||
|
||
// Properties | ||
monoLeft->setResolution(dai::MonoCameraProperties::SensorResolution::THE_400_P); | ||
monoLeft->setCamera("left"); | ||
monoRight->setResolution(dai::MonoCameraProperties::SensorResolution::THE_400_P); | ||
monoRight->setCamera("right"); | ||
|
||
stereo->setDefaultProfilePreset(dai::node::StereoDepth::PresetMode::HIGH_ACCURACY); | ||
|
||
color->setCamera("color"); | ||
|
||
sync->setSyncThreshold(std::chrono::milliseconds(100)); | ||
|
||
// Linking | ||
monoLeft->out.link(stereo->left); | ||
monoRight->out.link(stereo->right); | ||
|
||
stereo->disparity.link(sync->inputs["disparity"]); | ||
color->video.link(sync->inputs["video"]); | ||
|
||
sync->out.link(xoutGrp->input); | ||
|
||
// Connect to device and start pipeline | ||
dai::Device device(pipeline); | ||
|
||
auto queue = device.getOutputQueue("xout", 10, true); | ||
|
||
float disparityMultiplier = 255 / stereo->initialConfig.getMaxDisparity(); | ||
|
||
while(true) { | ||
auto msgGrp = queue->get<dai::MessageGroup>(); | ||
for(auto& frm : *msgGrp) { | ||
auto imgFrm = std::dynamic_pointer_cast<dai::ImgFrame>(frm.second); | ||
cv::Mat img = imgFrm->getCvFrame(); | ||
if(frm.first == "disparity") { | ||
img.convertTo(img, CV_8UC1, disparityMultiplier); // Extend disparity range | ||
cv::applyColorMap(img, img, cv::COLORMAP_JET); | ||
} | ||
cv::imshow(frm.first, img); | ||
} | ||
|
||
int key = cv::waitKey(1); | ||
if(key == 'q' || key == 'Q') { | ||
return 0; | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <iostream> | ||
#include <opencv2/opencv.hpp> | ||
|
||
#include "depthai/depthai.hpp" | ||
|
||
int main() { | ||
dai::Device device; | ||
|
||
auto imuType = device.getConnectedIMU(); | ||
auto imuFirmwareVersion = device.getIMUFirmwareVersion(); | ||
std::cout << "IMU type: " << imuType << ", firmware version: " << imuFirmwareVersion << std::endl; | ||
|
||
if(imuType != "BNO086") { | ||
std::cout << "Rotation vector output is supported only by BNO086!" << std::endl; | ||
return 1; | ||
} | ||
|
||
dai::Pipeline pipeline; | ||
|
||
auto colorCamera = pipeline.create<dai::node::ColorCamera>(); | ||
auto imu = pipeline.create<dai::node::IMU>(); | ||
auto sync = pipeline.create<dai::node::Sync>(); | ||
auto xoutGroup = pipeline.create<dai::node::XLinkOut>(); | ||
|
||
xoutGroup->setStreamName("xout"); | ||
|
||
colorCamera->setCamera("color"); | ||
|
||
imu->enableIMUSensor(dai::IMUSensor::ROTATION_VECTOR, 120); | ||
imu->setBatchReportThreshold(1); | ||
imu->setMaxBatchReports(10); | ||
|
||
sync->setSyncThreshold(std::chrono::milliseconds(10)); | ||
sync->setSyncAttempts(-1); // Infinite attempts | ||
|
||
colorCamera->video.link(sync->inputs["video"]); | ||
imu->out.link(sync->inputs["imu"]); | ||
|
||
sync->out.link(xoutGroup->input); | ||
|
||
device.startPipeline(pipeline); | ||
|
||
auto groupQueue = device.getOutputQueue("xout", 3, false); | ||
|
||
while(true) { | ||
auto groupMessage = groupQueue->get<dai::MessageGroup>(); | ||
auto imuData = groupMessage->get<dai::IMUData>("imu"); | ||
auto colorData = groupMessage->get<dai::ImgFrame>("video"); | ||
auto timeDifference = imuData->getTimestampDevice() - colorData->getTimestampDevice(); | ||
auto timeDifferenceUs = std::chrono::duration_cast<std::chrono::microseconds>(timeDifference).count(); | ||
|
||
std::cout << "Time difference between messages is: " << std::abs(timeDifferenceUs / 1000.0) << " ms" << std::endl; | ||
|
||
for(auto& packet : imuData->packets) { | ||
auto& rv = packet.rotationVector; | ||
|
||
printf( | ||
"Quaternion: i: %.3f j: %.3f k: %.3f real: %.3f\n" | ||
"Accuracy (rad): %.3f \n", | ||
rv.i, | ||
rv.j, | ||
rv.k, | ||
rv.real, | ||
rv.rotationVectorAccuracy); | ||
} | ||
|
||
cv::imshow("Color", colorData->getCvFrame()); | ||
if(cv::waitKey(1) == 'q') { | ||
break; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <chrono> | ||
#include <iostream> | ||
|
||
#include "depthai/depthai.hpp" | ||
|
||
int main() { | ||
dai::Pipeline pipeline; | ||
|
||
auto script1 = pipeline.create<dai::node::Script>(); | ||
script1->setScript( | ||
R"SCRPT( | ||
from time import sleep | ||
while True: | ||
sleep(1) | ||
b = Buffer(512) | ||
b.setData(bytes(4 * [i for i in range(0, 128)])) | ||
b.setTimestamp(Clock.now()) | ||
node.io['out'].send(b) | ||
)SCRPT"); | ||
|
||
auto script2 = pipeline.create<dai::node::Script>(); | ||
script2->setScript( | ||
R"SCRPT( | ||
from time import sleep | ||
while True: | ||
sleep(0.3) | ||
b = Buffer(512) | ||
b.setData(bytes(4 * [i for i in range(128, 256)])) | ||
b.setTimestamp(Clock.now()) | ||
node.io['out'].send(b) | ||
)SCRPT"); | ||
|
||
auto sync = pipeline.create<dai::node::Sync>(); | ||
sync->setSyncThreshold(std::chrono::milliseconds(100)); | ||
|
||
auto xout = pipeline.create<dai::node::XLinkOut>(); | ||
xout->setStreamName("xout"); | ||
|
||
sync->out.link(xout->input); | ||
script1->outputs["out"].link(sync->inputs["s1"]); | ||
script2->outputs["out"].link(sync->inputs["s2"]); | ||
|
||
dai::Device device(pipeline); | ||
std::cout << "Start" << std::endl; | ||
auto queue = device.getOutputQueue("xout", 10, true); | ||
while(true) { | ||
auto grp = queue->get<dai::MessageGroup>(); | ||
std::cout << "Buffer 1 timestamp: " << grp->get<dai::Buffer>("s1")->getTimestamp().time_since_epoch().count() << std::endl; | ||
std::cout << "Buffer 2 timestamp: " << grp->get<dai::Buffer>("s2")->getTimestamp().time_since_epoch().count() << std::endl; | ||
std::cout << "Time interval between messages: " << static_cast<double>(grp->getIntervalNs()) / 1e6 << "ms" << std::endl; | ||
std::cout << "----------" << std::endl; | ||
std::this_thread::sleep_for(std::chrono::milliseconds(200)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.