Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Porting host nodes to depthai-nodes #631

Merged
merged 22 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fced058
feat: port OverlayFrames to depthai_nodes
jkbmrz Mar 18, 2025
f3c1cd3
feat: remove density_map_resize_node
jkbmrz Mar 18, 2025
c4cca05
feat: import density map colorization from depthai_nodes
jkbmrz Mar 18, 2025
60e408e
feat: remove DensityMapToFrame node
jkbmrz Mar 18, 2025
bd46820
feat: remove custom host nodes from generic experiment
jkbmrz Mar 18, 2025
e59b95b
feat: switch OverlayFrames with ImgFrameOverlay
jkbmrz Mar 28, 2025
7e02ab4
feat: face-mask-detection switch to ImgDetectionsFilter host node
jkbmrz Mar 28, 2025
372fe47
feat: crestereo-stereo-matching switch to ApplyColormap
jkbmrz Apr 2, 2025
a0c5412
feat: human-machine-safety switch to ImgDetectionsFilter host node
jkbmrz Apr 2, 2025
20d6bca
feat: human-machine-safety switch to ImgDetectionsBridge host node
jkbmrz Apr 2, 2025
448f0e2
feat: people-tracker switch to ImgDetectionsBridge host node
jkbmrz Apr 2, 2025
3485d2a
fix: pre-commit
jkbmrz Apr 2, 2025
a014069
feat: add .setNNArchive() notes for running on OAK-D Lite
jkbmrz Apr 3, 2025
33c7915
fix: pre-commit
jkbmrz Apr 3, 2025
59dfa3b
crestereo depth color transform node replace
dominik737 Jan 31, 2025
af52231
default app use depth color transform node
dominik737 Jan 31, 2025
7276f04
calc spatial on host
dominik737 Jan 31, 2025
d6a830a
camera demo use depth color transform node
dominik737 Jan 31, 2025
8ee9f2c
feat: switch DepthColorTransform for ApplyColormap
jkbmrz Apr 8, 2025
1898ea6
feat: depth-driven-focus change DepthColorTransform for ApplyColormap…
jkbmrz Apr 8, 2025
2a42bd2
Merge branch 'ref/gen3/depth-color-transform-replace' into feat/porti…
jkbmrz Apr 8, 2025
1edf6ab
fix: remove irrelevant definition of DepthColorTransform
jkbmrz Apr 8, 2025
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
5 changes: 3 additions & 2 deletions apps/default-app/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import cv2
import depthai as dai
from depthai_nodes.node import DepthColorTransform
from depthai_nodes.node import ApplyColormap
from typing import Optional
from utils.arguments import initialize_argparser

Expand Down Expand Up @@ -73,6 +73,7 @@
cam_mono_2 = feature.socket
break
if cam_mono_1 and cam_mono_2:
device.setIrLaserDotProjectorIntensity(1)
left_cam = pipeline.create(dai.node.Camera).build(cam_mono_1)
right_cam = pipeline.create(dai.node.Camera).build(cam_mono_2)
stereo = pipeline.create(dai.node.StereoDepth).build(
Expand All @@ -84,7 +85,7 @@
if platform == dai.Platform.RVC2:
stereo.setOutputSize(*STEREO_RESOLUTION)

coloredDepth = pipeline.create(DepthColorTransform).build(stereo.disparity)
coloredDepth = pipeline.create(ApplyColormap).build(stereo.disparity)
coloredDepth.setColormap(cv2.COLORMAP_JET)
visualizer.addTopic("Depth", coloredDepth.out)

Expand Down
9 changes: 4 additions & 5 deletions camera-controls/depth-driven-focus/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import depthai as dai
from depthai_nodes.node import ParsingNeuralNetwork
from depthai_nodes.node import ParsingNeuralNetwork, ApplyColormap
from util.arguments import initialize_argparser
from util.depth_color_transform import DepthColorTransform
from util.depth_driven_focus import DepthDrivenFocus
from util.depth_merger import DepthMerger

Expand Down Expand Up @@ -44,8 +43,8 @@
depth_merger = pipeline.create(DepthMerger).build(
face_det_nn.out, stereo.depth, device.readCalibration2()
)
depth_color_transform = pipeline.create(DepthColorTransform).build(stereo.disparity)
depth_color_transform.setMaxDisparity(stereo.initialConfig.getMaxDisparity())
depth_color_transform = pipeline.create(ApplyColormap).build(stereo.disparity)
depth_color_transform.setMaxValue(int(stereo.initialConfig.getMaxDisparity()))

depth_driven_focus = pipeline.create(DepthDrivenFocus).build(
control_queue=cam.inputControl.createInputQueue(),
Expand All @@ -54,7 +53,7 @@

visualizer.addTopic("Video", color_out, "images")
visualizer.addTopic("Visualizations", face_det_nn.out, "images")
visualizer.addTopic("Depth", depth_color_transform.output, "images")
visualizer.addTopic("Depth", depth_color_transform.out, "images")
visualizer.addTopic("Focus distance", depth_driven_focus.output, "images")

print("Pipeline created.")
Expand Down
45 changes: 0 additions & 45 deletions camera-controls/depth-driven-focus/util/depth_color_transform.py

This file was deleted.

12 changes: 5 additions & 7 deletions depth-measurement/calc-spatial-on-host/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import cv2
import depthai as dai
from calc import HostSpatialsCalc
from depthai_nodes.node import ApplyColormap
from host_node.measure_distance import MeasureDistance
from host_node.host_depth_color_transform import DepthColorTransform
from host_node.host_display import Display
from host_node.keyboard_reader import KeyboardReader

Expand All @@ -23,23 +23,21 @@
)

stereo = pipeline.create(dai.node.StereoDepth).build(
monoLeft, monoRight, presetMode=dai.node.StereoDepth.PresetMode.HIGH_ACCURACY
monoLeft, monoRight, presetMode=dai.node.StereoDepth.PresetMode.DEFAULT
)

depth_color_transform = pipeline.create(DepthColorTransform).build(stereo.disparity)
depth_color_transform = pipeline.create(ApplyColormap).build(stereo.disparity)
depth_color_transform.setColormap(cv2.COLORMAP_JET)

keyboard_reader = pipeline.create(KeyboardReader).build(
depth_color_transform.output
)
keyboard_reader = pipeline.create(KeyboardReader).build(depth_color_transform.out)

measure_distance = pipeline.create(MeasureDistance).build(
stereo.depth, device.readCalibration(), HostSpatialsCalc.INITIAL_ROI
)

calibdata = device.readCalibration()
spatials = pipeline.create(HostSpatialsCalc).build(
disparity_frames=depth_color_transform.output,
disparity_frames=depth_color_transform.out,
measured_depth=measure_distance.output,
keyboard_input=keyboard_reader.output,
)
Expand Down
7 changes: 3 additions & 4 deletions depth-measurement/calc-spatial-on-host/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
--extra-index-url https://artifacts.luxonis.com/artifactory/luxonis-python-release-local/
depthai~=3.0.0a4
opencv-python==4.10.0.84
numpy>=1.22
opencv-python
numpy~=2.0
depthai==3.0.0a12
19 changes: 7 additions & 12 deletions neural-networks/counting/crowdcounting/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pathlib import Path
import depthai as dai
from depthai_nodes.node import ParsingNeuralNetwork
from depthai_nodes.node import ImgFrameOverlay
from depthai_nodes.node import ApplyColormap

from utils.arguments import initialize_argparser
from utils.counter import CrowdCounter
from utils.density_map_transform import DensityMapToFrame
from utils.overlay import OverlayFrames

_, args = initialize_argparser()

Expand Down Expand Up @@ -48,21 +48,16 @@
# Counter Node
crowd_counter_node = pipeline.create(CrowdCounter).build(nn.out)

# Density Map Transform and Resize Nodes
density_map_transform_node = pipeline.create(DensityMapToFrame).build(nn.out)
density_map_resize_node = pipeline.create(dai.node.ImageManipV2)
density_map_resize_node.setMaxOutputFrameSize(INPUT_WIDTH * INPUT_HEIGHT * 3)
density_map_resize_node.initialConfig.setOutputSize(INPUT_WIDTH, INPUT_HEIGHT)
density_map_resize_node.initialConfig.setFrameType(frame_type)
density_map_transform_node.output.link(density_map_resize_node.inputImage)
density_map_transform_node = pipeline.create(ApplyColormap).build(nn.out)

# Overlay Frames Node
overlay_frames = pipeline.create(OverlayFrames).build(
nn.passthrough, density_map_resize_node.out
overlay_frames = pipeline.create(ImgFrameOverlay).build(
nn.passthrough,
density_map_transform_node.out,
)

# Visualizer
visualizer.addTopic("VideoOverlay", overlay_frames.output)
visualizer.addTopic("VideoOverlay", overlay_frames.out)
visualizer.addTopic("Count", crowd_counter_node.output)

print("Pipeline created.")
Expand Down

This file was deleted.

56 changes: 0 additions & 56 deletions neural-networks/counting/crowdcounting/utils/overlay.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import argparse
import cv2
import depthai as dai
from depthai_nodes.node import ParsingNeuralNetwork
from utils.host_depth_color_transform import DepthColorTransform
from depthai_nodes.node import ParsingNeuralNetwork, ApplyColormap

device = dai.Device()
platform = device.getPlatform()
Expand Down Expand Up @@ -86,10 +85,10 @@
demux.outputs["left"].link(nn.inputs["left"])
demux.outputs["right"].link(nn.inputs["right"])

disparity_coloring = pipeline.create(DepthColorTransform).build(stereo.disparity)
disparity_coloring = pipeline.create(ApplyColormap).build(stereo.disparity)
disparity_coloring.setColormap(cv2.COLORMAP_PLASMA)

visualizer.addTopic("Stereo Disparity", disparity_coloring.output)
visualizer.addTopic("Stereo Disparity", disparity_coloring.out)
visualizer.addTopic("NN", nn.out)

print("Pipeline created.")
Expand Down

This file was deleted.

9 changes: 4 additions & 5 deletions neural-networks/facial-detection/face-mask-detection/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from pathlib import Path
import depthai as dai
from depthai_nodes.node import ParsingNeuralNetwork
from depthai_nodes.node import ParsingNeuralNetwork, ImgDetectionsFilter
from utils.arguments import initialize_argparser
from utils.filter import FilterDetections

_, args = initialize_argparser()

Expand Down Expand Up @@ -46,11 +45,11 @@
input_node, nn_archive, fps=args.fps_limit
)

det_process_node = pipeline.create(FilterDetections).build(nn_with_parser.out)
det_process_node.set_label_encoding(LABEL_ENCODING)
det_process_node = pipeline.create(ImgDetectionsFilter).build(nn_with_parser.out)
det_process_node.setLabels(list(LABEL_ENCODING.keys()), keep=True)

visualizer.addTopic("Video", nn_with_parser.passthrough, "images")
visualizer.addTopic("Detections", det_process_node.output, "detections")
visualizer.addTopic("Detections", det_process_node.out, "detections")

print("Pipeline created.")

Expand Down
Loading