-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/new snaps producer #252
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
Draft
FSAFTik
wants to merge
33
commits into
main
Choose a base branch
from
feat/new_snaps_producer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
f6dda1b
Allow also dev DAI versions with --pre flag
klemen1999 81d6c70
Small fix for pyproject.toml
klemen1999 86404a4
format fix
klemen1999 7da4e52
fix
klemen1999 701e4aa
include dev build
klemen1999 eeda1da
snaps producer v2
klemen1999 44ecc12
fixed file group
klemen1999 8b05681
temp logging level
klemen1999 ef920ca
temp logging level
klemen1999 cd4ad3d
remove debug logger
klemen1999 c5827ef
test File Group
5d8ca2f
removed device serial number from snapping
d39e4e2
changed the approach
126cfa8
sending frame by itself
fb71195
changed snaps produces sending
1819b63
Revert "changed snaps produces sending"
e6ccc85
Rollbacked and added 3rd producer
ddc26b0
Added new producer to init
e905703
Added new producer to init
628fa40
Returned FileGroup for test
926cfcc
Fixed naming problem, chagned sneding to use call per argument
a769dcd
Updated snaps producer to never build of snaps V2
ecb38b8
Added info logs to track problems
1511271
Fixed issue with time interval stopping snaps when not expected
00b9de5
new Snaps Producer
e17e741
changed nodes init
dcdc08c
changed snaps producer buffer treatment
3a52fb8
Added snaps
751da60
test snaps data
e67c5f4
changed producer logic
cb96745
Added SnapData message type + chagned producer
69c4fe2
Added tests for snap data + updated tests for snaps uploader
4bea7de
Update depthai_nodes/message/snap_data.py
FSAFTik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from typing import Dict, List, Optional | ||
|
|
||
| import depthai as dai | ||
|
|
||
|
|
||
| class SnapData(dai.Buffer): | ||
| """DepthAI-compatible message for representing a single snap event. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| snap_name : str | ||
| Logical name of the snap. | ||
| file_name : str | ||
| File name for the snap image. | ||
| frame : dai.ImgFrame | ||
| Captured image frame associated with the snap. | ||
| detections : Optional[dai.ImgDetections] | ||
| Optional detection data. | ||
| tags : List[str] | ||
| Optional list of tags to include. | ||
| extras : Dict[str, str] | ||
| Additional metadata. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| snap_name: str, | ||
| frame: dai.ImgFrame, | ||
| file_name: str = "", | ||
| detections: Optional[dai.ImgDetections] = None, | ||
| tags: Optional[List[str]] = None, | ||
| extras: Optional[Dict[str, str]] = None, | ||
| ): | ||
| super().__init__() | ||
| self.snap_name = snap_name | ||
| self.file_name = file_name | ||
| self.frame = frame | ||
| self.detections = detections | ||
| self.tags = tags or [] | ||
| self.extras = extras or {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import os | ||
|
|
||
| import depthai as dai | ||
|
|
||
| from depthai_nodes.message import SnapData | ||
| from depthai_nodes.node.base_host_node import BaseHostNode | ||
|
|
||
|
|
||
| class SnapsUploader(BaseHostNode): | ||
| """Host node responsible for receiving SnapData messages and sending snaps to | ||
| DepthAI Hub Events API.""" | ||
|
|
||
| def __init__(self): | ||
| super().__init__() | ||
| self._em = dai.EventsManager() | ||
|
|
||
| def set_token(self, token: str): | ||
| os.environ.setdefault("DEPTHAI_HUB_API_KEY", token) | ||
|
|
||
| def set_url(self, url: str): | ||
| os.environ.setdefault("DEPTHAI_HUB_EVENTS_BASE_URL", url) | ||
|
|
||
| def build(self, snaps: dai.Node.Output): | ||
| self.link_args(snaps) | ||
| return self | ||
|
|
||
| def process(self, snap: dai.Buffer): | ||
| assert isinstance(snap, SnapData), f"Expected SnapData, got {type(snap)}" | ||
|
|
||
| self._logger.debug(f"Sending snap: {snap.snap_name} -> {snap.file_name}") | ||
|
|
||
| success = self._em.sendSnap( | ||
| name=snap.snap_name, | ||
| fileName=snap.file_name, | ||
| imgFrame=snap.frame, | ||
| imgDetections=snap.detections, | ||
| tags=snap.tags, | ||
| extras=snap.extras, | ||
| ) | ||
|
|
||
| if success: | ||
| self._logger.info(f"Snap '{snap.snap_name}' sent successfully.") | ||
| else: | ||
| self._logger.error(f"Failed to send snap '{snap.snap_name}'.") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| depthai>=3.0.0rc2,<=3.0.0 | ||
| depthai>=3.0.0.dev0,<3.1 | ||
| opencv-python-headless~=4.10.0 | ||
| numpy>=1.22 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This method requires 2 positional arguments, whereas overridden BaseHostNode.process requires 1.