-
Notifications
You must be signed in to change notification settings - Fork 0
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
New model parsers. #5
Changes from 13 commits
42710ad
065c480
5ea5e8d
9b2c230
148dc05
495ab3f
6e7a2c4
920565c
bb90cfa
2b33133
2eefa6e
f211aad
48f280c
e50e75a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
from .img_detections import ImgDetectionWithKeypoints, ImgDetectionsWithKeypoints | ||
from .keypoints import HandKeypoints, Keypoints | ||
from .matched_points import MatchedPoints | ||
from .lines import Line, Lines | ||
|
||
__all__ = [ | ||
"ImgDetectionWithKeypoints", | ||
"ImgDetectionsWithKeypoints", | ||
"HandKeypoints", | ||
"Keypoints", | ||
"MatchedPoints", | ||
"Line", | ||
"Lines", | ||
] |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could instead do something like: https://docs.luxonis.com/software/depthai-components/nodes/feature_tracker. We would likely be matching features across the time, so perhaps using MatchedFeatures from above would make the most sense? Alternative option is to provide 2 possible decoders, one for feature matching and one for feature tracking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, meaning that I add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you would need to set the same ID to the new point and increment the age. I would do a full support of TrackedFeatures so that DAI can use this directly or see how it can be used downstream. Let's clarify with DAI team internally if we have some further questions on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in e50e75a. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import numpy as np | ||
from ...messages import MatchedPoints | ||
|
||
def create_matched_points_message(reference_points: np.ndarray, target_points: np.ndarray) -> MatchedPoints: | ||
""" | ||
Create a message for the matched points. The message contains the reference and target points. | ||
|
||
Args: | ||
reference_points (np.ndarray): Reference points of shape (N,2) meaning [...,[x, y],...]. | ||
target_points (np.ndarray): Target points of shape (N,2) meaning [...,[x, y],...]. | ||
|
||
Returns: | ||
MatchedPoints: Message containing the reference and target points. | ||
""" | ||
|
||
|
||
if not isinstance(reference_points, np.ndarray): | ||
raise ValueError(f"reference_points should be numpy array, got {type(reference_points)}.") | ||
if len(reference_points.shape) != 2: | ||
raise ValueError(f"reference_points should be of shape (N,2) meaning [...,[x, y],...], got {reference_points.shape}.") | ||
if reference_points.shape[1] != 2: | ||
raise ValueError(f"reference_points 2nd dimension should be of size 2 e.g. [x, y], got {reference_points.shape[1]}.") | ||
if not isinstance(target_points, np.ndarray): | ||
raise ValueError(f"target_points should be numpy array, got {type(target_points)}.") | ||
if len(target_points.shape) != 2: | ||
raise ValueError(f"target_points should be of shape (N,2) meaning [...,[x, y],...], got {target_points.shape}.") | ||
if target_points.shape[1] != 2: | ||
raise ValueError(f"target_points 2nd dimension should be of size 2 e.g. [x, y], got {target_points.shape[1]}.") | ||
|
||
matched_points_msg = MatchedPoints() | ||
matched_points_msg.reference_points = reference_points.tolist() | ||
matched_points_msg.target_points = target_points.tolist() | ||
|
||
return matched_points_msg |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import depthai as dai | ||
from typing import List | ||
|
||
class Line(dai.Buffer): | ||
def __init__(self): | ||
super().__init__() | ||
self._start_point: dai.Point2f = None | ||
self._end_point: dai.Point2f = None | ||
self._confidence: float = None | ||
|
||
@property | ||
def start_point(self) -> dai.Point2f: | ||
return self._start_point | ||
|
||
@start_point.setter | ||
def start_point(self, value: dai.Point2f): | ||
if not isinstance(value, dai.Point2f): | ||
raise TypeError(f"start_point must be of type Point2f, instead got {type(value)}.") | ||
self._start_point = value | ||
|
||
@property | ||
def end_point(self) -> dai.Point2f: | ||
return self._end_point | ||
|
||
@end_point.setter | ||
def end_point(self, value: dai.Point2f): | ||
if not isinstance(value, dai.Point2f): | ||
raise TypeError(f"end_point must be of type Point2f, instead got {type(value)}.") | ||
self._end_point = value | ||
|
||
@property | ||
def confidence(self) -> float: | ||
return self._confidence | ||
|
||
@confidence.setter | ||
def confidence(self, value: float): | ||
if not isinstance(value, float): | ||
raise TypeError(f"confidence must be of type float, instead got {type(value)}.") | ||
self._confidence = value | ||
|
||
|
||
class Lines(dai.Buffer): | ||
def __init__(self): | ||
super().__init__() | ||
self._lines: List[Line] = [] | ||
|
||
@property | ||
def lines(self) -> List[Line]: | ||
return self._lines | ||
|
||
@lines.setter | ||
def lines(self, value: List[Line]): | ||
if not isinstance(value, List): | ||
raise TypeError(f"lines must be of type List[Line], instead got {type(value)}.") | ||
for line in value: | ||
if not isinstance(line, Line): | ||
raise TypeError(f"lines must be of type List[Line], instead got {type(value)}.") | ||
self._lines = value |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import depthai as dai | ||
from typing import List | ||
|
||
class MatchedPoints(dai.Buffer): | ||
def __init__(self): | ||
super().__init__() | ||
self._reference_points: List[List[float]] = [] | ||
self._target_points: List[List[float]] = [] | ||
|
||
@property | ||
def reference_points(self) -> List[List[float]]: | ||
return self._reference_points | ||
|
||
@reference_points.setter | ||
def reference_points(self, value: List[List[float]]): | ||
if not isinstance(value, list): | ||
raise TypeError("reference_points must be a list.") | ||
for item in value: | ||
if not isinstance(item, list): | ||
raise TypeError("reference points should be List[List[float]].") | ||
for item in value: | ||
if len(item) != 2: | ||
raise ValueError("Each item in reference_points must be of length 2.") | ||
for item in value: | ||
if not all(isinstance(i, float) for i in item): | ||
raise TypeError("All items in reference_points must be of type float.") | ||
self._reference_points = value | ||
|
||
@property | ||
def target_points(self) -> List[List[float]]: | ||
return self._target_points | ||
|
||
@target_points.setter | ||
def target_points(self, value: List[List[float]]): | ||
if not isinstance(value, list): | ||
raise TypeError("target_points must be a list.") | ||
for item in value: | ||
if not isinstance(item, list): | ||
raise TypeError("target points should be List[List[float]].") | ||
for item in value: | ||
if len(item) != 2: | ||
raise ValueError("Each item in target_points must be of length 2.") | ||
for item in value: | ||
if not all(isinstance(i, float) for i in item): | ||
raise TypeError("All items in target_points must be of type float.") | ||
self._target_points = value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note is that his might require reshaping depending on the output as mentioned in one of the comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reshape is handled in the parser.