/*
* Copyright (c) 2025 EdgeImpulse Inc.
*
* Generated by Edge Impulse and licensed under the applicable Edge Impulse
* Terms of Service. Community and Professional Terms of Service
* (https://edgeimpulse.com/legal/terms-of-service) or Enterprise Terms of
* Service (https://edgeimpulse.com/legal/enterprise-terms-of-service),
* according to your product plan subscription (the “License”).
*
* This software, documentation and other associated files (collectively referred
* to as the “Software”) is a single SDK variation generated by the Edge Impulse
* platform and requires an active paid Edge Impulse subscription to use this
* Software for any purpose.
*
* You may NOT use this Software unless you have an active Edge Impulse subscription
* that meets the eligibility requirements for the applicable License, subject to
* your full and continued compliance with the terms and conditions of the License,
* including without limitation any usage restrictions under the applicable License.
*
* If you do not have an active Edge Impulse product plan subscription, or if use
* of this Software exceeds the usage limitations of your Edge Impulse product plan
* subscription, you are not permitted to use this Software and must immediately
* delete and erase all copies of this Software within your control or possession.
* Edge Impulse reserves all rights and remedies available to enforce its rights.
*
* Unless required by applicable law or agreed to in writing, the Software is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing
* permissions, disclaimers and limitations under the License.
*/
#include <stdio.h>
#include "edge-impulse-sdk/classifier/ei_run_classifier.h"
// Raw features copied from test sample
static const float features_impulse_14225_2[] = {
// Copy raw features here (e.g. from the 'Live classification' page) for project 14225, impulse 2
// https://studio.edgeimpulse.com/studio/14225/impulse/2/classification
};
static const float features_impulse_14227_1[] = {
// Copy raw features here (e.g. from the 'Live classification' page) for project 14227, impulse 1
// https://studio.edgeimpulse.com/studio/14227/impulse/1/classification
};
static const float features_impulse_25483_1[] = {
// Copy raw features here (e.g. from the 'Live classification' page) for project 25483, impulse 1
// https://studio.edgeimpulse.com/studio/25483/impulse/1/classification
};
int main(int argc, char **argv) {
// project 14225, impulse 2
{
ei_printf("Impulse #1 (project 14225, impulse 2):\n");
signal_t signal; // Wrapper for raw input buffer
ei_impulse_result_t result; // Used to store inference output
EI_IMPULSE_ERROR res; // Return code from inference
const ei_impulse_t& impulse = impulse_14225_2;
ei_impulse_handle_t& impulse_handle = impulse_handle_14225_2;
run_classifier_init(&impulse_handle);
// Calculate the length of the buffer
size_t buf_len = sizeof(features_impulse_14225_2) / sizeof(features_impulse_14225_2[0]);
// Make sure that the length of the buffer matches expected input length
if (buf_len != impulse.dsp_input_frame_size) {
ei_printf("ERROR: The size of the input buffer is not correct.\n");
ei_printf("Expected %d items, but got %d\n",
impulse.dsp_input_frame_size,
(int)buf_len);
return 1;
}
int err = numpy::signal_from_buffer(features_impulse_14225_2, impulse.dsp_input_frame_size, &signal);
if (err != 0) {
ei_printf("signal_from_buffer failed (%d)\n", err);
return 1;
}
// Perform DSP pre-processing and inference
res = run_classifier(&impulse_handle, &signal, &result, false);
if (res != EI_IMPULSE_OK) {
ei_printf("run_classifier returned: %d\n", res);
return 1;
}
// See how to modify this in edge-impulse-sdk/classifier/ei_print_results.h
ei_print_results(&impulse_handle, &result);
ei_printf("\n");
run_classifier_deinit(&impulse_handle);
}
// project 14227, impulse 1
{
ei_printf("Impulse #2 (project 14227, impulse 1):\n");
signal_t signal; // Wrapper for raw input buffer
ei_impulse_result_t result; // Used to store inference output
EI_IMPULSE_ERROR res; // Return code from inference
const ei_impulse_t& impulse = impulse_14227_1;
ei_impulse_handle_t& impulse_handle = impulse_handle_14227_1;
run_classifier_init(&impulse_handle);
// Calculate the length of the buffer
size_t buf_len = sizeof(features_impulse_14227_1) / sizeof(features_impulse_14227_1[0]);
// Make sure that the length of the buffer matches expected input length
if (buf_len != impulse.dsp_input_frame_size) {
ei_printf("ERROR: The size of the input buffer is not correct.\n");
ei_printf("Expected %d items, but got %d\n",
impulse.dsp_input_frame_size,
(int)buf_len);
return 1;
}
int err = numpy::signal_from_buffer(features_impulse_14227_1, impulse.dsp_input_frame_size, &signal);
if (err != 0) {
ei_printf("signal_from_buffer failed (%d)\n", err);
return 1;
}
// Perform DSP pre-processing and inference
res = run_classifier(&impulse_handle, &signal, &result, false);
if (res != EI_IMPULSE_OK) {
ei_printf("run_classifier returned: %d\n", res);
return 1;
}
// See how to modify this in edge-impulse-sdk/classifier/ei_print_results.h
ei_print_results(&impulse_handle, &result);
ei_printf("\n");
run_classifier_deinit(&impulse_handle);
}
// project 25483, impulse 1
{
ei_printf("Impulse #3 (project 25483, impulse 1):\n");
signal_t signal; // Wrapper for raw input buffer
ei_impulse_result_t result; // Used to store inference output
EI_IMPULSE_ERROR res; // Return code from inference
const ei_impulse_t& impulse = impulse_25483_1;
ei_impulse_handle_t& impulse_handle = impulse_handle_25483_1;
run_classifier_init(&impulse_handle);
// Calculate the length of the buffer
size_t buf_len = sizeof(features_impulse_25483_1) / sizeof(features_impulse_25483_1[0]);
// Make sure that the length of the buffer matches expected input length
if (buf_len != impulse.dsp_input_frame_size) {
ei_printf("ERROR: The size of the input buffer is not correct.\n");
ei_printf("Expected %d items, but got %d\n",
impulse.dsp_input_frame_size,
(int)buf_len);
return 1;
}
int err = numpy::signal_from_buffer(features_impulse_25483_1, impulse.dsp_input_frame_size, &signal);
if (err != 0) {
ei_printf("signal_from_buffer failed (%d)\n", err);
return 1;
}
// Perform DSP pre-processing and inference
res = run_classifier(&impulse_handle, &signal, &result, false);
if (res != EI_IMPULSE_OK) {
ei_printf("run_classifier returned: %d\n", res);
return 1;
}
// See how to modify this in edge-impulse-sdk/classifier/ei_print_results.h
ei_print_results(&impulse_handle, &result);
ei_printf("\n");
run_classifier_deinit(&impulse_handle);
}
}