-
Notifications
You must be signed in to change notification settings - Fork 158
Feature/snaps events v2 integration #1492
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
Open
aljazdu
wants to merge
36
commits into
develop
Choose a base branch
from
feature/snaps_events_v2_integration
base: develop
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.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
8c05663
Added WIP version of Snaps&Events V2 update
aljazdu 83543c5
Added FileData ImgDetections constructor
aljazdu c74b28c
Updated EventsManager bindings
aljazdu ba51384
Updated events manager bindings
aljazdu bd9471e
Updated FileData constructors
aljazdu 46d164e
Fixed response logging, removed redundant logUploadResults
aljazdu 3aa210a
Updated logging level
aljazdu 903b41b
Updated ImgDetections mimeType, sourceAppId
aljazdu f3e290a
Added events validation rules
aljazdu 3380fad
Batch preparation and upload of files is now async, added updated pro…
aljazdu 30d403d
Updated the asynchronous groups and files upload, removed queueSize
aljazdu 96f3e24
Updated fetching of configuration limits and preparing of group batch…
aljazdu f4bca4a
Updated uploadRetryPolicy
aljazdu c1133d4
Code cleanup
aljazdu 6c6b5cf
Updated events python example
aljazdu 77debeb
Updated events examples, events proto, pythong bindings, ImgDetection…
aljazdu 8146673
Added missing clear for FileGroup class
aljazdu cb4e7bd
Reverted ImgDetections changes, updated event example
aljazdu 38ed31c
Updated argument order of FileGroup add functions, fileName is now al…
aljazdu a13351e
Added addImageNNDataPair() to FileGroup
aljazdu 9c293e7
Added sendSnap() overload for the most common use case
aljazdu 3716c1f
Hub Url is now determined using an env setting
aljazdu 007e44f
Merge branch 'develop' into feature/snaps_events_v2_integration
aljazdu 940ca89
Fixed formatting
aljazdu 94fd634
Updated handling of uploadFileBatch futures
aljazdu 529b24c
Merge remote-tracking branch 'origin/develop' into feature/snaps_even…
0096d24
Minor cleanup
0cb59a8
Added caching of events
aljazdu 15a8366
PR clean up and fixes
aljazdu 622de45
Updated events examples
aljazdu f33d957
FileName is now optional when adding to fileGroups or sending snaps
aljazdu 501c5fd
Updated caching of snaps and events
aljazdu d66489c
DEPTHAI_HUB_URL env variable rename, snap tag fix, minor fixes
aljazdu d99d0f6
Added missing token check when fetching configuration limits
aljazdu 72bc656
Publish interval setting will no longer be exposed to the end user
aljazdu 0e2aac1
Merge branch 'develop' into feature/snaps_events_v2_integration
aljazdu 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
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
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,98 @@ | ||
| #include <chrono> | ||
| #include <iostream> | ||
| #include <opencv2/opencv.hpp> | ||
| #include <string> | ||
|
|
||
| #include "depthai/depthai.hpp" | ||
| #include "depthai/utility/EventsManager.hpp" | ||
|
|
||
| // Helper function to normalize frame coordinates | ||
| cv::Rect frameNorm(const cv::Mat& frame, const dai::Point2f& topLeft, const dai::Point2f& bottomRight) { | ||
| float width = frame.cols, height = frame.rows; | ||
| return cv::Rect(cv::Point(topLeft.x * width, topLeft.y * height), cv::Point(bottomRight.x * width, bottomRight.y * height)); | ||
| } | ||
|
|
||
| int main() { | ||
| dai::Pipeline pipeline(true); | ||
|
|
||
| // Enter you hub team's api-key | ||
| auto eventsManager = std::make_shared<dai::utility::EventsManager>(); | ||
| eventsManager->setToken(""); | ||
|
|
||
| auto camRgb = pipeline.create<dai::node::Camera>()->build(); | ||
| auto detectionNetwork = pipeline.create<dai::node::DetectionNetwork>(); | ||
|
|
||
| dai::NNModelDescription modelDescription; | ||
| modelDescription.model = "yolov6-nano"; | ||
| detectionNetwork->build(camRgb, modelDescription); | ||
| auto labelMap = detectionNetwork->getClasses(); | ||
|
|
||
| // Create output queues | ||
| auto qRgb = detectionNetwork->passthrough.createOutputQueue(); | ||
| auto qDet = detectionNetwork->out.createOutputQueue(); | ||
|
|
||
| pipeline.start(); | ||
|
|
||
| int counter = 0; | ||
| while(pipeline.isRunning()) { | ||
| if(cv::waitKey(1) == 'q') { | ||
| break; | ||
| } | ||
|
|
||
| auto inRgb = qRgb->get<dai::ImgFrame>(); | ||
| auto inDet = qDet->get<dai::ImgDetections>(); | ||
| if(inRgb == nullptr || inDet == nullptr) { | ||
| continue; | ||
| } | ||
|
|
||
| // Display the video stream and detections | ||
| cv::Mat frame = inRgb->getCvFrame(); | ||
| if(!frame.empty()) { | ||
| // Display detections | ||
| for(const auto& detection : inDet->detections) { | ||
| auto bbox = frameNorm(frame, dai::Point2f(detection.xmin, detection.ymin), dai::Point2f(detection.xmax, detection.ymax)); | ||
|
|
||
| // Draw label | ||
| cv::putText( | ||
| frame, labelMap.value()[detection.label], cv::Point(bbox.x + 10, bbox.y + 20), cv::FONT_HERSHEY_TRIPLEX, 0.5, cv::Scalar(255, 255, 255)); | ||
|
|
||
| // Draw confidence | ||
| cv::putText(frame, | ||
| std::to_string(static_cast<int>(detection.confidence * 100)) + "%", | ||
| cv::Point(bbox.x + 10, bbox.y + 40), | ||
| cv::FONT_HERSHEY_TRIPLEX, | ||
| 0.5, | ||
| cv::Scalar(255, 255, 255)); | ||
|
|
||
| // Draw rectangle | ||
| cv::rectangle(frame, bbox, cv::Scalar(255, 0, 0), 2); | ||
| } | ||
|
|
||
| // Show the frame | ||
| cv::imshow("rgb", frame); | ||
| } | ||
|
|
||
| // Suppose we are only interested in the detections with confidence between 50% and 60% | ||
| auto borderDetections = std::make_shared<dai::ImgDetections>(); | ||
| for(const auto& detection : inDet->detections) { | ||
| if(detection.confidence > 0.5f && detection.confidence < 0.6f) { | ||
| borderDetections->detections.emplace_back(detection); | ||
| } | ||
| } | ||
|
|
||
| // Are there any border detections | ||
| if(borderDetections->detections.size() > 0) { | ||
| std::string fileName = "ImageDetection_"; | ||
| std::stringstream ss; | ||
| ss << fileName << counter; | ||
|
|
||
| auto fileGroup = std::make_shared<dai::utility::FileGroup>(); | ||
| fileGroup->addImageDetectionsPair(ss.str(), inRgb, borderDetections); | ||
| eventsManager->sendSnap("LowConfidenceDetection", fileGroup, {"EventsExample", "C++"}, {{"key_0", "value_0"}, {"key_1", "value_1"}}); | ||
|
|
||
| counter++; | ||
| } | ||
| } | ||
|
|
||
| return EXIT_SUCCESS; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.