Skip to content
Merged
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
4 changes: 4 additions & 0 deletions examples/08_rgb_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
parser.add_argument('-s', '--sync', action="store_true", help="Sync RGB output with NN output", default=False)
args = parser.parse_args()

if not Path(nnPathDefault).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()

Expand Down
3 changes: 3 additions & 0 deletions examples/09_mono_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()
Expand Down
3 changes: 3 additions & 0 deletions examples/10_mono_depth_mobilenetssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()
Expand Down
3 changes: 3 additions & 0 deletions examples/11_rgb_encoding_mono_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

pipeline = dai.Pipeline()

Expand Down
3 changes: 3 additions & 0 deletions examples/12_rgb_encoding_mono_mobilenet_depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

pipeline = dai.Pipeline()

Expand Down
4 changes: 4 additions & 0 deletions examples/15_rgb_mobilenet_4k.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()

Expand Down
9 changes: 7 additions & 2 deletions examples/17_video_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
from time import monotonic

# Get argument first
nnPath = str((Path(__file__).parent / Path('models/mobilenet-ssd_openvino_2021.2_8shave.blob')).resolve().absolute())
videoPath = str(Path("./construction_vest.mp4").resolve().absolute())
parentDir = Path(__file__).parent
nnPath = str((parentDir / Path('models/mobilenet-ssd_openvino_2021.2_8shave.blob')).resolve().absolute())
videoPath = str((parentDir / Path('models/construction_vest.mp4')).resolve().absolute())
if len(sys.argv) > 2:
nnPath = sys.argv[1]
videoPath = sys.argv[2]

if not Path(nnPath).exists() or not Path(videoPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()

Expand Down
3 changes: 3 additions & 0 deletions examples/18_rgb_encoding_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

pipeline = dai.Pipeline()

Expand Down
4 changes: 4 additions & 0 deletions examples/22_1_tiny_yolo_v3_device_side_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()

Expand Down
4 changes: 4 additions & 0 deletions examples/22_2_tiny_yolo_v4_device_side_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()

Expand Down
6 changes: 5 additions & 1 deletion examples/23_autoexposure_roi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
# Press N to go back to the region controlled by the NN detections.

# Get argument first
nnPath = str((Path(__file__).parent / Path('models/mobilenet-ssd_openvino_2021.2_5shave.blob')).resolve().absolute())
nnPath = str((Path(__file__).parent / Path('models/mobilenet-ssd_openvino_2021.2_6shave.blob')).resolve().absolute())
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

previewSize = (300, 300)

# Start defining a pipeline
Expand Down
4 changes: 4 additions & 0 deletions examples/26_1_spatial_mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
if len(sys.argv) > 1:
nnBlobPath = sys.argv[1]

if not Path(nnBlobPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()

Expand Down
4 changes: 4 additions & 0 deletions examples/26_2_spatial_mobilenet_mono.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
if len(sys.argv) > 1:
nnPath = sys.argv[1]

if not Path(nnPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()

Expand Down
4 changes: 4 additions & 0 deletions examples/26_3_spatial_tiny_yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
if len(sys.argv) > 1:
nnBlobPath = sys.argv[1]

if not Path(nnBlobPath).exists():
import sys
raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

# Start defining a pipeline
pipeline = dai.Pipeline()

Expand Down
2 changes: 1 addition & 1 deletion examples/29_3_object_tracker_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

labelMap = ["person", ""]

nnPathDefault = str((Path(__file__).parent / Path('models/person-detection_openvino_2021.2_7shave.blob')).resolve().absolute())
nnPathDefault = str((Path(__file__).parent / Path('models/person-detection-0201_openvino_2021.3_7shave.blob')).resolve().absolute())
videoPathDefault = str((Path(__file__).parent / Path('models/construction_vest.mp4')).resolve().absolute())
parser = argparse.ArgumentParser()
parser.add_argument('-nnPath', help="Path to mobilenet detection network blob", default=nnPathDefault)
Expand Down
114 changes: 41 additions & 73 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ if(UNIX)
set(SYS_PATH_SEPARATOR ":")
endif()

add_custom_target(install_requirements
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/install_requirements.py" "--skip_depthai"
DEPENDS ${TARGET_NAME}
VERBATIM
COMMAND_EXPAND_LISTS
)

# Macro for adding new python test
macro(add_python_example example_name python_script_path)
Expand All @@ -29,7 +35,7 @@ macro(add_python_example example_name python_script_path)
"${ASAN_ENVIRONMENT_VARS}"
# Example
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/${python_script_path} ${ARGN}
DEPENDS ${TARGET_NAME}
DEPENDS ${TARGET_NAME} install_requirements
VERBATIM
COMMAND_EXPAND_LISTS
)
Expand All @@ -55,62 +61,24 @@ macro(add_python_example example_name python_script_path)

endmacro()

# Mobilenet resource
hunter_private_data(
URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.2_6shave.blob"
SHA1 "f0e14978b3f77a4f93b9f969cd39e58bb7aef490"
FILE "mobilenet-ssd_openvino_2021.2_6shave.blob"
LOCATION mobilenet_blob
)

# Mobilenet resource
hunter_private_data(
URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.2_5shave.blob"
SHA1 "d715f85e474609cf3f696d7a2e3750804ed6c726"
FILE "mobilenet-ssd_openvino_2021.2_5shave.blob"
LOCATION mobilenet_5shave_blob
)

# Construction vest video resource
hunter_private_data(
URL "http://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/construction_vest.mp4"
SHA1 "271d8d0b702e683ce02957db7c100843de5ceaec"
FILE "construction_vest.mp4"
LOCATION construction_vest
)

# tiny-YoloV3 neural network resource
hunter_private_data(
URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/tiny-yolo-v3_openvino_2021.2_6shave.blob"
SHA1 "f0ac263a0d55c374e1892eea21c9b7d1170bde46"
FILE "tiny-yolo-v3_openvino_2021.2_6shave.blob"
LOCATION tiny_yolo_v3_blob
)

# tiny-YoloV4 neural network resource
hunter_private_data(
URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/tiny-yolo-v4_openvino_2021.2_6shave.blob"
SHA1 "219d949610a5760e62a8458941e1300b81c3fe4a"
FILE "tiny-yolo-v4_openvino_2021.2_6shave.blob"
LOCATION tiny_yolo_v4_blob
)
if(DEPTHAI_PYTHON_TEST_EXAMPLES)

# NeuralNetwork node, mobilenet example, 8 shaves
hunter_private_data(
URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.2_8shave.blob"
SHA1 "3329bb8f3a9c881ef9756d232055f9d6f38aa07b"
FILE "mobilenet-ssd_openvino_2021.2_8shave.blob"
LOCATION mobilenet_8shaves_blob
)
# Adds install requirements test with 5 minute timeout
add_test(NAME install_requirements COMMAND
${CMAKE_COMMAND} -E env
# Python path (to find compiled module)
"PYTHONPATH=$<TARGET_FILE_DIR:${TARGET_NAME}>${SYS_PATH_SEPARATOR}$ENV{PYTHONPATH}"
# ASAN in case of sanitizers
${ASAN_ENVIRONMENT_VARS}
${CMAKE_COMMAND} -DTIMEOUT_SECONDS=300 -P ${CMAKE_CURRENT_LIST_DIR}/cmake/ExecuteTestTimeout.cmake
# Actual script to run
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/install_requirements.py" "--skip_depthai"
)

# Object tracker person detection
hunter_private_data(
URL "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/person-detection-0201_openvino_2021.3_7shave.blob"
SHA1 "a8d4b0067deb889ec66b2204573d9ee1e0039c8e"
FILE "person-detection-0201_openvino_2021.3_7shave.blob"
LOCATION person_detection_7shaves_blob
)
# Sets a regex catching any logged warnings, errors or critical (coming either from device or host)
set_tests_properties (install_requirements PROPERTIES FAIL_REGULAR_EXPRESSION "\\[warning\\];\\[error\\];\\[critical\\]")

endif()

# Add examples
add_python_example(01_rgb_preview 01_rgb_preview.py)
Expand All @@ -120,33 +88,33 @@ add_python_example(04_rgb_encoding 04_rgb_encoding.py)
add_python_example(05_rgb_mono_encoding 05_rgb_mono_encoding.py)
add_python_example(06_rgb_full_resolution_saver 06_rgb_full_resolution_saver.py)
add_python_example(07_mono_full_resolution_saver 07_mono_full_resolution_saver.py)
add_python_example(08_rgb_mobilenet 08_rgb_mobilenet.py "${mobilenet_blob}")
add_python_example(09_mono_mobilenet 09_mono_mobilenet.py "${mobilenet_blob}")
add_python_example(10_mono_depth_mobilenetssd 10_mono_depth_mobilenetssd.py "${mobilenet_blob}")
add_python_example(11_rgb_encoding_mono_mobilenet 11_rgb_encoding_mono_mobilenet.py "${mobilenet_blob}")
add_python_example(12_rgb_encoding_mono_mobilenet_depth 12_rgb_encoding_mono_mobilenet_depth.py "${mobilenet_blob}")
add_python_example(08_rgb_mobilenet 08_rgb_mobilenet.py)
add_python_example(09_mono_mobilenet 09_mono_mobilenet.py)
add_python_example(10_mono_depth_mobilenetssd 10_mono_depth_mobilenetssd.py)
add_python_example(11_rgb_encoding_mono_mobilenet 11_rgb_encoding_mono_mobilenet.py)
add_python_example(12_rgb_encoding_mono_mobilenet_depth 12_rgb_encoding_mono_mobilenet_depth.py)
add_python_example(13_encoding_max_limit 13_encoding_max_limit.py)
add_python_example(14_1_color_camera_control 14_1_color_camera_control.py)
add_python_example(14_2_mono_camera_control 14_2_mono_camera_control.py)
add_python_example(14_3_depth_crop_control 14_3_depth_crop_control.py)
add_python_example(15_rgb_mobilenet_4k 15_rgb_mobilenet_4k.py "${mobilenet_5shave_blob}")
add_python_example(15_rgb_mobilenet_4k 15_rgb_mobilenet_4k.py)
add_python_example(16_device_queue_event 16_device_queue_event.py)
add_python_example(17_video_mobilenet 17_video_mobilenet.py "${mobilenet_8shaves_blob}" "${construction_vest}")
add_python_example(18_rgb_encoding_mobilenet 18_rgb_encoding_mobilenet.py "${mobilenet_blob}")
add_python_example(17_video_mobilenet 17_video_mobilenet.py)
add_python_example(18_rgb_encoding_mobilenet 18_rgb_encoding_mobilenet.py)
add_python_example(19_mono_camera_control 19_mono_camera_control.py)
add_python_example(20_color_rotate_warp 20_color_rotate_warp.py)
add_python_example(21_mobilenet_device_side_decoding 21_mobilenet_device_side_decoding.py "${mobilenet_blob}")
add_python_example(22_1_tiny_yolo_v3_device_side_decoding 22_1_tiny_yolo_v3_device_side_decoding.py "${tiny_yolo_v3_blob}")
add_python_example(22_2_tiny_yolo_v4_device_side_decoding 22_2_tiny_yolo_v4_device_side_decoding.py "${tiny_yolo_v4_blob}")
add_python_example(23_autoexposure_roi 23_autoexposure_roi.py "${mobilenet_blob}")
add_python_example(21_mobilenet_device_side_decoding 21_mobilenet_device_side_decoding.py)
add_python_example(22_1_tiny_yolo_v3_device_side_decoding 22_1_tiny_yolo_v3_device_side_decoding.py)
add_python_example(22_2_tiny_yolo_v4_device_side_decoding 22_2_tiny_yolo_v4_device_side_decoding.py)
add_python_example(23_autoexposure_roi 23_autoexposure_roi.py)
add_python_example(24_opencv_support 24_opencv_support.py)
add_python_example(25_system_information 25_system_information.py)
add_python_example(26_1_spatial_mobilenet 26_1_spatial_mobilenet.py "${mobilenet_blob}")
add_python_example(26_2_spatial_mobilenet_mono 26_2_spatial_mobilenet_mono.py "${mobilenet_blob}")
add_python_example(26_3_spatial_tiny_yolo_v3 26_3_spatial_tiny_yolo.py "${tiny_yolo_v3_blob}")
add_python_example(26_3_spatial_tiny_yolo_v4 26_3_spatial_tiny_yolo.py "${tiny_yolo_v4_blob}")
add_python_example(26_1_spatial_mobilenet 26_1_spatial_mobilenet.py)
add_python_example(26_2_spatial_mobilenet_mono 26_2_spatial_mobilenet_mono.py)
add_python_example(26_3_spatial_tiny_yolo_v3 26_3_spatial_tiny_yolo.py)
add_python_example(26_3_spatial_tiny_yolo_v4 26_3_spatial_tiny_yolo.py)
add_python_example(27_spatial_location_calculator 27_spatial_location_calculator.py)
add_python_example(28_camera_video_example 28_camera_video_example.py)
add_python_example(29_1_object_tracker 29_1_object_tracker.py "${mobilenet_blob}")
add_python_example(29_2_spatial_object_tracker 29_2_spatial_object_tracker.py "${mobilenet_blob}")
add_python_example(29_3_object_tracker_video 29_3_object_tracker_video.py "-nnPath" "${person_detection_7shaves_blob}" "-v" "${construction_vest}")
add_python_example(29_1_object_tracker 29_1_object_tracker.py)
add_python_example(29_2_spatial_object_tracker 29_2_spatial_object_tracker.py)
add_python_example(29_3_object_tracker_video 29_3_object_tracker_video.py)
5 changes: 5 additions & 0 deletions examples/downloader/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!common.py
!converter.py
!downloader.py
!.gitignore
Loading