commit 2e2bc89d553699655db75888beda16680b01af53 Author: Zuckerberg Date: Tue Nov 29 14:54:11 2022 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2f5dd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..80d372a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 zuckerberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..30e9ef8 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# depthai sdk nix + +[Depthai python sdk](https://docs.luxonis.com/projects/sdk/en/latest/) packaged for [Nix](https://nixos.org/). + +Before running make sure you have the udev rules set up. Follow [this guide](https://docs.luxonis.com/en/latest/pages/troubleshooting/#udev-rules-on-linux) or just use the following snippet if using NixOS. + +```nix +{ + services.udev.extraRules = '' + SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666" + ''; +} +``` + +### Usage + +To try the example: + +```sh +nix run .#depthai-example +``` + +### Credits + +[Based on the work here for building the C++ depthai-core](https://github.com/queezle42/depthai-nix) \ No newline at end of file diff --git a/example/main.py b/example/main.py new file mode 100644 index 0000000..c702ab7 --- /dev/null +++ b/example/main.py @@ -0,0 +1,12 @@ +from depthai_sdk import OakCamera + +def run(): + with OakCamera(replay='https://www.youtube.com/watch?v=Y1jTEyb3wiI') as oak: + color = oak.create_camera('color') + nn = oak.create_nn('vehicle-detection-0202', color) + oak.visualize([nn.out.passthrough], fps=True) + oak.visualize(nn, scale=2 / 3, fps=True) + oak.start(blocking=True) + +if __name__ == "__main__": + run() \ No newline at end of file diff --git a/example/setup.py b/example/setup.py new file mode 100644 index 0000000..acf8cf1 --- /dev/null +++ b/example/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup +requires = ["depthai_sdk"] +setup( + name='depthai-example', + version='0.1', + py_modules=[ + 'main' + ], + entry_points={ + 'console_scripts': ['depthai-example = main:run'] + }, +) \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7104fab --- /dev/null +++ b/flake.lock @@ -0,0 +1,135 @@ +{ + "nodes": { + "depthai-python": { + "flake": false, + "locked": { + "lastModified": 1668364016, + "narHash": "sha256-akH44DaeyKD00D9TWDezr1eMjp55cjli7nQwpAHHHWs=", + "ref": "refs/tags/v2.19.1.0", + "rev": "4ac38655f488e5bd84d1c2b2b91692928ec04aca", + "revCount": 2860, + "submodules": true, + "type": "git", + "url": "https://github.com/luxonis/depthai-python" + }, + "original": { + "ref": "refs/tags/v2.19.1.0", + "submodules": true, + "type": "git", + "url": "https://github.com/luxonis/depthai-python" + } + }, + "depthai-sdk": { + "flake": false, + "locked": { + "lastModified": 1669063675, + "narHash": "sha256-uSDcecVC/gFdXSN7bZjQEFFYsFZw5LXVbOPuuID5iVo=", + "owner": "luxonis", + "repo": "depthai", + "rev": "2b22e4afb94bfff6c60ddbeceaa0e20cbf170490", + "type": "github" + }, + "original": { + "owner": "luxonis", + "repo": "depthai", + "rev": "2b22e4afb94bfff6c60ddbeceaa0e20cbf170490", + "type": "github" + } + }, + "fp16": { + "flake": false, + "locked": { + "lastModified": 1552877455, + "narHash": "sha256-AFlV31tc0xDbr5eqWPxv8Uj3vvXR3X1ChBBOTuF6VIo=", + "owner": "hunter-packages", + "repo": "FP16", + "rev": "bd06e94bc59bf187782d32da8e797f8d801fbb7c", + "type": "github" + }, + "original": { + "owner": "hunter-packages", + "repo": "FP16", + "type": "github" + } + }, + "libnop": { + "flake": false, + "locked": { + "lastModified": 1649522868, + "narHash": "sha256-w1g+eMLTSZIwf8FgS85STBjulocy9ORsazUXEAOHTfQ=", + "owner": "luxonis", + "repo": "libnop", + "rev": "70d158961ce0459e32a2b1641cddc627550e5663", + "type": "github" + }, + "original": { + "owner": "luxonis", + "ref": "develop", + "repo": "libnop", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1658247182, + "narHash": "sha256-FbtOZrHu7B0/6aWZyOjjzMV+HQ0fuuL0amuBQfUBTYY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8949f6984d90d3f6d16883d60ace71f04220ebb2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8949f6984d90d3f6d16883d60ace71f04220ebb2", + "type": "github" + } + }, + "psimd": { + "flake": false, + "locked": { + "lastModified": 1589713121, + "narHash": "sha256-lV+VZi2b4SQlRYrhKx9Dxc6HlDEFz3newvcBjTekupo=", + "owner": "Maratyszcza", + "repo": "psimd", + "rev": "072586a71b55b7f8c584153d223e95687148a900", + "type": "github" + }, + "original": { + "owner": "Maratyszcza", + "repo": "psimd", + "type": "github" + } + }, + "root": { + "inputs": { + "depthai-python": "depthai-python", + "depthai-sdk": "depthai-sdk", + "fp16": "fp16", + "libnop": "libnop", + "nixpkgs": "nixpkgs", + "psimd": "psimd", + "xlink": "xlink" + } + }, + "xlink": { + "flake": false, + "locked": { + "lastModified": 1667095399, + "narHash": "sha256-bWd+blcXbhE5byOLT0/Nk8RtE0LQZReg4lW6semfkeE=", + "owner": "luxonis", + "repo": "XLink", + "rev": "5c61615066af6539e50a4a17b5df3466e4350b21", + "type": "github" + }, + "original": { + "owner": "luxonis", + "ref": "develop", + "repo": "XLink", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7662b51 --- /dev/null +++ b/flake.nix @@ -0,0 +1,293 @@ +{ + inputs = { + # Downgrade nixpkgs for working spdlog/fmt package versions + nixpkgs.url = github:NixOS/nixpkgs/8949f6984d90d3f6d16883d60ace71f04220ebb2; + + xlink.url = github:luxonis/XLink/develop; + xlink.flake = false; + + fp16.url = github:hunter-packages/FP16; + fp16.flake = false; + + psimd.url = github:Maratyszcza/psimd; + psimd.flake = false; + + libnop.url = github:luxonis/libnop/develop; + libnop.flake = false; + + depthai-python.url = https://github.com/luxonis/depthai-python; + depthai-python.flake = false; + depthai-python.type = "git"; + depthai-python.submodules = true; + depthai-python.ref = "refs/tags/v2.19.1.0"; + + depthai-sdk.url = github:luxonis/depthai/2b22e4afb94bfff6c60ddbeceaa0e20cbf170490; + depthai-sdk.flake = false; + }; + + outputs = { self, nixpkgs, xlink, fp16, psimd, libnop, depthai-python, depthai-sdk }: + with nixpkgs.lib; + let + systems = platforms.unix; + forAllSystems = genAttrs systems; + + # Version is coupled to "depthai-core" submodule of "depthai-python": + # > cmake/Depthai/DepthaiBootloaderConfig.cmake + depthai-bootloader = builtins.fetchurl { + url = "https://artifacts.luxonis.com/artifactory/luxonis-myriad-release-local/depthai-bootloader/0.0.21/depthai-bootloader-fwp-0.0.21.tar.xz"; + name = "depthai-bootloader-fwp.tar.xz"; + sha256 = "0yxpdc0bbwrkjg7az07335wx1dk4n6vfa0lkawlz3d61xxaw5h57"; + }; + + # Version is coupled to "depthai-core" submodule of "depthai-python": + # > cmake/Depthai/DepthaiDeviceSideConfig.cmake + depthai-device = builtins.fetchurl { + url = "https://artifacts.luxonis.com/artifactory/luxonis-myriad-snapshot-local/depthai-device-side/adbcc016c8bd5a5580a26d8b6250f77160203666/depthai-device-fwp-adbcc016c8bd5a5580a26d8b6250f77160203666.tar.xz"; + sha256 = "191hz3d0fwmsn3vz3m98sxfsvrqs02vgq2sh6n1kz8wl04zkqg6s"; + }; + + xlink-drv = {clangStdenv, cmake, libusb1}: + clangStdenv.mkDerivation { + name = "xlink-unstable"; + src = xlink; + nativeBuildInputs = [ cmake ]; + buildInputs = [ libusb1 ]; + cmakeFlags = [ + "-DHUNTER_ENABLED=OFF" + "-DXLINK_LIBUSB_SYSTEM=ON" + ]; + }; + + fp16-drv = { clangStdenv, cmake }: + clangStdenv.mkDerivation { + name = "fp16-unstable"; + src = fp16; + nativeBuildInputs = [ cmake ]; + cmakeFlags = [ + "-DFP16_BUILD_TESTS=OFF" + "-DFP16_BUILD_BENCHMARKS=OFF" + "-DPSIMD_SOURCE_DIR=${psimd}" + ]; + }; + + libnop-drv = { clangStdenv, cmake, ninja, gtest }: + clangStdenv.mkDerivation { + name = "libnop-unstable"; + src = libnop; + nativeBuildInputs = [ cmake ninja gtest ]; + }; + + depthai-python-drv = { + cmake, + pkg-config, + xlink, + fp16, + libnop, + bzip2, + libarchive, + xz, + zlib, + spdlog, + nlohmann_json, + opencv, + python310Packages, + }: python310Packages.buildPythonPackage { + name = "depthai-python"; + version = depthai-python.rev; + src = depthai-python; + nativeBuildInputs = [ cmake pkg-config ]; + dontUseCmakeBuildDir = true; + propagatedBuildInputs = [ + xlink + bzip2 + fp16 + libnop + libarchive + xz + zlib + spdlog + nlohmann_json + opencv + python310Packages.python + python310Packages.pybind11 + ]; + cmakeFlags = [ + "-DHUNTER_ENABLED=OFF" + "-DBUILD_SHARED_LIBS=ON" + "-DDEPTHAI_ENABLE_BACKWARD=OFF" + "-DDEPTHAI_BINARIES_RESOURCE_COMPILE=ON" + "-DDEPTHAI_BOOTLOADER_FWP=${depthai-bootloader}" + "-DDEPTHAI_DEVICE_FWP=${depthai-device}" + ]; + patches = [ + ./patches/fix-cmake-build-env.patch + ./patches/fw-in-nix-store.patch + # Source: https://github.com/luxonis/depthai-core/issues/447 + ./patches/no-hunter.patch + ./patches/no-download.patch + ]; + postPatch = '' + # libnop has this set as an include dir for some reason. Make sure it exists. + # TODO: fix libnop eventually + mkdir include + + # patch depthai to use bootloader and device fw located in the nix store + sed -i 's|"depthai-device-fwp-" DEPTHAI_DEVICE_VERSION ".tar.xz"|"${depthai-device}"|' depthai-core/src/utility/Resources.cpp + sed -i 's|"depthai-bootloader-fwp-" DEPTHAI_BOOTLOADER_VERSION ".tar.xz"|"${depthai-bootloader}"|' depthai-core/src/utility/Resources.cpp + ''; + }; + + # blob converters make me sad :( + blobconverter-drv = { python310Packages }: + python310Packages.buildPythonPackage rec { + pname = "blobconverter"; + version = "1.3.0"; + doCheck = false; + propagatedBuildInputs = with python310Packages; [ + requests pyyaml boto3 + ]; + src = python310Packages.fetchPypi { + inherit pname version; + sha256 = "bxosxqTQNHpnXt3CF6oHUb1brAn9axkZW2QfbqnrHME="; + }; + }; + + distinctipy-drv = { python310Packages }: + python310Packages.buildPythonPackage rec { + pname = "distinctipy"; + version = "1.2.2"; + propagatedBuildInputs = with python310Packages; [ + numpy + ]; + src = python310Packages.fetchPypi { + inherit pname version; + sha256 = "gUWkInZqfmU1Sdi+wpeMC4Il+RptCL7ORiKMRKXslis="; + }; + }; + + marshmallow-3-17-drv = { + lib, + fetchFromGitHub, + python310Packages, + }: python310Packages.buildPythonPackage rec { + pname = "marshmallow"; + version = "3.17.0"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "marshmallow-code"; + repo = pname; + rev = version; + hash = "sha256-KfLC5fpZitHMcuTsMsm8K02cGGXxaMu0hdLeJUmc/Yg="; + }; + + propagatedBuildInputs = with python310Packages; [ + packaging + ]; + + checkInputs = with python310Packages; [ + pytestCheckHook + pytz + simplejson + ]; + }; + + qt-py-drv = { + python310Packages, + }: python310Packages.buildPythonPackage rec { + pname = "qt-py"; + version = "1.3.7"; + doCheck = false; + propagatedBuildInputs = with python310Packages; [ + pyside2 + ]; + src = python310Packages.fetchPypi { + pname = "Qt.py"; + inherit version; + sha256 = "gDx7301iMPmkZr4Z1Vk0oXPqu2FAbSHLkegMKj93Ox8="; + }; + }; + + depthai-sdk-drv = { + python310Packages, + depthai-python, + distinctipy, + blobconverter, + marshmallow-3-17, + qt-py, + }: python310Packages.buildPythonPackage { + name = "depthai-sdk"; + version = "1.9.0"; + src = depthai-sdk; + sourceRoot = "source/depthai_sdk"; + propagatedBuildInputs = with python310Packages; [ + numpy + (opencv4.override { enableGtk2 = true; }) + depthai-python + pyturbojpeg + marshmallow-3-17 + blobconverter + distinctipy + xmltodict + pytube + matplotlib + qt-py + ]; + patches = [ + ./patches/no-opencv-contrib.patch + ]; + }; + + depthai-example-drv = { + python310Packages, + depthai-sdk, + depthai-python, + }: python310Packages.buildPythonApplication { + pname = "depthai-example"; + src = self; + sourceRoot = "source/example"; + version = "0.1"; + propagatedBuildInputs = with python310Packages; [ + depthai-sdk + ]; + preFixup = '' + # TODO: for some reason lookup of this shared lib doesn't just work + makeWrapperArgs+=("--prefix" "LD_LIBRARY_PATH" ":" "${depthai-python}/lib/python3.10/site-packages") + ''; + }; + + in { + overlays.default = final: prev: { + xlink = final.callPackage xlink-drv {}; + fp16 = final.callPackage fp16-drv {}; + libnop = final.callPackage libnop-drv {}; + depthai-python = final.callPackage depthai-python-drv {}; + blobconverter = final.callPackage blobconverter-drv {}; + distinctipy = final.callPackage distinctipy-drv {}; + marshmallow-3-17 = final.callPackage marshmallow-3-17-drv {}; + qt-py = final.callPackage qt-py-drv {}; + depthai-sdk = final.callPackage depthai-sdk-drv {}; + depthai-example = final.callPackage depthai-example-drv {}; + }; + + packages = forAllSystems (system: + let + pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; + in rec { + default = depthai-sdk; + + depthai-example = pkgs.depthai-example; + + depthai-python = pkgs.depthai-python; + depthai-sdk = pkgs.depthai-sdk; + + xlink = pkgs.xlink; + fp16 = pkgs.fp16; + libnop = pkgs.libnop; + blobconverter = pkgs.blobconverter; + distinctipy = pkgs.distinctipy; + marshmallow-3-17 = pkgs.marshmallow-3-17; + } + ); + }; +} diff --git a/patches/fix-cmake-build-env.patch b/patches/fix-cmake-build-env.patch new file mode 100644 index 0000000..9c3fcfc --- /dev/null +++ b/patches/fix-cmake-build-env.patch @@ -0,0 +1,28 @@ +diff --git a/setup.py b/setup.py +index 341ab5f2..e649e43e 100644 +--- a/setup.py ++++ b/setup.py +@@ -169,11 +169,7 @@ class CMakeBuild(build_ext): + env['_PYTHON_HOST_PLATFORM'] = re.sub(r'macosx-[0-9]+\.[0-9]+-(.+)', r'macosx-10.9-\1', util.get_platform()) + + # Specify how many threads to use when building, depending on available memory +- max_threads = multiprocessing.cpu_count() +- num_threads = (freeMemory // 2000) +- num_threads = min(num_threads, max_threads) +- if num_threads <= 0: +- num_threads = 1 ++ num_threads = int(os.environ['NIX_BUILD_CORES']) + build_args += ['--', '-j' + str(num_threads)] + cmake_args += ['-DHUNTER_JOBS_NUMBER=' + str(num_threads)] + +@@ -187,8 +183,8 @@ class CMakeBuild(build_ext): + os.makedirs(self.build_temp) + + # Configure and build +- subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) +- subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp, env=env) ++ subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, env=env) ++ subprocess.check_call(['cmake', '--build', '.'] + build_args, env=env) + + setup( + name=MODULE_NAME, \ No newline at end of file diff --git a/patches/fw-in-nix-store.patch b/patches/fw-in-nix-store.patch new file mode 100644 index 0000000..e6b242f --- /dev/null +++ b/patches/fw-in-nix-store.patch @@ -0,0 +1,31 @@ +diff --git a/depthai-core/src/utility/Resources.cpp b/depthai-core/src/utility/Resources.cpp +index bca4dbde..e55436ea 100644 +--- a/depthai-core/src/utility/Resources.cpp ++++ b/depthai-core/src/utility/Resources.cpp +@@ -255,9 +255,14 @@ std::function getLazyTarXzFunction(MTX& mtx, CV& cv, BOOL& ready, PATH c + return [&mtx, &cv, &ready, cmrcPath, &resourceList, &resourceMap] { + using namespace std::chrono; + +- // Get binaries from internal sources +- auto fs = cmrc::depthai::get_filesystem(); +- auto tarXz = fs.open(cmrcPath); ++ std::ifstream file(cmrcPath, std::ios::binary | std::ios::ate); ++ auto size = file.tellg(); ++ file.seekg(0, std::ios::beg); ++ std::vector buffer(size); ++ if (!file.read(buffer.data(), size)) ++ { ++ throw std::runtime_error(std::string("Could not open file for reading: \"") + cmrcPath + '"'); ++ } + + auto t1 = steady_clock::now(); + +@@ -265,7 +270,7 @@ std::function getLazyTarXzFunction(MTX& mtx, CV& cv, BOOL& ready, PATH c + struct archive* a = archive_read_new(); + archive_read_support_filter_xz(a); + archive_read_support_format_tar(a); +- int r = archive_read_open_memory(a, tarXz.begin(), tarXz.size()); ++ int r = archive_read_open_memory(a, buffer.data(), size); + assert(r == ARCHIVE_OK); + + auto t2 = steady_clock::now(); \ No newline at end of file diff --git a/patches/no-download.patch b/patches/no-download.patch new file mode 100644 index 0000000..09ad259 --- /dev/null +++ b/patches/no-download.patch @@ -0,0 +1,71 @@ +--- a/depthai-core/CMakeLists.txt ++++ b/depthai-core/CMakeLists.txt +@@ -276,16 +276,12 @@ endif() + + # Set constant + set(DEPTHAI_RESOURCES_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/resources") ++message(STATUS "resource folder: ${DEPTHAI_RESOURCES_OUTPUT_DIR}") + + # Include configuration + include(Depthai/DepthaiDeviceSideConfig) # Depthai device binary commit/version configuration + include(Depthai/DepthaiBootloaderConfig) # Depthai bootloader binary commit/version configuration + +-# Include downloaders +-include(DepthaiDownloader) # Depthai device binary downloader +-include(DepthaiBootloaderDownloader) # Depthai bootloader binary downloader +- +- + # depthai-shared enforce commit hash match if CI + if($ENV{CI}) + set(DEPTHAI_SHARED_COMMIT_HASH_ENFORCE ON) +@@ -293,47 +289,9 @@ if($ENV{CI}) + endif() + + if(DEPTHAI_BINARIES_RESOURCE_COMPILE) +- +- # Then get the Depthai device side binaries (local or download) +- if(DEPTHAI_CMD_PATH OR DEPTHAI_USB2_CMD_PATH OR DEPTHAI_USB2_PATCH_PATH) +- # Atleast one of the paths is set. include binaries locally +- message(STATUS "Using local Depthai device side binaries...") +- +- DepthaiLocal( +- PATCH_ONLY ${DEPTHAI_USB2_PATCH_ONLY_MODE} +- "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder +- DEPTHAI_RESOURCE_LIST # List of output resources +- "${DEPTHAI_CMD_PATH}" # depthai.cmd +- "${DEPTHAI_USB2_CMD_PATH}" # depthai-usb2.cmd +- "${DEPTHAI_USB2_PATCH_PATH}" # depthai-usb2-patch.patch +- ) +- +- else() +- # No user specified paths, download from server +- message(STATUS "Downloading Depthai device side binaries from server...") +- +- DepthaiDownload( +- "${DEPTHAI_SHARED_COMMIT_HASH}" "${DEPTHAI_SHARED_COMMIT_HASH_ENFORCE}" +- PATCH_ONLY ${DEPTHAI_USB2_PATCH_ONLY_MODE} +- "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder +- DEPTHAI_RESOURCE_LIST # List of output resources +- "${DEPTHAI_DEVICE_SIDE_MATURITY}" # Maturity +- "${DEPTHAI_DEVICE_SIDE_COMMIT}" # commit hash +- "${DEPTHAI_DEVICE_SIDE_VERSION}" # Optional version +- ) +- endif() +- list(APPEND RESOURCE_COMPILED_FILES ${DEPTHAI_RESOURCE_LIST}) +- +- # Add bootloader +- DepthaiBootloaderDownload( +- "${DEPTHAI_BOOTLOADER_SHARED_COMMIT_HASH}" "${DEPTHAI_BOOTLOADER_SHARED_COMMIT_HASH_ENFORCE}" +- "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder +- DEPTHAI_BOOTLOADER_RESOURCE_LIST # List of output resources +- "${DEPTHAI_BOOTLOADER_MATURITY}" # Maturity +- "${DEPTHAI_BOOTLOADER_VERSION}" # if maturity == snapshot -> hash else version +- ) +- list(APPEND RESOURCE_COMPILED_FILES ${DEPTHAI_BOOTLOADER_RESOURCE_LIST}) +- ++ file(COPY "${DEPTHAI_BOOTLOADER_FWP}" DESTINATION "${DEPTHAI_RESOURCES_OUTPUT_DIR}") ++ file(COPY "${DEPTHAI_DEVICE_FWP}" DESTINATION "${DEPTHAI_RESOURCES_OUTPUT_DIR}") ++ file(GLOB RESOURCE_COMPILED_FILES "${DEPTHAI_RESOURCES_OUTPUT_DIR}/*.tar.xz") + message(STATUS "LIST OF RESOURCE COMPILED FILES: ${RESOURCE_COMPILED_FILES}") + + # Add RC and resource compile the binares diff --git a/patches/no-hunter.patch b/patches/no-hunter.patch new file mode 100644 index 0000000..4f36d36 --- /dev/null +++ b/patches/no-hunter.patch @@ -0,0 +1,178 @@ +--- a/depthai-core/CMakeLists.txt ++++ b/depthai-core/CMakeLists.txt +@@ -113,7 +113,7 @@ endif() + set(PROJECT_EXPORT_GROUP "${PROJECT_NAME}Targets") + + ## Check if cloned or sources +-find_package(Git) ++# find_package(Git) + if(GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --is-inside-work-tree +@@ -292,50 +292,50 @@ if($ENV{CI}) + set(DEPTHAI_BOOTLOADER_SHARED_COMMIT_HASH_ENFORCE ON) + endif() + ++if(DEPTHAI_BINARIES_RESOURCE_COMPILE) + +-# Then get the Depthai device side binaries (local or download) +-if(DEPTHAI_CMD_PATH OR DEPTHAI_USB2_CMD_PATH OR DEPTHAI_USB2_PATCH_PATH) +- # Atleast one of the paths is set. include binaries locally +- message(STATUS "Using local Depthai device side binaries...") ++ # Then get the Depthai device side binaries (local or download) ++ if(DEPTHAI_CMD_PATH OR DEPTHAI_USB2_CMD_PATH OR DEPTHAI_USB2_PATCH_PATH) ++ # Atleast one of the paths is set. include binaries locally ++ message(STATUS "Using local Depthai device side binaries...") + +- DepthaiLocal( +- PATCH_ONLY ${DEPTHAI_USB2_PATCH_ONLY_MODE} +- "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder +- DEPTHAI_RESOURCE_LIST # List of output resources +- "${DEPTHAI_CMD_PATH}" # depthai.cmd +- "${DEPTHAI_USB2_CMD_PATH}" # depthai-usb2.cmd +- "${DEPTHAI_USB2_PATCH_PATH}" # depthai-usb2-patch.patch +- ) ++ DepthaiLocal( ++ PATCH_ONLY ${DEPTHAI_USB2_PATCH_ONLY_MODE} ++ "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder ++ DEPTHAI_RESOURCE_LIST # List of output resources ++ "${DEPTHAI_CMD_PATH}" # depthai.cmd ++ "${DEPTHAI_USB2_CMD_PATH}" # depthai-usb2.cmd ++ "${DEPTHAI_USB2_PATCH_PATH}" # depthai-usb2-patch.patch ++ ) + +-else() +- # No user specified paths, download from server +- message(STATUS "Downloading Depthai device side binaries from server...") +- +- DepthaiDownload( +- "${DEPTHAI_SHARED_COMMIT_HASH}" "${DEPTHAI_SHARED_COMMIT_HASH_ENFORCE}" +- PATCH_ONLY ${DEPTHAI_USB2_PATCH_ONLY_MODE} +- "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder +- DEPTHAI_RESOURCE_LIST # List of output resources +- "${DEPTHAI_DEVICE_SIDE_MATURITY}" # Maturity +- "${DEPTHAI_DEVICE_SIDE_COMMIT}" # commit hash +- "${DEPTHAI_DEVICE_SIDE_VERSION}" # Optional version ++ else() ++ # No user specified paths, download from server ++ message(STATUS "Downloading Depthai device side binaries from server...") ++ ++ DepthaiDownload( ++ "${DEPTHAI_SHARED_COMMIT_HASH}" "${DEPTHAI_SHARED_COMMIT_HASH_ENFORCE}" ++ PATCH_ONLY ${DEPTHAI_USB2_PATCH_ONLY_MODE} ++ "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder ++ DEPTHAI_RESOURCE_LIST # List of output resources ++ "${DEPTHAI_DEVICE_SIDE_MATURITY}" # Maturity ++ "${DEPTHAI_DEVICE_SIDE_COMMIT}" # commit hash ++ "${DEPTHAI_DEVICE_SIDE_VERSION}" # Optional version ++ ) ++ endif() ++ list(APPEND RESOURCE_COMPILED_FILES ${DEPTHAI_RESOURCE_LIST}) ++ ++ # Add bootloader ++ DepthaiBootloaderDownload( ++ "${DEPTHAI_BOOTLOADER_SHARED_COMMIT_HASH}" "${DEPTHAI_BOOTLOADER_SHARED_COMMIT_HASH_ENFORCE}" ++ "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder ++ DEPTHAI_BOOTLOADER_RESOURCE_LIST # List of output resources ++ "${DEPTHAI_BOOTLOADER_MATURITY}" # Maturity ++ "${DEPTHAI_BOOTLOADER_VERSION}" # if maturity == snapshot -> hash else version + ) +-endif() +-list(APPEND RESOURCE_COMPILED_FILES ${DEPTHAI_RESOURCE_LIST}) ++ list(APPEND RESOURCE_COMPILED_FILES ${DEPTHAI_BOOTLOADER_RESOURCE_LIST}) + +-# Add bootloader +-DepthaiBootloaderDownload( +- "${DEPTHAI_BOOTLOADER_SHARED_COMMIT_HASH}" "${DEPTHAI_BOOTLOADER_SHARED_COMMIT_HASH_ENFORCE}" +- "${DEPTHAI_RESOURCES_OUTPUT_DIR}" # Output folder +- DEPTHAI_BOOTLOADER_RESOURCE_LIST # List of output resources +- "${DEPTHAI_BOOTLOADER_MATURITY}" # Maturity +- "${DEPTHAI_BOOTLOADER_VERSION}" # if maturity == snapshot -> hash else version +-) +-list(APPEND RESOURCE_COMPILED_FILES ${DEPTHAI_BOOTLOADER_RESOURCE_LIST}) +- +-message(STATUS "LIST OF RESOURCE COMPILED FILES: ${RESOURCE_COMPILED_FILES}") ++ message(STATUS "LIST OF RESOURCE COMPILED FILES: ${RESOURCE_COMPILED_FILES}") + +-if(DEPTHAI_BINARIES_RESOURCE_COMPILE) + # Add RC and resource compile the binares + include(CMakeRC) + +@@ -400,11 +400,11 @@ target_link_libraries(${TARGET_CORE_NAME} + libnop + PRIVATE + Threads::Threads +- BZip2::bz2 ++ BZip2::BZip2 + FP16::fp16 +- archive_static ++ LibArchive::LibArchive + spdlog::spdlog +- ZLIB::zlib ++ ZLIB::ZLIB + ) + + # Add compile definitions +@@ -559,8 +559,10 @@ configure_file("cmake/${PROJECT_NAME}Dependencies.cmake" ${PROJECT_NAME}Dependen + write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) + + # Configure config file (one for exporting build directory, one for installation) ++if(HUNTER_ENABLED) + file(RELATIVE_PATH DEPTHAI_DEPENDENCIES_INSTALLATION_PATH_REL "${CMAKE_CURRENT_BINARY_DIR}" "${HUNTER_INSTALL_PREFIX}") + configure_file(cmake/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY) ++endif() + + # Config for installation + set(DEPTHAI_DEPENDENCIES_INSTALLATION_PATH_REL "./dependencies") +@@ -591,7 +593,10 @@ if(DEPTHAI_INSTALL) + # Install depthai-bootloader-shared public headers + install(DIRECTORY "${DEPTHAI_BOOTLOADER_SHARED_PUBLIC_INCLUDE}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + # Install Hunter dependencies ++ if(HUNTER_ENABLED) + install(DIRECTORY "${HUNTER_INSTALL_PREFIX}/" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/dependencies") ++ endif() ++ + # Install resources if not RC'd + if(NOT DEPTHAI_BINARIES_RESOURCE_COMPILE) + install(DIRECTORY "${DEPTHAI_RESOURCES_OUTPUT_DIR}/" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}") +diff --git a/depthai-core/cmake/GitCommitHash.cmake b/depthai-core/cmake/GitCommitHash.cmake +index 0b1a406..87a4c39 100644 +--- a/depthai-core/cmake/GitCommitHash.cmake ++++ b/depthai-core/cmake/GitCommitHash.cmake +@@ -1,5 +1,5 @@ + # for commit hash +-find_package(Git) ++# find_package(Git) + + set(commit_version "unknown") + +diff --git a/depthai-core/cmake/depthaiDependencies.cmake b/depthai-core/cmake/depthaiDependencies.cmake +index bbbd606..8c8387b 100644 +--- a/depthai-core/cmake/depthaiDependencies.cmake ++++ b/depthai-core/cmake/depthaiDependencies.cmake +@@ -23,19 +23,19 @@ endif() + if(NOT CONFIG_MODE OR (CONFIG_MODE AND NOT DEPTHAI_SHARED_LIBS)) + + # BZip2 (for bspatch) +- find_package(BZip2 ${_QUIET} CONFIG REQUIRED) ++ find_package(BZip2 REQUIRED) + + # FP16 for conversions +- find_package(FP16 ${_QUIET} CONFIG REQUIRED) ++ find_package(FP16 REQUIRED) + + # libarchive for firmware packages +- find_package(archive_static ${_QUIET} CONFIG REQUIRED) +- find_package(lzma ${_QUIET} CONFIG REQUIRED) ++ find_package(LibArchive REQUIRED) ++ find_package(LibLZMA REQUIRED) + # ZLIB for compressing Apps +- find_package(ZLIB CONFIG REQUIRED) ++ find_package(ZLIB REQUIRED) + + # spdlog for library and device logging +- find_package(spdlog ${_QUIET} CONFIG REQUIRED) ++ find_package(spdlog REQUIRED) + + # Backward + if(DEPTHAI_ENABLE_BACKWARD) diff --git a/patches/no-opencv-contrib.patch b/patches/no-opencv-contrib.patch new file mode 100644 index 0000000..7d265b4 --- /dev/null +++ b/patches/no-opencv-contrib.patch @@ -0,0 +1,17 @@ +diff --git a/requirements.txt b/requirements.txt +index 844614f..66c01d4 100644 +--- a/requirements.txt ++++ b/requirements.txt +@@ -1,10 +1,9 @@ + numpy>=1.19; python_version < "3.7" + numpy>=1.21; python_version >= "3.7" +-opencv-contrib-python>4 + blobconverter>=1.2.8 + pytube>=12.1.0 + depthai>=2.18.0 +-PyTurboJPEG==1.6.4 ++PyTurboJPEG>=1.6.4 + marshmallow==3.17.0 + distinctipy + xmltodict +\ No newline at end of file \ No newline at end of file