Skip to content

Commit

Permalink
Rebase from 'debian/noetic/depthai'
Browse files Browse the repository at this point in the history
  • Loading branch information
Serafadam committed Dec 31, 2024
1 parent 3d9fdba commit 1dfe73f
Show file tree
Hide file tree
Showing 30 changed files with 552 additions and 4,691 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package depthai
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2.29.0 (2024-11-26)
* Features
* Add the ability to change the calibration on the device in runtime with the new `dai::Device.setCalibration()` method and to retrieve it with the `dai::Device.getCalibration()`.
* New `StereoDepth` presets:
* `DEFAULT`
* `FACE`
* `HIGH_DETAIL`
* `ROBOTICS`
* Multiple camera improvements (more details in https://github.com/luxonis/depthai-core/pull/972):
* Expose more downsampling modes when picking a lower than native resolutions
* Expose more binning modes when binning is picked on IMX582/586 (`sum` and `avg`)
* HDR on IMX582/586
* Option to bypass 3A for having manual expose/ISO take effect faster
* Initial support for new Sony 4K Starvis sensors: IMX678 and IMX715
* Option to set the main camera to drive auto-exposure and auto-white-balance in multi-camera configurations
* Improved StereoDepth filtering and an option to use a set a custom order of filters
* Disparity is first scaled to 13 bit before going through filtering, which results in filters being more effective.


* Misc
* Remove false reports on crashes that happened on device destruction
* Add `getWidth()` and `getHeight()` API to `EncodedFrame`

2.28.0 (2024-08-21)
-----------
Features
Expand Down
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Early options
option(DEPTHAI_ENABLE_LIBUSB "Enable usage of libusb and interaction with USB devices" ON)

# Early options
option(DEPTHAI_ENABLE_LIBUSB "Enable usage of libusb and interaction with USB devices" ON)

# Set to use native tls for windows before including Hunter (used for Curl)
if(WIN32)
set(DEPTHAI_CURL_USE_SCHANNEL ON)
Expand Down Expand Up @@ -62,7 +59,7 @@ if(WIN32)
endif()

# Create depthai project
project(depthai VERSION "2.28.0" LANGUAGES CXX C)
project(depthai VERSION "2.29.0" LANGUAGES CXX C)
get_directory_property(has_parent PARENT_DIRECTORY)
if(has_parent)
set(DEPTHAI_VERSION ${PROJECT_VERSION} PARENT_SCOPE)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

# "full commit hash of device side binary"
set(DEPTHAI_DEVICE_SIDE_COMMIT "9ed7c9ae4c232ff93a3500a585a6b1c00650e22c")
set(DEPTHAI_DEVICE_SIDE_COMMIT "4d360b5c56225f23e9a3d3a3999ce46c90cfdeaf")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
4,644 changes: 0 additions & 4,644 deletions debian/changelog

This file was deleted.

7 changes: 7 additions & 0 deletions debian/changelog.em
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@[for change_version, change_date, changelog, main_name, main_email in changelogs]@(Package) (@(change_version)@(DebianInc)@(Distribution)) @(Distribution); urgency=high

@(changelog)

-- @(main_name) <@(main_email)> @(change_date)

@[end for]
1 change: 0 additions & 1 deletion debian/compat

This file was deleted.

1 change: 1 addition & 0 deletions debian/compat.em
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@(debhelper_version)
12 changes: 0 additions & 12 deletions debian/control

This file was deleted.

14 changes: 14 additions & 0 deletions debian/control.em
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Source: @(Package)
Section: misc
Priority: optional
Maintainer: @(Maintainer)
Build-Depends: debhelper (>= @(debhelper_version).0.0), @(', '.join(BuildDepends))
Homepage: @(Homepage)
Standards-Version: 3.9.2

Package: @(Package)
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, @(', '.join(Depends))
@[if Conflicts]Conflicts: @(', '.join(Conflicts))@\n@[end if]@
@[if Replaces]Replaces: @(', '.join(Replaces))@\n@[end if]@
Description: @(Description)
10 changes: 7 additions & 3 deletions debian/copyright → debian/copyright.em
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Format: Bloom subset of https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: depthai
Upstream-Name: @(Name)
@[if BugTracker]Upstream-Contact: @(BugTracker)@\n@[end if]@
@[if Source]Source: @(Source)@\n@[end if]@
@[for License, Text in Licenses]@

Files: See file headers in repository for details
Copyright: See package copyright in source code for details
License: MIT
See repository for full license text
License: @(License)
@(Text)
@[end for]@
3 changes: 0 additions & 3 deletions debian/gbp.conf

This file was deleted.

3 changes: 3 additions & 0 deletions debian/gbp.conf.em
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[git-buildpackage]
upstream-tag=@(release_tag)
upstream-tree=tag
20 changes: 10 additions & 10 deletions debian/rules → debian/rules.em
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export DH_VERBOSE=1
# https://code.ros.org/trac/ros/ticket/2977
# https://code.ros.org/trac/ros/ticket/3842
export LDFLAGS=
export PKG_CONFIG_PATH=/opt/ros/noetic/lib/pkgconfig
export PKG_CONFIG_PATH=@(InstallationPrefix)/lib/pkgconfig
# Explicitly enable -DNDEBUG, see:
# https://github.com/ros-infrastructure/bloom/issues/327
export DEB_CXXFLAGS_MAINT_APPEND=-DNDEBUG
Expand All @@ -27,43 +27,43 @@ export DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

%:
dh $@ -v --buildsystem=cmake --builddirectory=.obj-$(DEB_HOST_GNU_TYPE)
dh $@@ -v --buildsystem=cmake --builddirectory=.obj-$(DEB_HOST_GNU_TYPE)

override_dh_auto_configure:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree and source it. It will set things like
# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
if [ -f "/opt/ros/noetic/setup.sh" ]; then . "/opt/ros/noetic/setup.sh"; fi && \
if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
dh_auto_configure -- \
-DCMAKE_INSTALL_PREFIX="/opt/ros/noetic" \
-DCMAKE_PREFIX_PATH="/opt/ros/noetic" \
-DCMAKE_INSTALL_PREFIX="@(InstallationPrefix)" \
-DCMAKE_PREFIX_PATH="@(InstallationPrefix)" \
$(BUILD_TESTING_ARG)

override_dh_auto_build:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree and source it. It will set things like
# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
if [ -f "/opt/ros/noetic/setup.sh" ]; then . "/opt/ros/noetic/setup.sh"; fi && \
if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
dh_auto_build

override_dh_auto_test:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree and source it. It will set things like
# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
echo -- Running tests. Even if one of them fails the build is not canceled.
if [ -f "/opt/ros/noetic/setup.sh" ]; then . "/opt/ros/noetic/setup.sh"; fi && \
if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
dh_auto_test || true

override_dh_shlibdeps:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree and source it. It will set things like
# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
if [ -f "/opt/ros/noetic/setup.sh" ]; then . "/opt/ros/noetic/setup.sh"; fi && \
dh_shlibdeps -l$(CURDIR)/debian/ros-noetic-depthai//opt/ros/noetic/lib/:$(CURDIR)/debian/ros-noetic-depthai//opt/ros/noetic/lib/${DEB_HOST_MULTIARCH}
if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
dh_shlibdeps -l$(CURDIR)/debian/@(Package)/@(InstallationPrefix)/lib/:$(CURDIR)/debian/@(Package)/@(InstallationPrefix)/lib/${DEB_HOST_MULTIARCH}

override_dh_auto_install:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree and source it. It will set things like
# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
if [ -f "/opt/ros/noetic/setup.sh" ]; then . "/opt/ros/noetic/setup.sh"; fi && \
if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi && \
dh_auto_install
1 change: 0 additions & 1 deletion debian/source/format

This file was deleted.

1 change: 1 addition & 0 deletions debian/source/format.em
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (@(format))
3 changes: 2 additions & 1 deletion debian/source/options → debian/source/options.em
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@[if format and format == 'quilt']@
# Automatically add upstream changes to the quilt overlay.
# http://manpages.ubuntu.com/manpages/trusty/man1/dpkg-source.1.html
# This supports reusing the orig.tar.gz for debian increments.
auto-commit

@[end if]
12 changes: 12 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ hunter_private_data(
LOCATION tiny_yolo_v4_blob
)

# YoloV8 resource
hunter_private_data(
URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/yolov8n_coco_640x352.blob"
SHA1 "6b88a80ffb4267e253a89cb2b3e4e186453431b0"
FILE "yolov8n_coco_640x352.blob"
LOCATION yolov8n_blob
)

# NeuralNetwork node, mobilenet example, 5 shaves
hunter_private_data(
URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.4_5shave.blob"
Expand Down Expand Up @@ -220,6 +228,7 @@ hunter_private_data(
LOCATION normalization_model
)


## message(STATUS "Location of test1.data: ${test1_data}")

# bootloader
Expand Down Expand Up @@ -380,8 +389,10 @@ dai_add_example(mjpeg_encoding VideoEncoder/mjpeg_encoding_example.cpp ON OFF)
# Yolo
dai_add_example(tiny_yolo_v4_device_side_decoding Yolo/tiny_yolo.cpp ON OFF)
dai_add_example(tiny_yolo_v3_device_side_decoding Yolo/tiny_yolo.cpp ON OFF)
dai_add_example(yolo_v8_nano_device_side_decoding Yolo/yolov8_nano.cpp ON OFF)
target_compile_definitions(tiny_yolo_v4_device_side_decoding PRIVATE BLOB_PATH="${tiny_yolo_v4_blob}")
target_compile_definitions(tiny_yolo_v3_device_side_decoding PRIVATE BLOB_PATH="${tiny_yolo_v3_blob}")
target_compile_definitions(yolo_v8_nano_device_side_decoding PRIVATE BLOB_PATH="${yolov8n_blob}")
dai_add_example(apriltag AprilTag/apriltag.cpp ON OFF)
dai_add_example(apriltag_rgb AprilTag/apriltag_rgb.cpp ON OFF)

Expand Down Expand Up @@ -421,3 +432,4 @@ target_compile_definitions(cast_diff PRIVATE BLOB_PATH="${diff_model}")
dai_add_example(spatial_tiny_yolo_tof_v3 SpatialDetection/spatial_tiny_yolo_tof.cpp OFF OFF)
dai_add_example(spatial_tiny_yolo_tof_v4 SpatialDetection/spatial_tiny_yolo_tof.cpp OFF OFF)
target_compile_definitions(spatial_tiny_yolo_tof_v3 PRIVATE BLOB_PATH="${tiny_yolo_v3_blob}")
target_compile_definitions(spatial_tiny_yolo_tof_v4 PRIVATE BLOB_PATH="${tiny_yolo_v4_blob}")
157 changes: 157 additions & 0 deletions examples/Yolo/yolov8_nano.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#include <chrono>
#include <iostream>

// Includes common necessary includes for development using depthai library
#include "depthai/depthai.hpp"

/*
The code is the same as for Tiny-yolo-V3 and V4, the only difference is the blob file and anchors that are not needed for V8.
The blob was compiled following this tutorial: https://github.com/TNTWEN/OpenVINO-YOLOV4
*/

static const std::vector<std::string> labelMap = {
"person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat",
"traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse",
"sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag",
"tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove",
"skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon",
"bowl", "banana", "apple", "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza",
"donut", "cake", "chair", "sofa", "pottedplant", "bed", "diningtable", "toilet", "tvmonitor",
"laptop", "mouse", "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink",
"refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush"};

static std::atomic<bool> syncNN{true};

int main(int argc, char** argv) {
using namespace std;
using namespace std::chrono;
std::string nnPath(BLOB_PATH);

// If path to blob specified, use that
if(argc > 1) {
nnPath = std::string(argv[1]);
}

// Print which blob we are using
printf("Using blob at path: %s\n", nnPath.c_str());

// Create pipeline
dai::Pipeline pipeline;

// Define sources and outputs
auto camRgb = pipeline.create<dai::node::ColorCamera>();
auto detectionNetwork = pipeline.create<dai::node::YoloDetectionNetwork>();
auto xoutRgb = pipeline.create<dai::node::XLinkOut>();
auto nnOut = pipeline.create<dai::node::XLinkOut>();

xoutRgb->setStreamName("rgb");
nnOut->setStreamName("detections");

// Properties
camRgb->setPreviewSize(640, 352);
camRgb->setResolution(dai::ColorCameraProperties::SensorResolution::THE_1080_P);
camRgb->setInterleaved(false);
camRgb->setColorOrder(dai::ColorCameraProperties::ColorOrder::BGR);
camRgb->setFps(40);

// Network specific settings
detectionNetwork->setConfidenceThreshold(0.5f);
detectionNetwork->setNumClasses(80);
detectionNetwork->setCoordinateSize(4);
detectionNetwork->setIouThreshold(0.5f);
detectionNetwork->setBlobPath(nnPath);
detectionNetwork->setNumInferenceThreads(2);
detectionNetwork->input.setBlocking(false);

// Linking
camRgb->preview.link(detectionNetwork->input);
if(syncNN) {
detectionNetwork->passthrough.link(xoutRgb->input);
} else {
camRgb->preview.link(xoutRgb->input);
}

detectionNetwork->out.link(nnOut->input);

// Connect to device and start pipeline
dai::Device device(pipeline);

// Output queues will be used to get the rgb frames and nn data from the outputs defined above
auto qRgb = device.getOutputQueue("rgb", 4, false);
auto qDet = device.getOutputQueue("detections", 4, false);

cv::Mat frame;
std::vector<dai::ImgDetection> detections;
auto startTime = steady_clock::now();
int counter = 0;
float fps = 0;
auto color2 = cv::Scalar(255, 255, 255);

// Add bounding boxes and text to the frame and show it to the user
auto displayFrame = [](std::string name, cv::Mat frame, std::vector<dai::ImgDetection>& detections) {
auto color = cv::Scalar(255, 0, 0);
// nn data, being the bounding box locations, are in <0..1> range - they need to be normalized with frame width/height
for(auto& detection : detections) {
int x1 = detection.xmin * frame.cols;
int y1 = detection.ymin * frame.rows;
int x2 = detection.xmax * frame.cols;
int y2 = detection.ymax * frame.rows;

uint32_t labelIndex = detection.label;
std::string labelStr = to_string(labelIndex);
if(labelIndex < labelMap.size()) {
labelStr = labelMap[labelIndex];
}
cv::putText(frame, labelStr, cv::Point(x1 + 10, y1 + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, 255);
std::stringstream confStr;
confStr << std::fixed << std::setprecision(2) << detection.confidence * 100;
cv::putText(frame, confStr.str(), cv::Point(x1 + 10, y1 + 40), cv::FONT_HERSHEY_TRIPLEX, 0.5, 255);
cv::rectangle(frame, cv::Rect(cv::Point(x1, y1), cv::Point(x2, y2)), color, cv::FONT_HERSHEY_SIMPLEX);
}
// Show the frame
cv::imshow(name, frame);
};

while(true) {
std::shared_ptr<dai::ImgFrame> inRgb;
std::shared_ptr<dai::ImgDetections> inDet;

if(syncNN) {
inRgb = qRgb->get<dai::ImgFrame>();
inDet = qDet->get<dai::ImgDetections>();
} else {
inRgb = qRgb->tryGet<dai::ImgFrame>();
inDet = qDet->tryGet<dai::ImgDetections>();
}

counter++;
auto currentTime = steady_clock::now();
auto elapsed = duration_cast<duration<float>>(currentTime - startTime);
if(elapsed > seconds(1)) {
fps = counter / elapsed.count();
counter = 0;
startTime = currentTime;
}

if(inRgb) {
frame = inRgb->getCvFrame();
std::stringstream fpsStr;
fpsStr << "NN fps: " << std::fixed << std::setprecision(2) << fps;
cv::putText(frame, fpsStr.str(), cv::Point(2, inRgb->getHeight() - 4), cv::FONT_HERSHEY_TRIPLEX, 0.4, color2);
}

if(inDet) {
detections = inDet->detections;
}

if(!frame.empty()) {
displayFrame("rgb", frame, detections);
}

int key = cv::waitKey(1);
if(key == 'q' || key == 'Q') {
return 0;
}
}
return 0;
}
Loading

0 comments on commit 1dfe73f

Please sign in to comment.