Skip to content

Commit

Permalink
SDK release v1.60.13
Browse files Browse the repository at this point in the history
  • Loading branch information
francovaro committed Oct 29, 2024
1 parent cd5859f commit de187d3
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 32 deletions.
12 changes: 6 additions & 6 deletions EdgeImpulse.EI-SDK.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -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.9/</url>
<url>https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.13/</url>
<supportContact>[email protected]</supportContact>
<repository type="git">https://github.com/edgeimpulse/edge-impulse-sdk-pack.git</repository>
<releases>
<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">
<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>
<release version="1.60.5" tag="v1.60.5" date="2024-10-16" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.5/EdgeImpulse.EI-SDK.1.60.5.pack">
EI-SDK
</release>
Expand Down Expand Up @@ -98,9 +101,6 @@
</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>
<release version="1.50.7" tag="v1.50.7" date="2024-05-24" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.50.7/EdgeImpulse.EI-SDK.1.50.7.pack">
EI-SDK
</release>
</releases>
<keywords>
Expand Down Expand Up @@ -146,7 +146,7 @@
</packages>
</requirements>
<components>
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.60.9">
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.60.13">
<description>Edge Impulse SDK</description>
<!-- short component description -->
<files>
Expand Down
4 changes: 2 additions & 2 deletions EdgeImpulse.pidx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<index schemaVersion="1.0.0" xs:noNamespaceSchemaLocation="PackIndex.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
<vendor>EdgeImpulse</vendor>
<url>https://raw.githubusercontent.com/edgeimpulse/edge-impulse-sdk-pack/main/</url>
<timestamp>2024-10-24 09:21:35</timestamp>
<timestamp>2024-10-29 12:24:25</timestamp>
<pindex>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.9/" vendor="EdgeImpulse" name="EI-SDK" version="1.60.9"/>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.13/" vendor="EdgeImpulse" name="EI-SDK" version="1.60.13"/>
</pindex>
</index>
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ typedef struct {
#endif // EI_CLASSIFIER_HAS_VISUAL_ANOMALY
ei_post_processing_output_t postprocessed_output;

#if EI_DSP_ENABLE_RUNTIME_HR == 1
#if EI_CLASSIFIER_HR_ENABLED == 1
ei_impulse_result_hr_t hr_calcs;
#endif
} ei_impulse_result_t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_quantized_yol

if (score >= block_config->threshold && score <= 1.0f) {
ei_impulse_result_bounding_box_t r;
r.label = ei_classifier_inferencing_categories[label];
r.label = impulse->categories[label];

if (version != 5) {
x *= static_cast<float>(impulse->input_width);
Expand Down Expand Up @@ -884,7 +884,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32_yolox_det

if (confidence >= block_config->threshold && confidence <= 1.0f) {
ei_impulse_result_bounding_box_t r;
r.label = ei_classifier_inferencing_categories[class_idx];
r.label = impulse->categories[class_idx];
r.value = confidence;

// now find the box...
Expand Down Expand Up @@ -959,7 +959,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32_yolov7(co

if (score >= block_config->threshold && score <= 1.0f) {
ei_impulse_result_bounding_box_t r;
r.label = ei_classifier_inferencing_categories[label];
r.label = impulse->categories[label];

r.x = static_cast<uint32_t>(xmin);
r.y = static_cast<uint32_t>(ymin);
Expand Down Expand Up @@ -1691,7 +1691,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32_yolov2(co
// convert relative coordinates to absolute coordinates
for(auto & box: boxes) {
ei_impulse_result_bounding_box_t res;
res.label = ei_classifier_inferencing_categories[box.get_label()];
res.label = impulse->categories[box.get_label()];
res.x = ceil(box.x1 * impulse->input_width);
res.y = ceil(box.y1 * impulse->input_height);
res.width = ceil((box.x2 - box.x1) * impulse->input_width);
Expand Down
30 changes: 17 additions & 13 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_run_classifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ extern "C" EI_IMPULSE_ERROR process_impulse(ei_impulse_handle_t *handle,
memset(features, 0, sizeof(ei_feature_t) * block_num);

// have it outside of the loop to avoid going out of scope
std::unique_ptr<ei::matrix_t> *matrix_ptrs = new std::unique_ptr<ei::matrix_t>[block_num];
std::unique_ptr<std::unique_ptr<ei::matrix_t>[]> matrix_ptrs_ptr(new std::unique_ptr<ei::matrix_t>[block_num]);
std::unique_ptr<ei::matrix_t> *matrix_ptrs = matrix_ptrs_ptr.get();

uint64_t dsp_start_us = ei_read_timer_us();

Expand All @@ -263,14 +264,12 @@ extern "C" EI_IMPULSE_ERROR process_impulse(ei_impulse_handle_t *handle,

if (out_features_index + block.n_output_features > handle->impulse->nn_input_frame_size) {
ei_printf("ERR: Would write outside feature buffer\n");
delete[] matrix_ptrs;
return EI_IMPULSE_DSP_ERROR;
}

#if EIDSP_SIGNAL_C_FN_POINTER
if (block.axes_size != handle->impulse->raw_samples_per_frame) {
ei_printf("ERR: EIDSP_SIGNAL_C_FN_POINTER can only be used when all axes are selected for DSP blocks\n");
delete[] matrix_ptrs;
return EI_IMPULSE_DSP_ERROR;
}
auto internal_signal = signal;
Expand All @@ -291,11 +290,12 @@ extern "C" EI_IMPULSE_ERROR process_impulse(ei_impulse_handle_t *handle,
// getter has a lazy init, so we can just call it
auto dsp_handle = handle->state.get_dsp_handle(ix);
if(dsp_handle) {
ret = dsp_handle->extract(internal_signal, features[ix].matrix, block.config, handle->impulse->frequency);
#if EI_DSP_ENABLE_RUNTIME_HR == 1
hr_class* hr = static_cast<hr_class*>(dsp_handle);
result->hr_calcs.heart_rate = hr->get_last_hr();
#endif
ret = dsp_handle->extract(
internal_signal,
features[ix].matrix,
block.config,
handle->impulse->frequency,
result);
}
else {
return EI_IMPULSE_OUT_OF_MEMORY;
Expand All @@ -306,12 +306,10 @@ extern "C" EI_IMPULSE_ERROR process_impulse(ei_impulse_handle_t *handle,

if (ret != EIDSP_OK) {
ei_printf("ERR: Failed to run DSP process (%d)\n", ret);
delete[] matrix_ptrs;
return EI_IMPULSE_DSP_ERROR;
}

if (ei_run_impulse_check_canceled() == EI_IMPULSE_CANCELED) {
delete[] matrix_ptrs;
return EI_IMPULSE_CANCELED;
}

Expand Down Expand Up @@ -351,10 +349,16 @@ extern "C" EI_IMPULSE_ERROR process_impulse(ei_impulse_handle_t *handle,
ei_printf("Running impulse...\n");
}

#if EI_CLASSIFIER_DSP_ONLY
return EI_IMPULSE_OK;
#else
EI_IMPULSE_ERROR res = run_inference(handle, features, result, debug);
delete[] matrix_ptrs;
res = run_postprocessing(handle, result, debug);
return res;
if (res != EI_IMPULSE_OK) {
return res;
} else {
return run_postprocessing(handle, result, debug);
}
#endif
}

/**
Expand Down
4 changes: 2 additions & 2 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_run_dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ __attribute__((unused)) int extract_hr_features(
{
#if EI_CLASSIFIER_HR_ENABLED
auto handle = hr_class::create(config_ptr, frequency);
auto ret = handle->extract(signal, output_matrix, config_ptr, frequency);
auto ret = handle->extract(signal, output_matrix, config_ptr, frequency, nullptr);
delete handle;
return ret;
#else
Expand Down Expand Up @@ -167,7 +167,7 @@ __attribute__((unused)) int extract_raw_features(signal_t *signal, matrix_t *out

__attribute__((unused)) int extract_flatten_features(signal_t *signal, matrix_t *output_matrix, void *config_ptr, const float frequency) {
auto handle = flatten_class::create(config_ptr, frequency);
auto ret = handle->extract(signal, output_matrix, config_ptr, frequency);
auto ret = handle->extract(signal, output_matrix, config_ptr, frequency, nullptr);
delete handle;
return ret;
}
Expand Down
11 changes: 9 additions & 2 deletions edgeimpulse/edge-impulse-sdk/dsp/ei_dsp_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "edge-impulse-sdk/dsp/config.hpp"
#include "edge-impulse-sdk/dsp/numpy_types.h"
#include "edge-impulse-sdk/classifier/ei_classifier_types.h"

class DspHandle {
public:
Expand All @@ -43,9 +44,15 @@ class DspHandle {
* @param output_matrix Output matrix to write features to
* @param config Configuration object, generated by Studio based on your DSP block parameters
* @param frequency Sampling frequency, as set in your project
* @param result Result object to write HR to. NULLABLE!
* @return int 0 on success, anything else for failure
*/
virtual int extract(ei::signal_t *signal, ei::matrix_t *output_matrix, void *config, const float frequency) = 0;
virtual int extract(
ei::signal_t *signal,
ei::matrix_t *output_matrix,
void *config,
const float frequency,
ei_impulse_result_t *result) = 0; // result* is a hack. I want to pass full context everywhere but custom DSP. TODO

// Must declare so user can override
/**
Expand All @@ -55,4 +62,4 @@ class DspHandle {
virtual ~DspHandle() {};
};

#endif //!__EI_DSP_HANDLE__H__
#endif //!__EI_DSP_HANDLE__H__
8 changes: 7 additions & 1 deletion edgeimpulse/edge-impulse-sdk/dsp/ei_flatten.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ class flatten_class : public DspHandle {
return ei::EIDSP_OK;
}

int extract(ei::signal_t *signal, ei::matrix_t *output_matrix, void *config_ptr, const float frequency) override {
int extract(
ei::signal_t *signal,
ei::matrix_t *output_matrix,
void *config_ptr,
const float frequency,
ei_impulse_result_t *result) override
{
using namespace ei;

ei_dsp_config_flatten_t config = *((ei_dsp_config_flatten_t*)config_ptr);
Expand Down
11 changes: 10 additions & 1 deletion edgeimpulse/edge-impulse-sdk/dsp/ei_hr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ class hr_class : public DspHandle {
return ei::EIDSP_OK;
}

int extract(ei::signal_t *signal, ei::matrix_t *output_matrix, void *config_ptr, const float frequency) override {
int extract(
ei::signal_t *signal,
ei::matrix_t *output_matrix,
void *config_ptr,
const float frequency,
ei_impulse_result_t *result) override
{
using namespace ei;

// Using reference avoids a copy
Expand All @@ -74,6 +80,9 @@ class hr_class : public DspHandle {
matrix_t temp(ppg.win_inc_samples, ppg.axes);
signal->get_data(i, floats_per_inc, temp.buffer);
auto hr = ppg.stream(&temp);
if (result) {
result->hr_calcs.heart_rate = hr;
}
if(!hrv || (hrv && config.include_hr)) {
output_matrix->buffer[out_idx++] = hr;
}
Expand Down

0 comments on commit de187d3

Please sign in to comment.