Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,19 +453,15 @@ if(DEPTHAI_ENABLE_PROTOBUF)
)
endif()

if(DEPTHAI_DYNAMIC_CALIBRATION_SUPPORT)
list(APPEND TARGET_CORE_SOURCES
src/pipeline/node/DynamicCalibrationNode.cpp
src/pipeline/datatype/DynamicCalibrationResults.cpp
src/pipeline/datatype/DynamicCalibrationControl.cpp
src/pipeline/node/AutoCalibration.cpp
src/pipeline/datatype/AutoCalibrationResult.cpp
src/pipeline/datatype/AutoCalibrationConfig.cpp
)
endif()

set(TARGET_OPENCV_SOURCES
src/opencv/ImgFrame.cpp
src/opencv/ImgDetectionsT.cpp
src/opencv/SegmentationMask.cpp
src/opencv/DetectionNetwork.cpp
src/opencv/NeuralNetwork.cpp
src/opencv/EventsManager.cpp
Comment thread
asahtik marked this conversation as resolved.
src/opencv/Camera.cpp
src/opencv/matrixOps.cpp
src/pipeline/node/host/Display.cpp
src/pipeline/node/host/HostCamera.cpp
src/pipeline/node/host/Record.cpp
Expand All @@ -475,6 +471,17 @@ set(TARGET_OPENCV_SOURCES
src/opencv/HolisticRecordReplay.cpp
)

if(DEPTHAI_DYNAMIC_CALIBRATION_SUPPORT AND DEPTHAI_MERGED_TARGET)
list(APPEND TARGET_CORE_SOURCES
src/pipeline/node/DynamicCalibrationNode.cpp
src/pipeline/datatype/DynamicCalibrationResults.cpp
src/pipeline/datatype/DynamicCalibrationControl.cpp
src/pipeline/node/AutoCalibration.cpp
src/pipeline/datatype/AutoCalibrationResult.cpp
src/pipeline/datatype/AutoCalibrationConfig.cpp
)
endif()

set(TARGET_PCL_SOURCES src/pcl/PointCloudData.cpp)

set(TARGET_BASALT_SOURCES src/basalt/BasaltVIO.cpp)
Expand Down Expand Up @@ -652,7 +659,7 @@ if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(${TARGET_CORE_NAME} PUBLIC MCAP_STATIC)
endif()

if(DEPTHAI_DYNAMIC_CALIBRATION_SUPPORT)
if(DEPTHAI_DYNAMIC_CALIBRATION_SUPPORT AND DEPTHAI_MERGED_TARGET)
# Link the dynamic calibration target
target_link_libraries(${TARGET_CORE_NAME} PRIVATE dynamic_calibration_imported)
target_compile_definitions(${TARGET_CORE_NAME} PUBLIC DEPTHAI_HAVE_DYNAMIC_CALIBRATION_SUPPORT)
Expand Down Expand Up @@ -988,7 +995,7 @@ if(DEPTHAI_ENABLE_LIBUSB AND NOT XLINK_LIBUSB_SYSTEM)
add_runtime_dependencies(${TARGET_CORE_NAME} usb-1.0)
endif()
# Add dynamic calibration dll in build time
if(DEPTHAI_DYNAMIC_CALIBRATION_SUPPORT)
if(DEPTHAI_DYNAMIC_CALIBRATION_SUPPORT AND DEPTHAI_MERGED_TARGET)
add_runtime_dependencies(${TARGET_CORE_NAME} dynamic_calibration_imported)
endif()

Expand All @@ -1009,12 +1016,21 @@ if(DEPTHAI_HAVE_OPENCV_SUPPORT AND NOT DEPTHAI_MERGED_TARGET)

# Link to OpenCV (publicly)
target_link_libraries(${TARGET_OPENCV_NAME} PUBLIC ${REQUIRED_OPENCV_LIBRARIES} ${THIRDPARTY_OPENCV_LIBRARIES})
target_link_libraries(${TARGET_OPENCV_NAME} PRIVATE spdlog::spdlog)

# Specify that we are building target opencv
target_compile_definitions(${TARGET_OPENCV_NAME} PUBLIC DEPTHAI_TARGET_OPENCV)
target_compile_definitions(${TARGET_OPENCV_NAME} PUBLIC DEPTHAI_HAVE_OPENCV_SUPPORT)
# Add public dependency to depthai::core library
target_link_libraries(${TARGET_OPENCV_NAME} PUBLIC ${TARGET_CORE_NAME})
target_include_directories(${TARGET_OPENCV_NAME}
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/depthai>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/depthai>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>"
"$<BUILD_INTERFACE:${DEPTHAI_SHARED_INCLUDE}>"
"$<BUILD_INTERFACE:${DEPTHAI_BOOTLOADER_SHARED_INCLUDE}>"
)

# Add to clangformat target
if(COMMAND target_clangformat_setup)
Expand Down
5 changes: 5 additions & 0 deletions cmake/depthaiOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ option(DEPTHAI_BUILD_ZOO_HELPER "Build the Zoo helper" OFF)
option(DEPTHAI_NEW_FIND_PYTHON "Use new FindPython module" ON)
option(DEPTHAI_INSTALL "Enable install target for depthai-core targets" ON)

if(DEPTHAI_BUILD_EXAMPLES AND NOT DEPTHAI_OPENCV_SUPPORT)
message(WARNING "DEPTHAI_BUILD_EXAMPLES requires DEPTHAI_OPENCV_SUPPORT to be ON. Turning DEPTHAI_BUILD_EXAMPLES OFF.")
set(DEPTHAI_BUILD_EXAMPLES OFF CACHE BOOL "Build examples - Requires OpenCV library to be installed" FORCE)
endif()

# ---------- Dependency Management -------------
option(DEPTHAI_BOOTSTRAP_VCPKG "Automatically bootstrap VCPKG" ON)
option(DEPTHAI_VCPKG_INTERNAL_ONLY "Use VCPKG internally, but not for interface libraries" ON)
Expand Down
4 changes: 3 additions & 1 deletion examples/cpp/AutoCalibration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
project(auto_calibration_examples)
cmake_minimum_required(VERSION 3.10)

dai_add_example(auto_calibration_example auto_calibration_example.cpp ON OFF)
if(DEPTHAI_MERGED_TARGET)
dai_add_example(auto_calibration_example auto_calibration_example.cpp ON OFF)
endif()
10 changes: 6 additions & 4 deletions examples/cpp/DynamicCalibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ cmake_minimum_required(VERSION 3.10)
## function: dai_add_example(example_name example_src enable_test use_pcl)
## function: dai_set_example_test_labels(example_name ...)

dai_add_example(calibration_quality_dynamic calibration_quality_dynamic.cpp ON OFF)
dai_add_example(calibration_dynamic calibration_dynamic.cpp ON OFF)
dai_add_example(calibration_dynamic_3_sensors calibration_dynamic_3_sensors.cpp ON OFF)
dai_add_example(calibration_integration calibration_integration.cpp ON OFF)
if(DEPTHAI_MERGED_TARGET)
dai_add_example(calibration_quality_dynamic calibration_quality_dynamic.cpp ON OFF)
dai_add_example(calibration_dynamic calibration_dynamic.cpp ON OFF)
dai_add_example(calibration_dynamic_3_sensors calibration_dynamic_3_sensors.cpp ON OFF)
dai_add_example(calibration_integration calibration_integration.cpp ON OFF)
endif()
16 changes: 9 additions & 7 deletions examples/cpp/RecordReplay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ dai_add_example(replay_video replay_video.cpp OFF OFF)

dai_add_example(replay_imu replay_imu.cpp OFF OFF)

if(DEPTHAI_FETCH_ARTIFACTS)
dai_add_example(holistic_replay holistic_replay.cpp ON OFF)
target_compile_definitions(holistic_replay PRIVATE RECORDING_PATH="${recording_path}")
endif()

dai_add_example(record_video record_video.cpp OFF OFF)

dai_add_example(holistic_record holistic_record.cpp OFF OFF)

dai_add_example(record_encoded record_encoded.cpp OFF OFF)

dai_add_example(record_raw record_raw.cpp OFF OFF)

dai_add_example(record_imu record_imu.cpp OFF OFF)

if(DEPTHAI_MERGED_TARGET)
dai_add_example(holistic_record holistic_record.cpp OFF OFF)

if(DEPTHAI_FETCH_ARTIFACTS)
dai_add_example(holistic_replay holistic_replay.cpp ON OFF)
target_compile_definitions(holistic_replay PRIVATE RECORDING_PATH="${recording_path}")
endif()
endif()
2 changes: 1 addition & 1 deletion examples/cpp/RecordReplay/holistic_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "depthai/utility/RecordReplay.hpp"
#include "utility.hpp"
#ifndef DEPTHAI_MERGED_TARGET
#error This example needs OpenCV support, which is not available on your system
#error This example needs DEPTHAI_MERGED_TARGET to be enabled
#endif

// Signal handling for clean shutdown
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/RecordReplay/holistic_replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "depthai/depthai.hpp"

#ifndef DEPTHAI_MERGED_TARGET
#error This example needs OpenCV support, which is not available on your system
#error This example needs DEPTHAI_MERGED_TARGET to be enabled
#endif

int main(int argc, char** argv) {
Expand Down
4 changes: 2 additions & 2 deletions include/depthai/pipeline/MessageQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class MessageQueue : public std::enable_shared_from_this<MessageQueue> {
name(c.name),
callbacks(c.callbacks),
uniqueCallbackId(c.uniqueCallbackId),
pipelineEventDispatcher(c.pipelineEventDispatcher){};
pipelineEventDispatcher(c.pipelineEventDispatcher) {};
MessageQueue(MessageQueue&& m) noexcept
: enable_shared_from_this(m),
queue(std::move(m.queue)),
name(std::move(m.name)),
callbacks(std::move(m.callbacks)),
uniqueCallbackId(m.uniqueCallbackId),
pipelineEventDispatcher(m.pipelineEventDispatcher){};
pipelineEventDispatcher(m.pipelineEventDispatcher) {};

MessageQueue& operator=(const MessageQueue& c) {
queue = c.queue;
Expand Down
4 changes: 3 additions & 1 deletion include/depthai/pipeline/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ class Node : public std::enable_shared_from_this<Node> {
static constexpr auto DEFAULT_NAME = "";
#define DEFAULT_TYPES \
{ \
{ DatatypeEnum::Buffer, true } \
{ \
DatatypeEnum::Buffer, true \
} \
}
static constexpr auto DEFAULT_BLOCKING = true;
static constexpr auto DEFAULT_QUEUE_SIZE = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AutoCalibrationResult : public Buffer {
* @param calibration The actual calibration handler containing the new parameters.
*/
AutoCalibrationResult(double dataConfidence, double calibrationConfidence, bool passed, CalibrationHandler calibration)
: dataConfidence(dataConfidence), calibrationConfidence(calibrationConfidence), passed(passed), calibration(calibration){};
: dataConfidence(dataConfidence), calibrationConfidence(calibrationConfidence), passed(passed), calibration(calibration) {};

virtual ~AutoCalibrationResult();

Expand Down
2 changes: 1 addition & 1 deletion include/depthai/pipeline/datatype/GateControl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GateControl : public Buffer {

GateControl() = default;

GateControl(bool open, int numMessages, int fps) : open(open), numMessages(numMessages), fps(fps){};
GateControl(bool open, int numMessages, int fps) : open(open), numMessages(numMessages), fps(fps) {};

~GateControl() override;

Expand Down
22 changes: 22 additions & 0 deletions include/depthai/pipeline/datatype/ImgDetectionsT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,28 @@ class ImgDetectionsT : public Buffer {
*/
std::optional<cv::Mat> getCvSegmentationMaskByClass(uint8_t semanticClass, cv::MatAllocator* allocator = nullptr);

#else

template <typename... T>
struct dependent_false {
static constexpr bool value = false;
};
template <typename... T>
void setCvSegmentationMask(T...) {
static_assert(dependent_false<T...>::value, "Library not configured with OpenCV support");
}
template <typename... T>
void getCvSegmentationMask(T...) {
static_assert(dependent_false<T...>::value, "Library not configured with OpenCV support");
}
template <typename... T>
void getCvSegmentationMaskByIndex(T...) {
static_assert(dependent_false<T...>::value, "Library not configured with OpenCV support");
}
template <typename... T>
void getCvSegmentationMaskByClass(T...) {
static_assert(dependent_false<T...>::value, "Library not configured with OpenCV support");
}
#endif
};

Expand Down
4 changes: 0 additions & 4 deletions include/depthai/pipeline/node/ToF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,21 @@ class ToF : public DeviceNodeGroup {
*/
Input& tofBaseInputConfig{tofBase->inputConfig};

#ifdef DEPTHAI_HAVE_OPENCV_SUPPORT
/**
* Input config for image filters
*/
Input* imageFiltersInputConfig = nullptr;
#endif
#endif

/**
* ToF base node
*/
ToFBase& tofBaseNode{*tofBase};

#ifdef DEPTHAI_HAVE_OPENCV_SUPPORT
/**
* Image filters node
*/
ImageFilters* imageFiltersNode = nullptr;
#endif
};

} // namespace node
Expand Down
3 changes: 3 additions & 0 deletions include/depthai/utility/EventsManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <atomic>
#include <condition_variable>
#include <deque>
#include <future>
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -38,6 +39,8 @@ class FileData {
bool toFile(const std::filesystem::path& inputPath);

private:
static std::string calculateSHA256Checksum(const std::string& data);

std::string mimeType;
std::string fileTag;
std::string data;
Expand Down
4 changes: 2 additions & 2 deletions include/depthai/utility/LockingQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class LockingQueue {
this->maxSize = maxSize;
this->blocking = blocking;
}
LockingQueue(const LockingQueue& obj) : maxSize(obj.maxSize), blocking(obj.blocking), queue(obj.queue), destructed(obj.destructed){};
LockingQueue(LockingQueue&& obj) noexcept : maxSize(obj.maxSize), blocking(obj.blocking), queue(std::move(obj.queue)), destructed(obj.destructed){};
LockingQueue(const LockingQueue& obj) : maxSize(obj.maxSize), blocking(obj.blocking), queue(obj.queue), destructed(obj.destructed) {};
LockingQueue(LockingQueue&& obj) noexcept : maxSize(obj.maxSize), blocking(obj.blocking), queue(std::move(obj.queue)), destructed(obj.destructed) {};
LockingQueue& operator=(const LockingQueue& obj) {
maxSize = obj.maxSize;
blocking = obj.blocking;
Expand Down
2 changes: 1 addition & 1 deletion include/depthai/utility/MemoryWrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// memfd_create wrapper for glibc < 2.27
#if defined(__unix__) && !defined(__APPLE__)
#if(__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 27)
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 27)

int memfd_create(const char* name, unsigned int flags);

Expand Down
4 changes: 2 additions & 2 deletions include/depthai/utility/NlohmannJsonCompat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <nlohmann/json.hpp>

// Check version of nlohmann json
#if(defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR))
#if((NLOHMANN_JSON_VERSION_MAJOR < 3) || ((NLOHMANN_JSON_VERSION_MAJOR == 3) && (NLOHMANN_JSON_VERSION_MINOR < 6)))
#if (defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR))
#if ((NLOHMANN_JSON_VERSION_MAJOR < 3) || ((NLOHMANN_JSON_VERSION_MAJOR == 3) && (NLOHMANN_JSON_VERSION_MINOR < 6)))
static_assert(0, "DepthAI requires nlohmann library version 3.6.0 or higher");
#else
// Set up compat macros for nlohmann json (independent of version)
Expand Down
4 changes: 2 additions & 2 deletions src/device/DeviceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ class DeviceBase::Impl {
* RPC call with custom timeout. Set timeout to 0 to enable endless wait.
*/
template <typename... Args>
auto rpcCall(std::chrono::milliseconds timeout, std::string name, Args&&... args) -> decltype(rpcClient->call(std::string(name),
std::forward<Args>(args)...)) {
auto rpcCall(std::chrono::milliseconds timeout, std::string name, Args&&... args)
-> decltype(rpcClient->call(std::string(name), std::forward<Args>(args)...)) {
ScopedRpcTimeout guard(timeout);
return rpcClient->call(name, std::forward<Args>(args)...);
}
Expand Down
45 changes: 45 additions & 0 deletions src/opencv/Camera.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "depthai/pipeline/node/Camera.hpp"

#include <stdexcept>

#include "depthai/pipeline/Pipeline.hpp"
#include "utility/RecordReplayImpl.hpp"

namespace dai::node {

std::shared_ptr<Camera> Camera::build(CameraBoardSocket boardSocket, ReplayVideo& replay) {
auto cam = build(boardSocket);
cam->setMockIsp(replay);
return cam;
}

std::shared_ptr<Camera> Camera::build(ReplayVideo& replay) {
auto cam = build(CameraBoardSocket::AUTO);
cam->setMockIsp(replay);
return cam;
}

Camera& Camera::setMockIsp(ReplayVideo& replay) {
if(replay.getReplayVideoFile().empty()) {
throw std::runtime_error("ReplayVideo video path not set");
}

auto [width, height] = replay.getSize();
double fps = replay.getFps();
if(width <= 0 || height <= 0) {
const auto& [vidWidth, vidHeight, vidFps] = utility::getVideoSize(replay.getReplayVideoFile().string());
width = vidWidth;
height = vidHeight;
fps = vidFps;
}
properties.mockIspWidth = width;
properties.mockIspHeight = height;
properties.mockIspFps = fps;

auto device = getParentPipeline().getDefaultDevice();
replay.setOutFrameType(device && device->getPlatform() == Platform::RVC2 ? ImgFrame::Type::YUV420p : ImgFrame::Type::NV12);
replay.out.link(mockIsp);
return *this;
}

} // namespace dai::node
15 changes: 15 additions & 0 deletions src/opencv/DetectionNetwork.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "depthai/pipeline/node/DetectionNetwork.hpp"

#include "utility/ErrorMacros.hpp"

namespace dai::node {

std::shared_ptr<DetectionNetwork> DetectionNetwork::build(const std::shared_ptr<ReplayVideo>& input, const Model& model, std::optional<float> fps) {
neuralNetwork->build(input, model, fps);
auto nnArchive = neuralNetwork->getNNArchive();
DAI_CHECK(nnArchive.has_value(), "NeuralNetwork NNArchive is not set after build.");
detectionParser->setNNArchive(*nnArchive);
return std::static_pointer_cast<DetectionNetwork>(shared_from_this());
}

} // namespace dai::node
Loading