Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
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 "e88cdb4afa8be3cbbf8c739601f1aa1b2fd5395b")
set(DEPTHAI_DEVICE_SIDE_COMMIT "3f22c4cf67ca3ec8dcf5e01fffdf9137f49aefbf")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
3 changes: 1 addition & 2 deletions examples/src/rgb_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ int main() {
camRgb->preview.link(xoutRgb->input);

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

cout << "Connected cameras: ";
for(const auto& cam : device.getConnectedCameras()) {
cout << static_cast<int>(cam) << " ";
cout << cam << " ";
}
cout << endl;
Expand Down
76 changes: 55 additions & 21 deletions include/depthai/device/Device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "depthai/common/CameraBoardSocket.hpp"
#include "depthai/common/UsbSpeed.hpp"
#include "depthai/device/CalibrationHandler.hpp"
#include "depthai/pipeline/Pipeline.hpp"
#include "depthai/openvino/OpenVINO.hpp"
#include "depthai/utility/Pimpl.hpp"
#include "depthai/xlink/XLinkConnection.hpp"
#include "depthai/xlink/XLinkStream.hpp"
Expand All @@ -22,12 +22,15 @@
#include "depthai-shared/common/ChipTemperature.hpp"
#include "depthai-shared/common/CpuUsage.hpp"
#include "depthai-shared/common/MemoryInfo.hpp"
#include "depthai-shared/device/PrebootConfig.hpp"
#include "depthai-shared/log/LogLevel.hpp"
#include "depthai-shared/log/LogMessage.hpp"
#include "tl/optional.hpp"

namespace dai {

// Device (RAII), connects to device and maintains watchdog, timesync, ...
// Forward declare Pipeline
class Pipeline;

/**
* Represents the DepthAI device with the methods to interact with it.
Expand All @@ -42,6 +45,18 @@ class Device {
static constexpr std::size_t EVENT_QUEUE_MAXIMUM_SIZE{2048};
/// Default rate at which system information is logged
static constexpr float DEFAULT_SYSTEM_INFORMATION_LOGGING_RATE_HZ{1.0f};
/// Default UsbSpeed for device connection
static constexpr UsbSpeed DEFAULT_USB_SPEED{UsbSpeed::SUPER};

// Structures

/**
* Device specific configuration
*/
struct Config {
OpenVINO::Version version;
PrebootConfig preboot;
};

// static API

Expand Down Expand Up @@ -86,7 +101,7 @@ class Device {
* @param version Version of OpenVINO which firmware will support
* @returns Firmware binary
*/
static std::vector<std::uint8_t> getEmbeddedDeviceBinary(bool usb2Mode, OpenVINO::Version version = Pipeline::DEFAULT_OPENVINO_VERSION);
static std::vector<std::uint8_t> getEmbeddedDeviceBinary(bool usb2Mode, OpenVINO::Version version = OpenVINO::DEFAULT_VERSION);

/**
* Connects to any available device with a DEFAULT_SEARCH_TIME timeout.
Expand All @@ -104,15 +119,16 @@ class Device {
/**
* Connects to any available device with a DEFAULT_SEARCH_TIME timeout.
* @param pipeline Pipeline to be executed on the device
* @param pathToCmd Path to custom device firmware
* @param maxUsbSpeed Maximum allowed USB speed
*/
Device(const Pipeline& pipeline, const char* pathToCmd);
Device(const Pipeline& pipeline, UsbSpeed maxUsbSpeed);

/**
* Connects to any available device with a DEFAULT_SEARCH_TIME timeout.
* @param pipeline Pipeline to be executed on the device
* @param pathToCmd Path to custom device firmware
*/
Device(const Pipeline& pipeline, const char* pathToCmd);
Device(const Pipeline& pipeline, const std::string& pathToCmd);

/**
Expand All @@ -127,23 +143,24 @@ class Device {
* Connects to device specified by devInfo.
* @param pipeline Pipeline to be executed on the device
* @param devInfo DeviceInfo which specifies which device to connect to
* @param pathToCmd Path to custom device firmware
* @param maxUsbSpeed Maximum allowed USB speed
*/
Device(const Pipeline& pipeline, const DeviceInfo& devInfo, const char* pathToCmd);
Device(const Pipeline& pipeline, const DeviceInfo& devInfo, UsbSpeed maxUsbSpeed);

/**
* Connects to device specified by devInfo.
* @param pipeline Pipeline to be executed on the device
* @param devInfo DeviceInfo which specifies which device to connect to
* @param usb2Mode Path to custom device firmware
* @param pathToCmd Path to custom device firmware
*/
Device(const Pipeline& pipeline, const DeviceInfo& devInfo, const char* pathToCmd);
Device(const Pipeline& pipeline, const DeviceInfo& devInfo, const std::string& pathToCmd);

/**
* Connects to any available device with a DEFAULT_SEARCH_TIME timeout.
* @param version OpenVINO version which the device will be booted with. Default is Pipeline::DEFAULT_OPENVINO_VERSION
* @param version OpenVINO version which the device will be booted with. Default is OpenVINO::DEFAULT_VERSION
*/
explicit Device(OpenVINO::Version version = Pipeline::DEFAULT_OPENVINO_VERSION);
explicit Device(OpenVINO::Version version = OpenVINO::DEFAULT_VERSION);

/**
* Connects to any available device with a DEFAULT_SEARCH_TIME timeout.
Expand All @@ -155,15 +172,16 @@ class Device {
/**
* Connects to any available device with a DEFAULT_SEARCH_TIME timeout.
* @param version OpenVINO version which the device will be booted with
* @param pathToCmd Path to custom device firmware
* @param maxUsbSpeed Maximum allowed USB speed
*/
Device(OpenVINO::Version version, const char* pathToCmd);
Device(OpenVINO::Version version, UsbSpeed maxUsbSpeed);

/**
* Connects to any available device with a DEFAULT_SEARCH_TIME timeout.
* @param version OpenVINO version which the device will be booted with
* @param pathToCmd Path to custom device firmware
*/
Device(OpenVINO::Version version, const char* pathToCmd);
Device(OpenVINO::Version version, const std::string& pathToCmd);

/**
Expand All @@ -178,18 +196,32 @@ class Device {
* Connects to device specified by devInfo.
* @param version OpenVINO version which the device will be booted with
* @param devInfo DeviceInfo which specifies which device to connect to
* @param pathToCmd Path to custom device firmware
* @param maxUsbSpeed Maximum USB speed
*/
Device(OpenVINO::Version version, const DeviceInfo& devInfo, const char* pathToCmd);
Device(OpenVINO::Version version, const DeviceInfo& devInfo, UsbSpeed maxUsbSpeed);

/**
* Connects to device specified by devInfo.
* @param version OpenVINO version which the device will be booted with
* @param devInfo DeviceInfo which specifies which device to connect to
* @param usb2Mode Path to custom device firmware
* @param pathToCmd Path to custom device firmware
*/
Device(OpenVINO::Version version, const DeviceInfo& devInfo, const char* pathToCmd);
Device(OpenVINO::Version version, const DeviceInfo& devInfo, const std::string& pathToCmd);

/**
* Connects to any available device with custom config.
* @param config Device custom configuration to boot with
*/
explicit Device(Config config);

/**
* Connects to device 'devInfo' with custom config.
* @param devInfo DeviceInfo which specifies which device to connect to
* @param config Device custom configuration to boot with
*/
Device(const DeviceInfo& devInfo, Config config);

/**
* Device destructor. Closes the connection and data queues.
*/
Expand Down Expand Up @@ -499,10 +531,12 @@ class Device {
bool isClosed() const;

private:
// private static
void init(OpenVINO::Version version, bool embeddedMvcmd, bool usb2Mode, const std::string& pathToMvcmd);
void init(const Pipeline& pipeline, bool embeddedMvcmd, bool usb2Mode, const std::string& pathToMvcmd);
void init2(bool embeddedMvcmd, bool usb2Mode, const std::string& pathToMvcmd, tl::optional<const Pipeline&> pipeline);
// private
void init(OpenVINO::Version version, bool usb2Mode, const std::string& pathToMvcmd);
void init(const Pipeline& pipeline, bool usb2Mode, const std::string& pathToMvcmd);
void init(OpenVINO::Version version, UsbSpeed maxUsbSpeed, const std::string& pathToMvcmd);
void init(const Pipeline& pipeline, UsbSpeed maxUsbSpeed, const std::string& pathToMvcmd);
void init2(Config cfg, const std::string& pathToMvcmd, tl::optional<const Pipeline&> pipeline);
void checkClosed() const;

std::shared_ptr<XLinkConnection> connection;
Expand Down Expand Up @@ -544,8 +578,8 @@ class Device {
class Impl;
Pimpl<Impl> pimpl;

// OpenVINO version device was booted with
OpenVINO::Version openvinoVersion;
// Device config
Config config;
};

} // namespace dai
3 changes: 3 additions & 0 deletions include/depthai/openvino/OpenVINO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class OpenVINO {
/// OpenVINO Version supported version information
enum Version { VERSION_2020_3, VERSION_2020_4, VERSION_2021_1, VERSION_2021_2, VERSION_2021_3, VERSION_2021_4 };

/// Main OpenVINO version
constexpr static const Version DEFAULT_VERSION = VERSION_2021_4;

/**
* @returns Supported versions
*/
Expand Down
34 changes: 24 additions & 10 deletions include/depthai/pipeline/Pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
#include "AssetManager.hpp"
#include "Node.hpp"
#include "depthai/device/CalibrationHandler.hpp"
#include "depthai/device/Device.hpp"
#include "depthai/openvino/OpenVINO.hpp"

// shared
#include "depthai-shared/device/PrebootConfig.hpp"
#include "depthai-shared/pipeline/PipelineSchema.hpp"
#include "depthai-shared/properties/GlobalProperties.hpp"

Expand All @@ -34,7 +36,9 @@ class PipelineImpl {
// Functions
Node::Id getNextUniqueId();
PipelineSchema getPipelineSchema() const;
OpenVINO::Version getPipelineOpenVINOVersion() const;
tl::optional<OpenVINO::Version> getPipelineOpenVINOVersion() const;
bool isOpenVINOVersionCompatible(OpenVINO::Version version) const;
Device::Config getDeviceConfig() const;
void setCameraTuningBlobPath(const std::string& path);

// Access to nodes
Expand All @@ -43,7 +47,7 @@ class PipelineImpl {
std::shared_ptr<const Node> getNode(Node::Id id) const;
std::shared_ptr<Node> getNode(Node::Id id);

void serialize(PipelineSchema& schema, Assets& assets, std::vector<std::uint8_t>& assetStorage, OpenVINO::Version& version) const;
void serialize(PipelineSchema& schema, Assets& assets, std::vector<std::uint8_t>& assetStorage) const;
void remove(std::shared_ptr<Node> node);

std::vector<Node::Connection> getConnections() const;
Expand All @@ -56,8 +60,6 @@ class PipelineImpl {
Node::Id latestId = 0;
// Pipeline asset manager
AssetManager assetManager;
// Default version
constexpr static auto DEFAULT_OPENVINO_VERSION = OpenVINO::Version::VERSION_2021_4;
// Optionally forced version
tl::optional<OpenVINO::Version> forceRequiredOpenVINOVersion;
// Global pipeline properties
Expand Down Expand Up @@ -106,9 +108,6 @@ class Pipeline {
/// Clone the pipeline (Creates a copy)
Pipeline clone() const;

/// Default Pipeline openvino version
constexpr static auto DEFAULT_OPENVINO_VERSION = PipelineImpl::DEFAULT_OPENVINO_VERSION;

/**
* @returns Global properties of current pipeline
*/
Expand All @@ -120,8 +119,8 @@ class Pipeline {
PipelineSchema getPipelineSchema();

// void loadAssets(AssetManager& assetManager);
void serialize(PipelineSchema& schema, Assets& assets, std::vector<std::uint8_t>& assetStorage, OpenVINO::Version& version) const {
impl()->serialize(schema, assets, assetStorage, version);
void serialize(PipelineSchema& schema, Assets& assets, std::vector<std::uint8_t>& assetStorage) const {
impl()->serialize(schema, assets, assetStorage);
}

/**
Expand Down Expand Up @@ -231,15 +230,30 @@ class Pipeline {
return impl()->getCalibrationData();
}

/// Get required OpenVINO version to run this pipeline
/// Get possible OpenVINO version to run this pipeline
OpenVINO::Version getOpenVINOVersion() const {
return impl()->getPipelineOpenVINOVersion().value_or(OpenVINO::DEFAULT_VERSION);
}

/// Get required OpenVINO version to run this pipeline. Can be none
tl::optional<OpenVINO::Version> getRequiredOpenVINOVersion() const {
return impl()->getPipelineOpenVINOVersion();
}

/// Set a camera IQ (Image Quality) tuning blob, used for all cameras
void setCameraTuningBlobPath(const std::string& path) {
impl()->setCameraTuningBlobPath(path);
}

/// Checks whether a given OpenVINO version is compatible with the pipeline
bool isOpenVINOVersionCompatible(OpenVINO::Version version) const {
return impl()->isOpenVINOVersionCompatible(version);
}

/// Get device configuration needed for this pipeline
Device::Config getDeviceConfig() const {
return impl()->getDeviceConfig();
}
};

} // namespace dai
5 changes: 3 additions & 2 deletions shared/depthai-shared.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(DEPTHAI_SHARED_3RDPARTY_HEADERS_PATH "depthai-shared/3rdparty")

set(DEPTHAI_SHARED_SOURCES
${DEPTHAI_SHARED_FOLDER}/src/datatype/DatatypeEnum.cpp
${DEPTHAI_SHARED_FOLDER}/src/utility/Checksum.cpp
)

set(DEPTHAI_SHARED_PUBLIC_INCLUDE
Expand All @@ -21,7 +22,7 @@ set(DEPTHAI_SHARED_INCLUDE
# Try retriving depthai-shared commit hash (if cloned and not sources only)
find_package(Git)
if(GIT_FOUND AND NOT DEPTHAI_DOWNLOADED_SOURCES)

# Check that submodule is initialized and updated
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule status ${DEPTHAI_SHARED_FOLDER}
Expand All @@ -32,7 +33,7 @@ if(GIT_FOUND AND NOT DEPTHAI_DOWNLOADED_SOURCES)
string(SUBSTRING ${statusCommit} 0 1 status)
if(${status} STREQUAL "-")
message(FATAL_ERROR "Submodule 'depthai-shared' not initialized/updated. Run 'git submodule update --init --recursive' first")
endif()
endif()

# Get depthai-shared current commit
execute_process(
Expand Down
2 changes: 1 addition & 1 deletion src/device/CallbackHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CallbackHandler::CallbackHandler(std::shared_ptr<XLinkConnection> conn,
t = std::thread([this, streamName]() {
try {
// open stream with 1B write size (no writing will happen here)
XLinkStream stream(*connection, streamName, XLINK_USB_BUFFER_MAX_SIZE);
XLinkStream stream(*connection, streamName, device::XLINK_USB_BUFFER_MAX_SIZE);

while(running) {
// read packet
Expand Down
2 changes: 1 addition & 1 deletion src/device/DataQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ bool DataOutputQueue::removeCallback(int callbackId) {
DataInputQueue::DataInputQueue(const std::shared_ptr<XLinkConnection>& conn, const std::string& streamName, unsigned int maxSize, bool blocking)
: queue(maxSize, blocking), name(streamName) {
// open stream with default XLINK_USB_BUFFER_MAX_SIZE write size
XLinkStream stream(*conn, name, dai::XLINK_USB_BUFFER_MAX_SIZE);
XLinkStream stream(*conn, name, device::XLINK_USB_BUFFER_MAX_SIZE);

writingThread = std::thread([this, stream = std::move(stream)]() mutable {
std::uint64_t numPacketsSent = 0;
Expand Down
Loading