Skip to content

Commit

Permalink
Merge branch 'device_improvements' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
themarpe committed Apr 30, 2021
2 parents 03cf12c + c658ae2 commit 96386f5
Show file tree
Hide file tree
Showing 45 changed files with 176 additions and 161 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ jobs:

# Job which builds docstrings for the rest of the wheel builds
build-docstrings:
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Cache .hunter folder
uses: actions/cache@v2
with:
path: ~/.hunter
key: hunter-macos-latest
key: hunter-ubuntu-latest
- name: List .hunter cache directory
run: ls -a -l ~/.hunter/_Base/ || true
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Set up Python
uses: actions/setup-python@v2
with:
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
brew install libusb
python -m pip install git+git://github.com/luxonis/pybind11_mkdoc.git@master
sudo apt install libusb-1.0-0-dev
python -m pip install -r docs/requirements_mkdoc.txt
- name: Configure project
run: cmake -S . -B build -DDEPTHAI_PYTHON_FORCE_DOCSTRINGS=ON -DDEPTHAI_PYTHON_DOCSTRINGS_OUTPUT="$PWD/docstrings/depthai_python_docstring.hpp"
- name: Build target 'pybind11_mkdoc'
Expand All @@ -62,7 +62,7 @@ jobs:
build-linux-armhf:
needs: build-docstrings
runs-on: luxonis-armhf
container:
container:
image: registry.gitlab.com/luxonis/depthai-crosscompile/debian-buster
# Mount local hunter cache directory, instead of transfering to Github and back
volumes:
Expand All @@ -73,7 +73,7 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: 'recursive'

- uses: actions/download-artifact@v2
with:
name: 'docstrings'
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.python-architecture }}
- name: Append build hash if not a tagged commit
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
with:
python-version: ${{ matrix.python-version }}
- name: Append build hash if not a tagged commit
if: startsWith(github.ref, 'refs/tags/v') != true
Expand All @@ -197,7 +197,7 @@ jobs:
- name: Building wheels
run: python -m pip wheel . -w ./wheelhouse/ --verbose
- name: Auditing wheels
run: ci/repair-whl-macos.sh `pwd`/wheelhouse/* `pwd`/wheelhouse/audited
run: ci/repair-whl-macos.sh `pwd`/wheelhouse/* `pwd`/wheelhouse/audited
- name: Archive wheel artifacts
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -336,12 +336,12 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64, build-linux-arm64]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Get tag version
id: tag
uses: battila7/get-version-action@v2
Expand Down
27 changes: 15 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ endif()
hunter_add_package(pybind11)

# Disable LTO if MINGW compiler
if(MINGW)
if(MINGW)
set(PYBIND11_LTO_CXX_FLAGS "" CACHE STRING "" FORCE)
endif()
find_package(pybind11 CONFIG REQUIRED)

# Add files for python module
pybind11_add_module(${TARGET_NAME}
pybind11_add_module(${TARGET_NAME}
src/py_bindings.cpp
src/XLinkConnectionBindings.cpp
src/DeviceBindings.cpp
Expand All @@ -104,8 +104,8 @@ endif()

if(DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT)
# If output is specified set both input and output to same the path
set(docstring_input_path ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT})
set(docstring_output_path ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT})
set(docstring_input_path ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT})
set(docstring_output_path ${DEPTHAI_PYTHON_DOCSTRINGS_OUTPUT})
else()
# If input docstrings explicitly specified, use those and disable building
if(DEPTHAI_PYTHON_DOCSTRINGS_INPUT)
Expand All @@ -114,11 +114,11 @@ else()
set(DEPTHAI_PYTHON_BUILD_DOCSTRINGS OFF CACHE BOOL "Generate docstrings from header files if module 'pybind11_mkdoc' available" FORCE)
else()
# Otherwise set default location as input
set(docstring_input_path ${DEFAULT_DOCSTRINGS_OUTPUT})
set(docstring_input_path ${DEFAULT_DOCSTRINGS_OUTPUT})
endif()

# Set default output location
set(docstring_output_path ${DEFAULT_DOCSTRINGS_OUTPUT})
set(docstring_output_path ${DEFAULT_DOCSTRINGS_OUTPUT})
endif()

if(DEPTHAI_PYTHON_BUILD_DOCSTRINGS)
Expand All @@ -130,11 +130,14 @@ configure_file(cmake/docstring.hpp.in ${DOCSTRINGS_INCLUDE_PLACEHOLDER_PATH})
# Add target to generate docstrings
if (DEPTHAI_PYTHON_BUILD_DOCSTRINGS)
include(pybind11-mkdoc)

# Check if pybind11_mkdoc available and create target
target_pybind11_mkdoc_setup(${docstring_output_path} depthai::core ${DEPTHAI_PYTHON_FORCE_DOCSTRINGS})

if(NOT TARGET pybind11_mkdoc)

if(TARGET pybind11_mkdoc)
# Add dependency to mkdoc target (makes sure that mkdoc is executed, and docstrings available)
add_dependencies(${TARGET_NAME} pybind11_mkdoc)
else()
# Generate default docstrings to OUTPUT path
configure_file(cmake/default_docstring.hpp.in ${docstring_output_path} COPYONLY)
endif()
Expand All @@ -147,16 +150,16 @@ endif()
target_include_directories(${TARGET_NAME} PRIVATE src ${DOCSTRINGS_INCLUDE_PLACEHOLDER_DIR})

# Link with libraries
target_link_libraries(${TARGET_NAME}
PUBLIC
target_link_libraries(${TARGET_NAME}
PUBLIC
# pybind11
pybind11::pybind11
depthai::core # Use non-opencv target as we use opencv-python in bindings
hedley
)

# Add default commit hash ('dev') if not build by CI
if(NOT DEFINED ENV{CI} AND NOT DEPTHAI_PYTHON_COMMIT_HASH)
if(NOT DEFINED ENV{CI} AND NOT DEPTHAI_PYTHON_COMMIT_HASH)
set(DEPTHAI_PYTHON_COMMIT_HASH "dev")
endif()

Expand Down
3 changes: 0 additions & 3 deletions cmake/pybind11-mkdoc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,4 @@ function(pybind11_mkdoc_setup_internal target output_path mkdoc_headers enforce)
# Force target build
file(TOUCH_NOCREATE ${mkdoc_headers})

# Add dependency to mkdoc target (makes sure that mkdoc is executed, and docstrings available)
add_dependencies(${target} ${PYBIND11_MKDOC_TARGET_NAME})

endfunction()
2 changes: 1 addition & 1 deletion depthai-core
Submodule depthai-core updated 39 files
+1 −1 cmake/Depthai/DepthaiDeviceSideConfig.cmake
+7 −6 examples/CMakeLists.txt
+1 −3 examples/src/camera_mobilenet_example.cpp
+0 −1 examples/src/camera_mobilenet_sync_example.cpp
+12 −2 examples/src/camera_preview_example.cpp
+1 −3 examples/src/camera_video_example.cpp
+1 −4 examples/src/color_camera_control_example.cpp
+1 −3 examples/src/device_queue_event_example.cpp
+1 −3 examples/src/h264_encoding_example.cpp
+0 −1 examples/src/image_manip_example.cpp
+0 −1 examples/src/image_manip_warp_example.cpp
+1 −3 examples/src/mjpeg_encoding_example.cpp
+1 −3 examples/src/mobilenet_device_side_decoding_example.cpp
+1 −3 examples/src/mono_camera_example.cpp
+1 −3 examples/src/object_tracker_example.cpp
+1 −4 examples/src/opencv_support_example.cpp
+1 −2 examples/src/rgb_depth_aligned_example.cpp
+1 −2 examples/src/spatial_location_calculator_example.cpp
+4 −5 examples/src/spatial_mobilenet_example.cpp
+4 −5 examples/src/spatial_mobilenet_mono_example.cpp
+1 −3 examples/src/spatial_object_tracker_example.cpp
+4 −5 examples/src/spatial_tiny_yolo_example.cpp
+1 −2 examples/src/stereo_example.cpp
+2 −2 examples/src/system_information_example.cpp
+1 −3 examples/src/tiny_yolo_v3_device_side_decoding_example.cpp
+1 −3 examples/src/tiny_yolo_v4_device_side_decoding_example.cpp
+0 −2 examples/src/webcam_mobilenet_example.cpp
+72 −6 include/depthai/device/Device.hpp
+13 −0 include/depthai/pipeline/Pipeline.hpp
+9 −3 include/depthai/pipeline/node/DetectionNetwork.hpp
+5 −4 include/depthai/pipeline/node/NeuralNetwork.hpp
+8 −2 include/depthai/pipeline/node/SpatialDetectionNetwork.hpp
+149 −48 src/device/Device.cpp
+17 −10 src/pipeline/Pipeline.cpp
+12 −0 src/pipeline/node/DetectionNetwork.cpp
+12 −0 src/pipeline/node/SpatialDetectionNetwork.cpp
+0 −1 tests/src/color_camera_node_test.cpp
+0 −1 tests/src/image_manip_node_test.cpp
+2 −2 tests/src/neural_network_test.cpp
13 changes: 12 additions & 1 deletion docs/ci.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,16 @@ set(project_root "${CMAKE_CURRENT_LIST_DIR}/..")
# Get buildCommitHash for non release build
execute_process(COMMAND "git" "rev-parse" "HEAD" WORKING_DIRECTORY ${project_root} OUTPUT_VARIABLE buildCommitHash OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(COMMAND ${CMAKE_COMMAND} -D DEPTHAI_PYTHON_COMMIT_HASH:STRING=${buildCommitHash} -D DEPTHAI_PYTHON_BUILD_DOCS:BOOL=YES -D DEPTHAI_BUILD_DOCS:BOOL=YES -S . -B build WORKING_DIRECTORY ${project_root} COMMAND_ECHO STDOUT)
# Configure
execute_process(COMMAND ${CMAKE_COMMAND}
-D DEPTHAI_PYTHON_COMMIT_HASH:STRING=${buildCommitHash}
-D DEPTHAI_PYTHON_BUILD_DOCS:BOOL=YES
-D DEPTHAI_BUILD_DOCS:BOOL=YES
-D DEPTHAI_PYTHON_BUILD_DOCSTRINGS:BOOL=YES
-D DEPTHAI_PYTHON_FORCE_DOCSTRINGS:BOOL=YES
-S . -B build
WORKING_DIRECTORY ${project_root} COMMAND_ECHO STDOUT
)

# Build
execute_process(COMMAND ${CMAKE_COMMAND} --build build --parallel 4 WORKING_DIRECTORY ${project_root} COMMAND_ECHO STDOUT)
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ sphinx-tabs==1.3.0
sphinx-rtd-theme==0.5.2
git+https://github.com/VanDavv/rtd-redirects.git@3e7333898acad533b37c9de426f1f2ef258d756b
breathe==4.26.0
git+https://github.com/luxonis/pybind11_mkdoc.git@master
Sphinx-Substitution-Extensions==2020.9.30.0
sphinx-autopackagesummary==1.3
autodocsumm==0.2.2
pathlib==1.0.1
-r ./requirements_mkdoc.txt
1 change: 1 addition & 0 deletions docs/requirements_mkdoc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git+https://github.com/luxonis/pybind11_mkdoc.git@47a353ae22a3ca2fe1ca47f47b38613dcfb1043b
10 changes: 5 additions & 5 deletions examples/01_rgb_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
# Define a source - color camera
camRgb = pipeline.createColorCamera()
camRgb.setPreviewSize(300, 300)
camRgb.setBoardSocket(dai.CameraBoardSocket.RGB)
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
camRgb.setInterleaved(False)
camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)

Expand All @@ -19,10 +17,12 @@
xoutRgb.setStreamName("rgb")
camRgb.preview.link(xoutRgb.input)

# Pipeline is defined, now we can connect to the device
with dai.Device(pipeline) as device:
# Connect to the device
with dai.Device() as device:
# Print out available cameras
print('Connected cameras: ', device.getConnectedCameras())
# Start pipeline
device.startPipeline()
device.startPipeline(pipeline)

# Output queue will be used to get the rgb frames from the output defined above
qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
Expand Down
4 changes: 1 addition & 3 deletions examples/02_mono_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
xoutRight.setStreamName('right')
camRight.out.link(xoutRight.input)

# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

# Output queues will be used to get the grayscale frames from the outputs defined above
qLeft = device.getOutputQueue(name="left", maxSize=4, blocking=False)
Expand Down
4 changes: 1 addition & 3 deletions examples/03_depth_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@
xout.setStreamName("disparity")
depth.disparity.link(xout.input)

# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

# Output queue will be used to get the disparity frames from the outputs defined above
q = device.getOutputQueue(name="disparity", maxSize=4, blocking=False)
Expand Down
4 changes: 1 addition & 3 deletions examples/04_rgb_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
videoOut.setStreamName('h265')
videoEncoder.bitstream.link(videoOut.input)

# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

# Output queue will be used to get the encoded data from the output defined above
q = device.getOutputQueue(name="h265", maxSize=30, blocking=True)
Expand Down
4 changes: 1 addition & 3 deletions examples/05_rgb_mono_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
ve3.bitstream.link(ve3Out.input)


# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as dev:
# Start pipeline
dev.startPipeline()

# Output queues will be used to get the encoded data from the outputs defined above
outQ1 = dev.getOutputQueue(name='ve1Out', maxSize=30, blocking=True)
Expand Down
4 changes: 1 addition & 3 deletions examples/06_rgb_full_resolution_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
videoEnc.bitstream.link(xoutJpeg.input)


# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

# Output queue will be used to get the rgb frames from the output defined above
qRgb = device.getOutputQueue(name="rgb", maxSize=30, blocking=False)
Expand Down
4 changes: 1 addition & 3 deletions examples/07_mono_full_resolution_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
xoutRight.setStreamName("right")
camRight.out.link(xoutRight.input)

# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

# Output queue will be used to get the grayscale frames from the output defined above
qRight = device.getOutputQueue(name="right", maxSize=4, blocking=False)
Expand Down
4 changes: 1 addition & 3 deletions examples/08_rgb_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]


# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

# Output queues will be used to get the rgb frames and nn data from the outputs defined above
qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
Expand Down
4 changes: 1 addition & 3 deletions examples/09_mono_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@
labelMap = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow",
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]

# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

# Output queues will be used to get the grayscale frames and nn data from the outputs defined above
qRight = device.getOutputQueue("right", maxSize=4, blocking=False)
Expand Down
4 changes: 1 addition & 3 deletions examples/10_mono_depth_mobilenetssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@
labelMap = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow",
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]

# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

# Output queues will be used to get the grayscale / depth frames and nn data from the outputs defined above
qRight = device.getOutputQueue("rectifiedRight", maxSize=4, blocking=False)
Expand Down
4 changes: 1 addition & 3 deletions examples/11_rgb_encoding_mono_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]


# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

queue_size = 8
qRight = device.getOutputQueue("right", queue_size)
Expand Down
4 changes: 1 addition & 3 deletions examples/12_rgb_encoding_mono_mobilenet_depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]


# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as device:
# Start pipeline
device.startPipeline()

queueSize = 8
qRight = device.getOutputQueue("right", queueSize)
Expand Down
5 changes: 1 addition & 4 deletions examples/13_encoding_max_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@
ve3.bitstream.link(ve3Out.input)


# Pipeline is defined, now we can connect to the device
# Connect and start the pipeline
with dai.Device(pipeline) as dev:

# Prepare data queues
outQ1 = dev.getOutputQueue('ve1Out', maxSize=30, blocking=True)
outQ2 = dev.getOutputQueue('ve2Out', maxSize=30, blocking=True)
outQ3 = dev.getOutputQueue('ve3Out', maxSize=30, blocking=True)

# Start the pipeline
dev.startPipeline()

# Processing loop
with open('mono1.h264', 'wb') as fileMono1H264, open('color.h265', 'wb') as fileColorH265, open('mono2.h264', 'wb') as fileMono2H264:
print("Press Ctrl+C to stop encoding...")
Expand Down
Loading

0 comments on commit 96386f5

Please sign in to comment.