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

Release depthai-nodes v0.0.2 #98

Closed
wants to merge 110 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
4039a91
Added labeler to CI (#43)
klemen1999 Sep 2, 2024
5f755d3
Updated requirements.txt (#44)
klemen1999 Sep 2, 2024
1168441
Added coverage badge to README (#45)
klemen1999 Sep 2, 2024
29a4c33
Added package version (#46)
klemen1999 Sep 2, 2024
c8b1bfb
Update ci.yaml
kozlov721 Sep 2, 2024
afbb73b
[Automated] Updated coverage badge
actions-user Sep 2, 2024
c44fc71
Merge pull request #47 from luxonis/kozlov721-patch-1
kozlov721 Sep 2, 2024
a3f03fd
Update README.md
klemen1999 Sep 3, 2024
ae8f1fb
YOLOv8 kpts and seg example. (#48)
kkeroo Sep 3, 2024
d33cad2
Extend MPPalmDetection parser. (#49)
kkeroo Sep 3, 2024
f6c0b46
feat: add support for metric depth
jkbmrz Sep 3, 2024
0a3c2a3
fix: broken depth tests
jkbmrz Sep 3, 2024
6f96c4b
fix: pre-commit
jkbmrz Sep 3, 2024
180740e
fix: change default depth limit to float
jkbmrz Sep 3, 2024
fbed8e9
feat: add test for metric depth map
jkbmrz Sep 3, 2024
5c0d70d
Developer guide docs added. (#51)
kkeroo Sep 4, 2024
53e0ef1
Merge pull request #50 from luxonis/feat/add_metric_depth_support
jkbmrz Sep 4, 2024
3a551ea
Support for metrics depth type. (#52)
kkeroo Sep 4, 2024
db9c519
Hotfix: remove no-commit from pre-commit (#54)
klemen1999 Sep 4, 2024
6448b1c
Added automatic PyPI publishing (#55)
klemen1999 Sep 4, 2024
c2a42f8
feat: add parser for DM-Count crowd density estimation model
jkbmrz Sep 4, 2024
5ff8582
fix: pre-commit
jkbmrz Sep 4, 2024
6692b53
fix: add missing imports
jkbmrz Sep 4, 2024
fb0ec0d
feat: add property methods to Map2D message
jkbmrz Sep 5, 2024
6191b41
fix: density map dimensions
jkbmrz Sep 5, 2024
9d0d34c
fix: pre-commit
jkbmrz Sep 5, 2024
256d128
Merge pull request #56 from luxonis/feat/mdcount_parser
jkbmrz Sep 6, 2024
4262379
feat: unify map parsers
jkbmrz Sep 6, 2024
ec4c413
feat: unify map message creators
jkbmrz Sep 6, 2024
a5fe692
refactor: simplify map message file name
jkbmrz Sep 6, 2024
b772caf
feat: add map tests
jkbmrz Sep 6, 2024
91afa7a
fix: pre-commit
jkbmrz Sep 6, 2024
8419b33
fix: map tests
jkbmrz Sep 6, 2024
d6a7565
fix: map scaling test
jkbmrz Sep 6, 2024
33591db
fix: pre-commit
jkbmrz Sep 6, 2024
59d3220
[Automated] Updated coverage badge
actions-user Sep 6, 2024
82a44c6
feat: remove thermal image parser and creator
jkbmrz Sep 9, 2024
0104416
feat: remove thermal image tests
jkbmrz Sep 9, 2024
6d7c1e5
fix: remove imports of the deleted objects
jkbmrz Sep 9, 2024
ea6dae4
[Automated] Updated coverage badge
actions-user Sep 9, 2024
9aa4881
fix: create_map_message output type hint
jkbmrz Sep 9, 2024
6da850e
fix: pre-commit
jkbmrz Sep 9, 2024
f216c3f
Merge pull request #57 from luxonis/feat/unify_mapping_models_support
jkbmrz Sep 9, 2024
780444a
Adds FastSAM to example. (#58)
kkeroo Sep 9, 2024
d81e669
Extend Segmentation Parser. (#59)
kkeroo Sep 9, 2024
792ba1b
Added PaddlePaddle Text detection model parser.
aljazkonec1 Sep 9, 2024
855ae07
Added Parser to __init__
aljazkonec1 Sep 9, 2024
c31cbbe
Fixes Shape Error bug
aljazkonec1 Sep 9, 2024
6619b8b
Merge branch 'dev' into paddle-text-detection-parser
aljazkonec1 Sep 9, 2024
3cfe605
pre-commit error
aljazkonec1 Sep 9, 2024
4e23045
[fix] precommit
aljazkonec1 Sep 9, 2024
03905fd
[Automated] Updated coverage badge
actions-user Sep 9, 2024
cb60290
Revision.
aljazkonec1 Sep 10, 2024
7e4fe2f
Remove syntax error
aljazkonec1 Sep 10, 2024
4d73879
Update depthai_nodes/ml/parsers/utils/ppocr.py
klemen1999 Sep 10, 2024
7e8fb22
Renamed some functions.
aljazkonec1 Sep 10, 2024
bf40f37
Merge branch 'paddle-text-detection-parser' of https://github.com/lux…
aljazkonec1 Sep 10, 2024
d419cd0
Removed wrong __init__ imports
aljazkonec1 Sep 10, 2024
d4cea65
PaddleOCR model returns a sequence of classification probabilities fo…
aljazkonec1 Sep 10, 2024
5fbfdd8
[Automated] Updated coverage badge
actions-user Sep 10, 2024
6f78316
Lane detection parser. (#61)
kkeroo Sep 10, 2024
50a237b
Merge branch 'dev' into paddle-text-detection-parser
aljazkonec1 Sep 10, 2024
bd219af
[Automated] Updated coverage badge
actions-user Sep 10, 2024
9cb663a
Merge pull request #60 from luxonis/paddle-text-detection-parser
aljazkonec1 Sep 10, 2024
5583782
Merge branch 'dev' into paddle-ocr-parser
aljazkonec1 Sep 10, 2024
7529fec
PaddleOCR Parser and Classification Sequence message
aljazkonec1 Sep 11, 2024
57b03e3
Added unit tests and modified some assertions
aljazkonec1 Sep 11, 2024
1134c6e
pre-commit fixs
aljazkonec1 Sep 11, 2024
245145a
Doc string fix
aljazkonec1 Sep 11, 2024
f432f02
[Automated] Updated coverage badge
actions-user Sep 11, 2024
8903d81
small fix
aljazkonec1 Sep 11, 2024
d5be207
Merge branch 'paddle-ocr-parser' of https://github.com/luxonis/deptha…
aljazkonec1 Sep 11, 2024
8899a79
Merge pull request #64 from luxonis/paddle-ocr-parser
aljazkonec1 Sep 11, 2024
f80b0ac
[BUG] small bug fix where x_min was not <= x_max
aljazkonec1 Sep 11, 2024
1bbe0c2
Merge pull request #66 from luxonis/corner2xyxy-bug
aljazkonec1 Sep 11, 2024
4c77524
Added VehicleAttribte Parser and tests.
aljazkonec1 Sep 12, 2024
4a5914d
Added docstrings.
aljazkonec1 Sep 12, 2024
fbfcfc8
[Automated] Updated coverage badge
actions-user Sep 13, 2024
ca37f9a
Changed to MultiClassification parser
aljazkonec1 Sep 13, 2024
eee0b3d
[Automated] Updated coverage badge
actions-user Sep 13, 2024
83080fe
Updated docstrings and names
aljazkonec1 Sep 16, 2024
f701cf7
fixed unit-test name
aljazkonec1 Sep 16, 2024
b1d42d5
Updated variable names.
aljazkonec1 Sep 16, 2024
ceac1c8
Merge pull request #67 from luxonis/vehicle-attributes-parser
aljazkonec1 Sep 16, 2024
9757985
Refactor code.
aljazkonec1 Sep 16, 2024
c98abfd
remove AgeGender Message.
aljazkonec1 Sep 17, 2024
13d7d4a
Refactor examples.
aljazkonec1 Sep 17, 2024
a6d34c1
Merge pull request #68 from luxonis/update-parser-locations
aljazkonec1 Sep 17, 2024
b5bd9fe
refactor: separate visualizers and their utils
jkbmrz Sep 17, 2024
9b7426b
refactor: remove mapping.py
jkbmrz Sep 17, 2024
a507e1b
feat: add support for models with 2D map output
jkbmrz Sep 17, 2024
6631d54
fix: add FPS limit to avoid OAK-D Lite errors
jkbmrz Sep 17, 2024
786ebaa
docs: update README.md
jkbmrz Sep 17, 2024
06f5874
fix: pre-commit
jkbmrz Sep 17, 2024
f61e1db
Merge pull request #70 from luxonis/feat/add_map_examples2
jkbmrz Sep 17, 2024
8e6b4ed
[HOT-FIX] Update ppdet to return polygons.
aljazkonec1 Sep 17, 2024
3546c60
[Automated] Updated coverage badge
actions-user Sep 17, 2024
4daa810
Update depthai_nodes/ml/parsers/ppdet.py
aljazkonec1 Sep 17, 2024
a79b8ad
dele one line
aljazkonec1 Sep 17, 2024
7345faa
Merge pull request #71 from luxonis/corner-support-for-ppdet
aljazkonec1 Sep 17, 2024
59a0190
Better error in MPPalmDetectionParser. (#72)
kkeroo Sep 19, 2024
6769aef
Fix RVC4 order (#76)
HonzaCuhel Sep 24, 2024
de544a4
XFeat parser for Mono and Stereo. (#82)
kkeroo Sep 30, 2024
2a312f8
Tiling and TilesPatcher (#89)
spbui00 Oct 2, 2024
9212a21
reformatted docstring in epytext (#92)
spbui00 Oct 2, 2024
3f3e360
Minor release preparation. (#93)
kkeroo Oct 4, 2024
6a44d79
Version bump. (#97)
kkeroo Oct 4, 2024
e4befc4
Remove duplicated.
kkeroo Oct 4, 2024
10fa1f2
Release: Fix merge conflicts (#99)
kkeroo Oct 4, 2024
d163fc4
Merge branch 'dev' of github.com:luxonis/depthai-nodes into dev
kkeroo Oct 4, 2024
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
2 changes: 1 addition & 1 deletion depthai_nodes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .ml.parsers import *

__version__ = "0.0.1"
__version__ = "0.0.2"
4 changes: 4 additions & 0 deletions depthai_nodes/ml/helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .tiles_patcher import TilesPatcher
from .tiling import Tiling

__all__ = ["Tiling", "TilesPatcher"]
229 changes: 229 additions & 0 deletions depthai_nodes/ml/helpers/tiles_patcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
import depthai as dai

from .tiling import Tiling
from .utils.nms import nms_detections


class TilesPatcher(dai.node.HostNode):
"""Handles the processing of tiled frames from neural network (NN) outputs, maps the
detections from tiles back into the global frame, and sends out the combined
detections for further processing.
@ivar conf_thresh: Confidence threshold for filtering detections.
@type conf_thresh: float
@ivar iou_thresh: IOU threshold for non-max suppression.
@type iou_thresh: float
@ivar tile_manager: Manager responsible for handling tiling configurations.
@type tile_manager: Tiling
@ivar tile_buffer: Buffer to store tile detections temporarily.
@type tile_buffer: list
@ivar current_timestamp: Timestamp for the current frame being processed.
@type current_timestamp: float
@ivar expected_tiles_count: Number of tiles expected per frame.
@type expected_tiles_count: int
"""

def __init__(self) -> None:
"""Initializes the TilesPatcher node, sets default thresholds for confidence and
IOU, and initializes buffers for tile processing."""
super().__init__()
self.name = "TilesPatcher"
self.tile_manager = None
self.conf_thresh = 0.3
self.iou_thresh = 0.4

self.tile_buffer = []
self.current_timestamp = None
self.expected_tiles_count = 0

def build(
self, tile_manager: Tiling, nn: dai.Node.Output, conf_thresh=0.3, iou_thresh=0.4
) -> "TilesPatcher":
"""Configures the TilesPatcher node with the tile manager and links the neural
network's output.
@param tile_manager: The tiling manager responsible for tile positions and
dimensions.
@type tile_manager: Tiling
@param nn: The output of the neural network node from which detections are
received.
@type nn: dai.Node.Output
@param conf_thresh: Confidence threshold for filtering detections (default:
0.3).
@type conf_thresh: float
@param iou_thresh: IOU threshold for non-max suppression (default: 0.4).
@type iou_thresh: float
@return: Returns self for method chaining.
@rtype: TilesPatcher
"""
self.conf_thresh = conf_thresh
self.iou_thresh = iou_thresh
self.tile_manager = tile_manager
if (
self.tile_manager.x is None
or self.tile_manager.grid_size is None
or self.tile_manager.overlap is None
):
raise ValueError("Tile dimensions, grid size, or overlap not initialized.")
self.expected_tiles_count = len(self.tile_manager.tile_positions)
self.sendProcessingToPipeline(True)
self.link_args(nn)
return self

def process(self, nn_output: dai.ImgDetections) -> None:
"""Processes each neural network output (detections) by mapping them from tiled
patches back into the global frame and buffering them until all tiles for the
current frame are processed.
@param nn_output: The detections from the neural network's output.
@type nn_output: dai.ImgDetections
"""
timestamp = nn_output.getTimestamp()
device_timestamp = nn_output.getTimestampDevice()

if self.current_timestamp is None:
self.current_timestamp = timestamp

if self.current_timestamp != timestamp and len(self.tile_buffer) > 0:
# new frame started, send the output for the previous frame
self._send_output(self.current_timestamp, device_timestamp)
self.tile_buffer = []

self.current_timestamp = timestamp
tile_index = nn_output.getSequenceNum()

bboxes: list[dai.ImgDetection] = nn_output.detections
mapped_bboxes = self._map_bboxes_to_global_frame(bboxes, tile_index)
self.tile_buffer.append(mapped_bboxes)

if len(self.tile_buffer) == self.expected_tiles_count:
self._send_output(timestamp, device_timestamp)
self.tile_buffer = []

def _map_bboxes_to_global_frame(
self, bboxes: list[dai.ImgDetection], tile_index: int
):
"""Maps bounding boxes from their local tile coordinates back to the global
frame of the full image.
@param bboxes: The bounding boxes to be mapped.
@type bboxes: list[dai.ImgDetection]
@param tile_index: The index of the tile being processed.
@type tile_index: int
@return: Mapped bounding boxes in the global image frame.
@rtype: list[dai.ImgDetection]
"""
tile_info = self._get_tile_info(tile_index)
if (
self.tile_manager is None
or self.tile_manager.nn_shape is None
or tile_info is None
):
return []
if tile_info is None:
return []

# Original tile coordinates in the global frame
tile_x1, tile_y1, tile_x2, tile_y2 = tile_info["coords"]
tile_actual_width = tile_x2 - tile_x1
tile_actual_height = tile_y2 - tile_y1

# Scaled dimensions (after resizing to fit NN input)
scaled_width, scaled_height = tile_info["scaled_size"]
nn_width, nn_height = self.tile_manager.nn_shape

# Offsets due to padding
x_offset = (nn_width - scaled_width) // 2
y_offset = (nn_height - scaled_height) // 2

# Scaling factors from scaled tile back to original tile dimensions
scale_x = tile_actual_width / scaled_width
scale_y = tile_actual_height / scaled_height

global_bboxes = []
for bbox in bboxes:
# Convert bbox coordinates from normalized to NN input dimensions
bbox_xmin_nn = bbox.xmin * nn_width
bbox_ymin_nn = bbox.ymin * nn_height
bbox_xmax_nn = bbox.xmax * nn_width
bbox_ymax_nn = bbox.ymax * nn_height

# Adjust for padding offsets to get coordinates in the scaled tile
bbox_xmin_scaled = bbox_xmin_nn - x_offset
bbox_ymin_scaled = bbox_ymin_nn - y_offset
bbox_xmax_scaled = bbox_xmax_nn - x_offset
bbox_ymax_scaled = bbox_ymax_nn - y_offset

# Ensure coordinates are within the scaled tile dimensions
bbox_xmin_scaled = max(0, min(bbox_xmin_scaled, scaled_width))
bbox_ymin_scaled = max(0, min(bbox_ymin_scaled, scaled_height))
bbox_xmax_scaled = max(0, min(bbox_xmax_scaled, scaled_width))
bbox_ymax_scaled = max(0, min(bbox_ymax_scaled, scaled_height))

# Map to original tile coordinates
bbox_xmin_tile = bbox_xmin_scaled * scale_x
bbox_ymin_tile = bbox_ymin_scaled * scale_y
bbox_xmax_tile = bbox_xmax_scaled * scale_x
bbox_ymax_tile = bbox_ymax_scaled * scale_y

# Map to global image coordinates
x1_global = tile_x1 + bbox_xmin_tile
y1_global = tile_y1 + bbox_ymin_tile
x2_global = tile_x1 + bbox_xmax_tile
y2_global = tile_y1 + bbox_ymax_tile

# Normalize global coordinates
img_width, img_height = self.tile_manager.img_shape
normalized_bbox = dai.ImgDetection()
normalized_bbox.label = bbox.label
normalized_bbox.confidence = bbox.confidence
normalized_bbox.xmin = x1_global / img_width
normalized_bbox.ymin = y1_global / img_height
normalized_bbox.xmax = x2_global / img_width
normalized_bbox.ymax = y2_global / img_height

global_bboxes.append(normalized_bbox)

return global_bboxes

def _get_tile_info(self, tile_index: int):
"""Retrieves the tile's coordinates and scaled dimensions based on the tile
index.
@param tile_index: The index of the tile.
@type tile_index: int
@return: Tile information for the given index.
"""
if self.tile_manager is None or self.tile_manager.tile_positions is None:
raise ValueError("Tile manager or tile positions not initialized.")
if tile_index >= len(self.tile_manager.tile_positions):
return None
return self.tile_manager.tile_positions[tile_index]

def _send_output(self, timestamp, device_timestamp):
"""Send the final combined bounding boxes as output when all tiles for a frame
are processed.
@param timestamp: The timestamp of the frame.
@param device_timestamp: The timestamp of the frame on the device.
"""
combined_bboxes: list[dai.ImgDetection] = []
for bboxes in self.tile_buffer:
combined_bboxes.extend(bboxes)

if combined_bboxes:
detection_list = nms_detections(
combined_bboxes,
conf_thresh=self.conf_thresh,
iou_thresh=self.iou_thresh,
)
else:
detection_list = []

# Create ImgDetections message
detections = dai.ImgDetections()
detections.setTimestamp(timestamp)
detections.setTimestampDevice(device_timestamp)
detections.detections = detection_list

self.out.send(detections)
Loading
Loading