Skip to content

Commit

Permalink
Merge 'origin/develop' into image_manip_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-luxonis committed Jun 17, 2022
2 parents 8ecc668 + d216ea2 commit 75d9906
Show file tree
Hide file tree
Showing 51 changed files with 1,148 additions and 308 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,21 @@ jobs:
cmake -S tests/integration/ -B tests/integration/build_add_subdirectory -D TEST_FIND_PACKAGE=OFF ${{ env.CMAKE_ARGS }}
cmake --build tests/integration/build_add_subdirectory --config ${{ matrix.build-type }} --parallel 4
cd tests/integration/build_add_subdirectory
ctest -C ${{ matrix.build-type }}
ctest -C ${{ matrix.build-type }} --output-on-failure
- name: Build and test find_package (installed)
run: |
cmake -S tests/integration/ -B tests/integration/build_find_package -D TEST_FIND_PACKAGE=ON -D depthai_DIR=$GITHUB_WORKSPACE/depthai_install/lib/cmake/depthai ${{ env.CMAKE_ARGS }}
cmake --build tests/integration/build_find_package --config ${{ matrix.build-type }} --parallel 4
cd tests/integration/build_find_package
ctest -C ${{ matrix.build-type }}
ctest -C ${{ matrix.build-type }} --output-on-failure
- name: Build and test find_package (build directory)
run: |
cmake -S tests/integration/ -B tests/integration/build_find_package_2 -D TEST_FIND_PACKAGE=ON -D depthai_DIR=$GITHUB_WORKSPACE/build ${{ env.CMAKE_ARGS }}
cmake --build tests/integration/build_find_package_2 --config ${{ matrix.build-type }} --parallel 4
cd tests/integration/build_find_package_2
ctest -C ${{ matrix.build-type }}
ctest -C ${{ matrix.build-type }} --output-on-failure
release:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
arch: 'x64'
flavor: 'tsan'
fail-fast: false
runs-on: ['self-hosted', '${{ matrix.os }}', '${{ matrix.arch }}']
runs-on: ['self-hosted', 'hil-test', '${{ matrix.os }}', '${{ matrix.arch }}']

steps:
- name: Cache .hunter folder
uses: actions/cache@v2
with:
path: $HOME/.hun_${{ matrix.flavor }}
path: $HOME/.hun2_${{ matrix.flavor }}
key: hunter-${{ matrix.os }}-${{ matrix.cmake }}
- uses: actions/checkout@v2
with:
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Configure, Build and Test
if: matrix.os != 'linux'
run: |
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D HUNTER_ROOT=$HOME/.hun_${{ matrix.flavor }} -D DEPTHAI_BUILD_EXAMPLES=ON -D DEPTHAI_BUILD_TESTS=ON -D DEPTHAI_TEST_EXAMPLES=ON
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D HUNTER_ROOT=$HOME/.hun2_${{ matrix.flavor }} -D DEPTHAI_BUILD_EXAMPLES=ON -D DEPTHAI_BUILD_TESTS=ON -D DEPTHAI_TEST_EXAMPLES=ON
cmake --build build --parallel 8 --config Release
cd build
ctest -C Release --output-on-failure -L usb
Expand All @@ -64,7 +64,7 @@ jobs:
run: |
export DISPLAY=:99
xdpyinfo -display $DISPLAY >/dev/null 2>&1 || (Xvfb $DISPLAY &)
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D HUNTER_ROOT=$HOME/.hun_${{ matrix.flavor }} -D DEPTHAI_BUILD_EXAMPLES=ON -D DEPTHAI_BUILD_TESTS=ON -D DEPTHAI_TEST_EXAMPLES=ON
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -D HUNTER_ROOT=$HOME/.hun2_${{ matrix.flavor }} -D DEPTHAI_BUILD_EXAMPLES=ON -D DEPTHAI_BUILD_TESTS=ON -D DEPTHAI_TEST_EXAMPLES=ON
cmake --build build --parallel 8 --config Release
cd build
ctest -C Release --output-on-failure -L usb
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if(WIN32)
endif()

# Create depthai project
project(depthai VERSION "2.15.4" LANGUAGES CXX C)
project(depthai VERSION "2.16.0" LANGUAGES CXX C)
get_directory_property(has_parent PARENT_DIRECTORY)
if(has_parent)
set(DEPTHAI_VERSION ${PROJECT_VERSION} PARENT_SCOPE)
Expand Down Expand Up @@ -81,7 +81,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/sanitizers")

# Additional options
option(DEPTHAI_CLANG_FORMAT "Enable clang-format target" ON )
option(DEPTHAI_CLANG_FORMAT "Enable clang-format target" ON)
option(DEPTHAI_CLANG_TIDY "Enable clang-tidy checks during compilation" OFF)
option(DEPTHAI_SANITIZE "Enable Address and Undefined sanitizers for library, examples and tests" OFF)

Expand Down Expand Up @@ -207,6 +207,7 @@ add_library(${TARGET_CORE_NAME}
src/pipeline/node/EdgeDetector.cpp
src/pipeline/node/SPIIn.cpp
src/pipeline/node/FeatureTracker.cpp
src/pipeline/node/DetectionParser.cpp
src/pipeline/datatype/Buffer.cpp
src/pipeline/datatype/ImgFrame.cpp
src/pipeline/datatype/ImageManipConfig.cpp
Expand Down Expand Up @@ -409,9 +410,11 @@ endif()
target_link_libraries(${TARGET_CORE_NAME}
PUBLIC
nlohmann_json::nlohmann_json
XLink
libnop
INTERFACE
XLinkPublic
PRIVATE
XLink
Threads::Threads
BZip2::bz2
FP16::fp16
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ DepthAI library doesn't yet provide API stability guarantees. While we take care

## Dependencies
- CMake >= 3.10
- libusb1 development package (MacOS & Linux only)
- C/C++14 compiler
- [optional] OpenCV 4 (required if building examples)

MacOS: `brew install libusb`, optionally with `brew install opencv`
MacOS: Optional `brew install opencv`

Linux: `sudo apt install libusb-1.0-0-dev`, optionally with `sudo apt install libopencv-dev`
Linux: Optional `sudo apt install libopencv-dev`

## Building

Expand Down Expand Up @@ -123,9 +122,6 @@ In your non-CMake project (new Visual Studio project, ...)
- `build/install/include` (library headers)
- `build/install/include/depthai-shared/3rdparty` (shared 3rdparty headers)
- `build/install/lib/cmake/depthai/dependencies/include` (dependency headers)
3. Add the following defines
- `XLINK_USE_MX_ID_NAME=ON`
- `__PC__=ON`

> ℹ️ Threading library might need to be linked to explicitly.
Expand Down Expand Up @@ -157,6 +153,7 @@ The following environment variables can be set to alter default behavior of the
| DEPTHAI_CONNECT_TIMEOUT | Specifies timeout in milliseconds for establishing a connection to a given device. |
| DEPTHAI_BOOTUP_TIMEOUT | Specifies timeout in milliseconds for waiting the device to boot after sending the binary. |
| DEPTHAI_PROTOCOL | Restricts default search to the specified protocol. Options: any, usb, tcpip. |
| DEPTHAI_DEVICE_MXID_LIST | Restricts default search to the specified MXIDs. Accepts comma separated list of MXIDs |
| DEPTHAI_DEVICE_BINARY | Overrides device Firmware binary. Mostly for internal debugging purposes. |
| DEPTHAI_BOOTLOADER_BINARY_USB | Overrides device USB Bootloader binary. Mostly for internal debugging purposes. |
| DEPTHAI_BOOTLOADER_BINARY_ETH | Overrides device Network Bootloader binary. Mostly for internal debugging purposes. |
Expand Down
4 changes: 2 additions & 2 deletions cmake/ClangFormat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function(clangformat_setup files target)
endif()

if(NOT EXISTS ${CLANG_FORMAT_BIN})
find_program(CLANG_FORMAT_BIN_tmp NAMES clang-format clang-format-10)
find_program(CLANG_FORMAT_BIN_tmp NAMES clang-format clang-format-10 clang-format-11 clang-format-12 clang-format-13 clang-format-14)
if(CLANG_FORMAT_BIN_tmp)
set(CLANG_FORMAT_BIN ${CLANG_FORMAT_BIN_tmp})
unset(CLANG_FORMAT_BIN_tmp)
Expand Down Expand Up @@ -46,7 +46,7 @@ endfunction()


macro(header_directories header_dirs return_list)

foreach(header_dir ${header_dirs})
file(GLOB_RECURSE new_list "${header_dir}/*.hpp")
set(file_list "")
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 "e483189a46ece011aca33e693eddddbce0236f50")
set(DEPTHAI_DEVICE_SIDE_COMMIT "2b90186f5479af3e3478326167df1daeaa30ca0c")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
25 changes: 19 additions & 6 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ hunter_config(

hunter_config(
XLink
VERSION "luxonis-2021.4.2-develop-tcp_nodelay"
URL "https://github.com/luxonis/XLink/archive/b765883efc43ecbbbc1ede25403f933de6679d53.tar.gz"
SHA1 "c4e0d2d186b79227558b307b9f5a98b4c9a746f7"
VERSION "luxonis-2021.4.2-develop"
URL "https://github.com/luxonis/XLink/archive/9fcd6dc8b7d0f95d892b059c0c938c97bc9da6dc.tar.gz"
SHA1 "6a4187839a94b948db3d7cc94a7e8e8651573ef4"
)

hunter_config(
Expand All @@ -32,9 +32,9 @@ hunter_config(
# libarchive, luxonis fork
hunter_config(
libarchive-luxonis
VERSION "3.4.2-p2"
URL "https://github.com/luxonis/libarchive/archive/cf2caf0588fc5e2af22cae37027d3ff6902e096f.tar.gz"
SHA1 "e99477d32ce14292fe652dc5f4f460d3af8fbc93"
VERSION "hunter-3.5.2"
URL "https://github.com/luxonis/libarchive/archive/45baa3a3e57104519e1165bcd5ac29c3bd8c9f3a.tar.gz"
SHA1 "ca5cd0f1c31b9c187d7119cb1aa7467f8c231d29"
CMAKE_ARGS
ENABLE_ACL=OFF
ENABLE_BZip2=OFF
Expand Down Expand Up @@ -111,3 +111,16 @@ hunter_config(
URL "https://github.com/luxonis/zlib/archive/refs/tags/v1.2.11-p2.tar.gz"
SHA1 "fb8b6486183b13a86040f793a939b128f6d27095"
)

# TMP, could be read from XLink
# libusb without udev
hunter_config(
libusb-luxonis
VERSION "1.0.24-cmake"
URL "https://github.com/luxonis/libusb/archive/b7e4548958325b18feb73977163ad44398099534.tar.gz"
SHA1 "2d79573d57628fe56d2868d2f6ce756d40906cf4"
CMAKE_ARGS
WITH_UDEV=OFF
# Build shared libs by default to not cause licensing issues
BUILD_SHARED_LIBS=ON
)
8 changes: 7 additions & 1 deletion cmake/depthaiDependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
if(CONFIG_MODE)
set(_CMAKE_PREFIX_PATH_ORIGINAL ${CMAKE_PREFIX_PATH})
set(_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE_ORIGINAL ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE})
# Fixes Android NDK build, where prefix path is ignored as its not inside sysroot
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH")
# Sets where to search for packages about to follow
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/${_IMPORT_PREFIX}" ${CMAKE_PREFIX_PATH})
set(_QUIET "QUIET")
else()
Expand Down Expand Up @@ -66,7 +70,7 @@ if(DEPTHAI_XLINK_LOCAL AND (NOT CONFIG_MODE))
unset(_BUILD_SHARED_LIBS_SAVED)
list(APPEND targets_to_export XLink)
else()
find_package(XLink ${_QUIET} CONFIG REQUIRED)
find_package(XLink ${_QUIET} CONFIG REQUIRED HINTS "${CMAKE_CURRENT_LIST_DIR}/XLink" "${CMAKE_CURRENT_LIST_DIR}/../XLink")
endif()

# OpenCV 4 - (optional, quiet always)
Expand All @@ -81,6 +85,8 @@ endif()
if(CONFIG_MODE)
set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH_ORIGINAL})
set(_CMAKE_PREFIX_PATH_ORIGINAL)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE_ORIGINAL})
set(_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE_ORIGINAL)
set(_QUIET)
else()
set(DEPTHAI_SHARED_LIBS)
Expand Down
12 changes: 12 additions & 0 deletions cmake/toolchain/asan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(_internal_flags_sanitizer "-fno-omit-frame-pointer -fsanitize=address")
set(CMAKE_C_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_CXX_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_C_FLAGS_INIT ${_internal_flags_sanitizer})
set(CMAKE_CXX_FLAGS_INIT ${_internal_flags_sanitizer})
set(CMAKE_EXE_LINKER_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_EXE_LINKER_FLAGS_INIT ${_internal_flags_sanitizer})
set(CMAKE_SHARED_LINKER_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_SHARED_LINKER_FLAGS_INIT ${_internal_flags_sanitizer})
set(CMAKE_MODULE_LINKER_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_MODULE_LINKER_FLAGS_INIT ${_internal_flags_sanitizer})
set(_internal_flags_sanitizer)
12 changes: 12 additions & 0 deletions cmake/toolchain/ubsan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(_internal_flags_sanitizer "-fno-omit-frame-pointer -fsanitize=undefined")
set(CMAKE_C_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_CXX_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_C_FLAGS_INIT ${_internal_flags_sanitizer})
set(CMAKE_CXX_FLAGS_INIT ${_internal_flags_sanitizer})
set(CMAKE_EXE_LINKER_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_EXE_LINKER_FLAGS_INIT ${_internal_flags_sanitizer})
set(CMAKE_SHARED_LINKER_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_SHARED_LINKER_FLAGS_INIT ${_internal_flags_sanitizer})
set(CMAKE_MODULE_LINKER_FLAGS ${_internal_flags_sanitizer})
set(CMAKE_MODULE_LINKER_FLAGS_INIT ${_internal_flags_sanitizer})
set(_internal_flags_sanitizer)
39 changes: 36 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ target_include_directories(utility PUBLIC "utility")
add_default_flags(utility LEAN)
target_link_libraries(utility FP16::fp16 ${OpenCV_LIBS})

# Create environments for usb & poe labels
set(test_usb_env
# Misc
"UBSAN_OPTIONS=halt_on_error=1"
# DepthAI
"DEPTHAI_PROTOCOL=usb"
)
set(test_poe_env
# Misc
"UBSAN_OPTIONS=halt_on_error=1"
# DepthAI
"DEPTHAI_PROTOCOL=tcpip;DEPTHAI_SEARCH_TIMEOUT=15000"
)

# Helper for adding new examples
function(dai_add_example example_name example_src enable_test)

Expand Down Expand Up @@ -43,17 +57,32 @@ function(dai_add_example example_name example_src enable_test)
set_tests_properties(${example_name} PROPERTIES FAIL_REGULAR_EXPRESSION "\\[warning\\];\\[error\\];\\[critical\\]")

# Add ubsan halt on error
set_tests_properties(${example_name} PROPERTIES ENVIRONMENT "UBSAN_OPTIONS=halt_on_error=1;DEPTHAI_PROTOCOL=usb" LABELS usb)
set_tests_properties(${example_name} PROPERTIES ENVIRONMENT "${test_usb_env}" LABELS usb)

# Add PoE test variants
add_test(NAME ${example_name}_poe COMMAND ${CMAKE_COMMAND}
-DTIMEOUT_SECONDS=50
-P ${CMAKE_CURRENT_LIST_DIR}/cmake/ExecuteTestTimeout.cmake $<TARGET_FILE:${example_name}> ${arguments}
)
# Add ubsan halt on error
set_tests_properties(${example_name}_poe PROPERTIES ENVIRONMENT "UBSAN_OPTIONS=halt_on_error=1;DEPTHAI_PROTOCOL=tcpip;DEPTHAI_SEARCH_TIMEOUT=15000" LABELS poe)
set_tests_properties(${example_name}_poe PROPERTIES ENVIRONMENT "${test_poe_env}" LABELS poe)

endif()

# Copy over required DLLs (Windows)
if(WIN32)
# Copy dlls to target directory - Windows only
# TARGET_RUNTIME_DLLS generator expression available since CMake 3.21
if(CMAKE_VERSION VERSION_LESS "3.21")
file(GLOB depthai_dll_libraries "${HUNTER_INSTALL_PREFIX}/bin/*.dll")
else()
set(depthai_dll_libraries "$<TARGET_RUNTIME_DLLS:${example_name}>")
endif()
add_custom_command(TARGET ${example_name} POST_BUILD COMMAND
${CMAKE_COMMAND} -E copy ${depthai_dll_libraries} $<TARGET_FILE_DIR:${example_name}>
COMMAND_EXPAND_LISTS
)
endif()
endfunction()

# Create a custom target which runs all examples for 10 seconds max, and check if they executed without errors
Expand Down Expand Up @@ -309,4 +338,8 @@ dai_add_example(tiny_yolo_v3_device_side_decoding Yolo/tiny_yolo.cpp ON)
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}")
dai_add_example(apriltag AprilTag/apriltag.cpp ON)
dai_add_example(apriltag_rgb AprilTag/apriltag_rgb.cpp ON)
dai_add_example(apriltag_rgb AprilTag/apriltag_rgb.cpp ON)

# DetectionParser
dai_add_example(detection_parser NeuralNetwork/detection_parser.cpp ON)
target_compile_definitions(detection_parser PRIVATE BLOB_PATH="${mobilenet_blob}")
Loading

0 comments on commit 75d9906

Please sign in to comment.