-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de187d3
commit c7b04cc
Showing
17 changed files
with
1,707 additions
and
97 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -5,13 +5,16 @@ | |
<name>EI-SDK</name> | ||
<license>LICENSE-apache-2.0.txt</license> | ||
<description>Edge Impulse SDK</description> | ||
<url>https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.13/</url> | ||
<url>https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.61.7/</url> | ||
<supportContact>[email protected]</supportContact> | ||
<repository type="git">https://github.com/edgeimpulse/edge-impulse-sdk-pack.git</repository> | ||
<releases> | ||
<release version="1.60.13" tag="v1.60.13" date="2024-10-29" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.13/EdgeImpulse.EI-SDK.1.60.13.pack"> | ||
<release version="1.61.7" tag="v1.61.7" date="2024-11-06" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.61.7/EdgeImpulse.EI-SDK.1.61.7.pack"> | ||
EI-SDK | ||
</release> | ||
<release version="1.60.13" tag="v1.60.13" date="2024-10-29" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.13/EdgeImpulse.EI-SDK.1.60.13.pack"> | ||
EI-SDK | ||
</release> | ||
<release version="1.60.9" tag="v1.60.9" date="2024-10-24" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.9/EdgeImpulse.EI-SDK.1.60.9.pack"> | ||
EI-SDK | ||
</release> | ||
|
@@ -98,9 +101,6 @@ | |
</release> | ||
<release version="1.50.13" tag="v1.50.13" date="2024-05-30" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.50.13/EdgeImpulse.EI-SDK.1.50.13.pack"> | ||
EI-SDK | ||
</release> | ||
<release version="1.50.11" tag="v1.50.11" date="2024-05-27" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.50.11/EdgeImpulse.EI-SDK.1.50.11.pack"> | ||
EI-SDK | ||
</release> | ||
</releases> | ||
<keywords> | ||
|
@@ -146,7 +146,7 @@ | |
</packages> | ||
</requirements> | ||
<components> | ||
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.60.13"> | ||
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.61.7"> | ||
<description>Edge Impulse SDK</description> | ||
<!-- short component description --> | ||
<files> | ||
|
@@ -403,9 +403,11 @@ | |
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/memryx.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/engines.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_performance_calibration.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_postprocessing_types.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_postprocessing_common.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_postprocessing.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_object_counting.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_object_tracking.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/tinyEKF/tinyekf_custom.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/third_party/ruy/ruy/profiler/instrumentation.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/third_party/gemmlowp/internal/detect_platform.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/third_party/gemmlowp/fixedpoint/fixedpoint_neon.h"/> | ||
|
@@ -656,6 +658,9 @@ | |
<file category="header" name="edgeimpulse/edge-impulse-sdk/porting/espressif/ESP-NN/include/esp_nn_ansi_c.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/porting/espressif/ESP-NN/src/common/common_functions.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/porting/espressif/ESP-NN/src/softmax/softmax_common.h"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/alignment/ei_alignment.hpp"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/alignment/rectangular_lsap.hpp"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/tinyEKF/tinyekf.hpp"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/dsp/config.hpp"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/dsp/numpy.hpp"/> | ||
<file category="header" name="edgeimpulse/edge-impulse-sdk/dsp/memory.hpp"/> | ||
|
This file contains 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 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 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 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
138 changes: 138 additions & 0 deletions
138
edgeimpulse/edge-impulse-sdk/classifier/postprocessing/alignment/ei_alignment.hpp
This file contains 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,138 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <tuple> | ||
#include <set> | ||
#include <algorithm> | ||
#include <cmath> | ||
#include "rectangular_lsap.hpp" | ||
|
||
#if !defined(STANDALONE) | ||
#include "edge-impulse-sdk/classifier/ei_classifier_types.h" | ||
#endif | ||
|
||
__attribute__((unused)) static bool compare_tuples(std::tuple<int, int, float> a, std::tuple<int, int, float> b) { | ||
return std::get<2>(a) < std::get<2>(b); | ||
} | ||
|
||
float intersection_over_union(const ei_impulse_result_bounding_box_t bbox1, const ei_impulse_result_bounding_box_t bbox2) { | ||
uint32_t x_left = std::max(bbox1.x, bbox2.x); | ||
uint32_t y_top = std::max(bbox1.y, bbox2.y); | ||
uint32_t x_right = std::min(bbox1.x + bbox1.width, bbox2.x + bbox2.width); | ||
uint32_t y_bottom = std::min(bbox1.y + bbox1.height, bbox2.y + bbox2.height); | ||
|
||
if (x_right < x_left || y_bottom < y_top) { | ||
return 0.0; | ||
} | ||
|
||
uint32_t intersection_area = (x_right - x_left) * (y_bottom - y_top); | ||
uint32_t bbox1_area = bbox1.width * bbox1.height; | ||
uint32_t bbox2_area = bbox2.width * bbox2.height; | ||
|
||
return static_cast<float>(intersection_area) / static_cast<float>(bbox1_area + bbox2_area - intersection_area); | ||
} | ||
|
||
class JonkerVolgenantAlignment { | ||
public: | ||
JonkerVolgenantAlignment(float iou_threshold) : iou_threshold(iou_threshold) { | ||
} | ||
|
||
std::vector<std::tuple<int, int, float>> align(const std::vector<ei_impulse_result_bounding_box_t> traces, | ||
const std::vector<ei_impulse_result_bounding_box_t> detections) { | ||
|
||
if (traces.empty() || detections.empty()) { | ||
return {}; | ||
} | ||
|
||
std::vector<double> cost_mtx(traces.size() * detections.size()); | ||
for (size_t trace_idx = 0; trace_idx < traces.size(); ++trace_idx) { | ||
for (size_t detection_idx = 0; detection_idx < detections.size(); ++detection_idx) { | ||
float iou = intersection_over_union(traces[trace_idx], detections[detection_idx]); | ||
float cost = 1 - iou; | ||
EI_LOGD("t_idx=%zu d_idx=%zu cost=%.6f\n", trace_idx, detection_idx, cost); | ||
cost_mtx[trace_idx * detections.size() + detection_idx] = cost; | ||
} | ||
} | ||
|
||
int64_t *alignments_a = new int64_t[traces.size()]; | ||
int64_t *alignments_b = new int64_t[detections.size()]; | ||
|
||
solve(traces.size(), detections.size(), cost_mtx.data(), false, alignments_a, alignments_b); | ||
EI_LOGD("detections size %zu\n", detections.size()); | ||
EI_LOGD("traces size %zu\n", traces.size()); | ||
|
||
for (size_t i = 0; i < traces.size(); i++) { | ||
EI_LOGD("alignments_a[%zu] %lld\n", i, alignments_a[i]); | ||
} | ||
|
||
for (size_t i = 0; i < detections.size(); i++) { | ||
EI_LOGD("alignments_b[%zu] %lld\n", i, alignments_b[i]); | ||
} | ||
|
||
std::vector<std::tuple<int, int, float>> matches; | ||
|
||
for (size_t i = 0; i < traces.size(); i++) { | ||
size_t trace_idx = i; | ||
size_t detection_idx = alignments_b[alignments_a[i]]; | ||
float iou = 1 - cost_mtx[trace_idx * detections.size() + detection_idx]; | ||
if (iou > iou_threshold) { | ||
matches.emplace_back(trace_idx, detection_idx, iou); | ||
} | ||
} | ||
delete[] alignments_a; | ||
delete[] alignments_b; | ||
return matches; | ||
} | ||
|
||
float iou_threshold; | ||
}; | ||
|
||
class GreedyAlignment { | ||
public: | ||
GreedyAlignment(float iou_threshold) : iou_threshold(iou_threshold) { | ||
} | ||
std::vector<std::tuple<int, int, float>> align(const std::vector<ei_impulse_result_bounding_box_t> traces, | ||
const std::vector<ei_impulse_result_bounding_box_t> detections) { | ||
|
||
if (traces.empty() || detections.empty()) { | ||
return {}; | ||
} | ||
|
||
std::vector<std::tuple<int, int, float>> alignments; | ||
for (size_t trace_idx = 0; trace_idx < traces.size(); ++trace_idx) { | ||
for (size_t detection_idx = 0; detection_idx < detections.size(); ++detection_idx) { | ||
float iou = intersection_over_union(traces[trace_idx], detections[detection_idx]); | ||
float cost = 1 - iou; | ||
EI_LOGD("t_idx=%zu d_idx=%zu cost=%.6f\n", trace_idx, detection_idx, cost); | ||
if (iou > iou_threshold) { | ||
alignments.emplace_back(trace_idx, detection_idx, cost); | ||
} | ||
} | ||
} | ||
|
||
std::sort(alignments.begin(), alignments.end(), compare_tuples); | ||
EI_LOGD("alignments.size() %zu\n", alignments.size()); | ||
std::vector<std::tuple<int, int, float>> matches; | ||
std::set<int> trace_idxs_matched; | ||
std::set<int> detection_idxs_matched; | ||
|
||
for (size_t i = 0; i < alignments.size(); i++) { | ||
uint32_t trace_idx = std::get<0>(alignments[i]); | ||
uint32_t detection_idx = std::get<1>(alignments[i]); | ||
float cost = std::get<2>(alignments[i]); | ||
|
||
if (trace_idxs_matched.find(trace_idx) == trace_idxs_matched.end() && detection_idxs_matched.find(detection_idx) == detection_idxs_matched.end()) { | ||
// (1 - cost) to get iou | ||
matches.emplace_back(trace_idx, detection_idx, 1 - cost); | ||
trace_idxs_matched.insert(trace_idx); | ||
if (trace_idxs_matched.size() == traces.size()) return matches; | ||
detection_idxs_matched.insert(detection_idx); | ||
if (detection_idxs_matched.size() == detections.size()) return matches; | ||
} | ||
} | ||
|
||
return matches; | ||
} | ||
|
||
float iou_threshold; | ||
}; |
Oops, something went wrong.