-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release_2.17.4' into main
- Loading branch information
Showing
26 changed files
with
1,199 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: DepthAI Core HIL Stability | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- main | ||
- develop | ||
|
||
# Only allow latest run on same branch to be tested | ||
concurrency: | ||
group: ci-stability-${{ github.ref }}-1 | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
|
||
# Testing | ||
test: | ||
runs-on: ['self-hosted', 'hil-stability', 'linux'] | ||
timeout-minutes: 1450 # 24h & 10minutes | ||
steps: | ||
- name: Cache .hunter folder | ||
uses: actions/cache@v2 | ||
with: | ||
path: $HOME/.hun_vanilla | ||
key: hunter-linux-stability-vanilla | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
|
||
# TODO also modify above hunter key to 'asan' | ||
# - name: Specify ASAN toolchain path | ||
# run: echo "CMAKE_TOOLCHAIN_PATH=$PWD/cmake/toolchain/asan.cmake" >> $GITHUB_ENV | ||
|
||
# - name: Configure, Build and Test | ||
# run: | | ||
# cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D HUNTER_ROOT=$HOME/.hun_vanilla -D DEPTHAI_BUILD_TESTS=ON | ||
# cmake --build build --parallel 8 --config Release --target stability_stress_test | ||
# cd build | ||
# ../ci/stability_stress_test_combined.sh | ||
|
||
# Release build | ||
- name: Configure, Build and Test | ||
run: | | ||
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D HUNTER_ROOT=$HOME/.hun_vanilla -D DEPTHAI_BUILD_TESTS=ON | ||
cmake --build build --parallel 8 --config Release --target stability_stress_test | ||
cd build | ||
../ci/stability_stress_test_combined.sh 86400 |
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,38 @@ | ||
# Cleanup in case the script dies | ||
cleanup() { | ||
# kill all processes whose parent is this process | ||
pkill -P $$ | ||
} | ||
|
||
for sig in INT QUIT HUP TERM; do | ||
trap " | ||
cleanup | ||
trap - $sig EXIT | ||
kill -s $sig "'"$$"' "$sig" | ||
done | ||
trap cleanup EXIT | ||
|
||
# Print timeout if set, otherwise use default | ||
echo "Timeout set to: $1" | ||
|
||
# Run USB & PoE stability stress test | ||
DEPTHAI_PROTOCOL=usb timeout $(($1+30)) ./tests/stability_stress_test $1 & | ||
jobUsb=$! | ||
DEPTHAI_PROTOCOL=tcpip timeout $(($1+30)) ./tests/stability_stress_test $1 & | ||
jobTcpip=$! | ||
|
||
# Wait for tests and save result code | ||
wait $jobUsb ; resultUsb=$? | ||
wait $jobTcpip ; resultTcpip=$? | ||
|
||
# Print results | ||
echo "Stability test USB: $resultUsb" | ||
echo "Stability test PoE: $resultTcpip" | ||
|
||
# If both tests concluded successfully, exit with code 0 | ||
if [[ "$resultUsb" == "0" ]] && [[ "$resultTcpip" == "0" ]]; then | ||
echo "Success!" | ||
exit 0 | ||
fi | ||
echo "Failed!" | ||
exit 1 |
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,38 @@ | ||
#include <iostream> | ||
|
||
// Includes common necessary includes for development using depthai library | ||
#include "depthai/depthai.hpp" | ||
|
||
int main() { | ||
using namespace std; | ||
|
||
// Start defining a pipeline | ||
dai::Pipeline pipeline; | ||
|
||
// Script node | ||
auto script = pipeline.create<dai::node::Script>(); | ||
script->setScript(R"( | ||
import json | ||
data = json.dumps({ | ||
'deviceId': __device_id__, | ||
'fwVersion': __version__ | ||
}).encode('utf-8') | ||
b = Buffer(len(data)) | ||
b.setData(data) | ||
node.io['info'].send(b) | ||
)"); | ||
|
||
// XLinkOut | ||
auto xout = pipeline.create<dai::node::XLinkOut>(); | ||
xout->setStreamName("info"); | ||
script->outputs["info"].link(xout->input); | ||
|
||
// Connect to device with pipeline | ||
dai::Device device(pipeline); | ||
auto msg = device.getOutputQueue("info")->get<dai::Buffer>(); | ||
auto data = nlohmann::json::parse(msg->getData()); | ||
std::cout << data.dump(4) << std::endl; | ||
|
||
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
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
110 changes: 110 additions & 0 deletions
110
examples/SpatialDetection/spatial_calculator_multi_roi.cpp
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,110 @@ | ||
#include <iostream> | ||
|
||
#include "utility.hpp" | ||
|
||
// Includes common necessary includes for development using depthai library | ||
#include "depthai/depthai.hpp" | ||
|
||
static constexpr float stepSize = 0.05f; | ||
|
||
static std::atomic<bool> newConfig{false}; | ||
|
||
int main() { | ||
using namespace std; | ||
|
||
// Create pipeline | ||
dai::Pipeline pipeline; | ||
|
||
// Define sources and outputs | ||
auto monoLeft = pipeline.create<dai::node::MonoCamera>(); | ||
auto monoRight = pipeline.create<dai::node::MonoCamera>(); | ||
auto stereo = pipeline.create<dai::node::StereoDepth>(); | ||
auto spatialLocationCalculator = pipeline.create<dai::node::SpatialLocationCalculator>(); | ||
|
||
auto xoutDepth = pipeline.create<dai::node::XLinkOut>(); | ||
auto xoutSpatialData = pipeline.create<dai::node::XLinkOut>(); | ||
auto xinSpatialCalcConfig = pipeline.create<dai::node::XLinkIn>(); | ||
|
||
xoutDepth->setStreamName("depth"); | ||
xoutSpatialData->setStreamName("spatialData"); | ||
xinSpatialCalcConfig->setStreamName("spatialCalcConfig"); | ||
|
||
// Properties | ||
monoLeft->setResolution(dai::MonoCameraProperties::SensorResolution::THE_400_P); | ||
monoLeft->setBoardSocket(dai::CameraBoardSocket::LEFT); | ||
monoRight->setResolution(dai::MonoCameraProperties::SensorResolution::THE_400_P); | ||
monoRight->setBoardSocket(dai::CameraBoardSocket::RIGHT); | ||
|
||
stereo->setDefaultProfilePreset(dai::node::StereoDepth::PresetMode::HIGH_DENSITY); | ||
stereo->setLeftRightCheck(true); | ||
stereo->setExtendedDisparity(true); | ||
spatialLocationCalculator->inputConfig.setWaitForMessage(false); | ||
|
||
// Create 10 ROIs | ||
for(int i = 0; i < 10; i++) { | ||
dai::SpatialLocationCalculatorConfigData config; | ||
config.depthThresholds.lowerThreshold = 200; | ||
config.depthThresholds.upperThreshold = 10000; | ||
config.roi = dai::Rect(dai::Point2f(i*0.1, 0.45), dai::Point2f((i+1)*0.1, 0.55)); | ||
spatialLocationCalculator->initialConfig.addROI(config); | ||
} | ||
|
||
// Linking | ||
monoLeft->out.link(stereo->left); | ||
monoRight->out.link(stereo->right); | ||
|
||
spatialLocationCalculator->passthroughDepth.link(xoutDepth->input); | ||
stereo->depth.link(spatialLocationCalculator->inputDepth); | ||
|
||
spatialLocationCalculator->out.link(xoutSpatialData->input); | ||
xinSpatialCalcConfig->out.link(spatialLocationCalculator->inputConfig); | ||
|
||
// Connect to device and start pipeline | ||
dai::Device device(pipeline); | ||
device.setIrLaserDotProjectorBrightness(1000); | ||
|
||
// Output queue will be used to get the depth frames from the outputs defined above | ||
auto depthQueue = device.getOutputQueue("depth", 4, false); | ||
auto spatialCalcQueue = device.getOutputQueue("spatialData", 4, false); | ||
auto color = cv::Scalar(0, 200, 40); | ||
auto fontType = cv::FONT_HERSHEY_TRIPLEX; | ||
|
||
while(true) { | ||
auto inDepth = depthQueue->get<dai::ImgFrame>(); | ||
|
||
cv::Mat depthFrame = inDepth->getFrame(); // depthFrame values are in millimeters | ||
|
||
cv::Mat depthFrameColor; | ||
cv::normalize(depthFrame, depthFrameColor, 255, 0, cv::NORM_INF, CV_8UC1); | ||
cv::equalizeHist(depthFrameColor, depthFrameColor); | ||
cv::applyColorMap(depthFrameColor, depthFrameColor, cv::COLORMAP_HOT); | ||
|
||
auto spatialData = spatialCalcQueue->get<dai::SpatialLocationCalculatorData>()->getSpatialLocations(); | ||
for(auto depthData : spatialData) { | ||
auto roi = depthData.config.roi; | ||
roi = roi.denormalize(depthFrameColor.cols, depthFrameColor.rows); | ||
|
||
auto xmin = static_cast<int>(roi.topLeft().x); | ||
auto ymin = static_cast<int>(roi.topLeft().y); | ||
auto xmax = static_cast<int>(roi.bottomRight().x); | ||
auto ymax = static_cast<int>(roi.bottomRight().y); | ||
|
||
auto coords = depthData.spatialCoordinates; | ||
auto distance = std::sqrt(coords.x * coords.x + coords.y * coords.y + coords.z * coords.z); | ||
|
||
cv::rectangle(depthFrameColor, cv::Rect(cv::Point(xmin, ymin), cv::Point(xmax, ymax)), color); | ||
std::stringstream depthDistance; | ||
depthDistance.precision(2); | ||
depthDistance << fixed << static_cast<float>(distance/1000.0f) << "m"; | ||
cv::putText(depthFrameColor, depthDistance.str(), cv::Point(xmin + 10, ymin + 20), fontType, 0.5, color); | ||
} | ||
// Show the frame | ||
cv::imshow("depth", depthFrameColor); | ||
|
||
if(cv::waitKey(1) == 'q') { | ||
break; | ||
} | ||
|
||
} | ||
return 0; | ||
} |
Oops, something went wrong.