cancel
Showing results for 
Search instead for 
Did you mean: 

Why is there no examples in the NanoEdgeAI.h I generated?

michael_yang
Associate

 

michael_yang_0-1733563817485.png

/* =============
Copyright (c) 2023, STMicroelectronics

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the
  following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
  products derived from this software without specific prior written permission.

*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER / OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*
*/

#ifndef __NANOEDGEAI_H__
#define __NANOEDGEAI_H__

/* Includes */
#include <stdint.h>

/* Define */
#define NEAI_ID "6754134bb85f3acb5354cd97"
#define AXIS_NUMBER 1
#define DATA_INPUT_USER 256

#ifndef __NEAI_STATE__
#define __NEAI_STATE__
enum neai_state { 
    NEAI_OK = 0,
    NEAI_INIT_FCT_NOT_CALLED = 123,
    NEAI_BOARD_ERROR,
    NEAI_KNOWLEDGE_BUFFER_ERROR,
    NEAI_NOT_ENOUGH_CALL_TO_LEARNING, //This is a fail-safe to prevent users from learning one or even no signals.
    NEAI_MINIMAL_RECOMMENDED_LEARNING_DONE,
    NEAI_UNKNOWN_ERROR,

    /* Error due to a potential compatibility issue affecting user of the ARMCC toolchain.
     * Contact our support for further details or consider using a different toolchain */
    NEAI_COMPILER_ERROR
};
#endif

/* Function prototypes */
#ifdef __cplusplus
extern "C" {
#endif
	/**
	 * @brief  Initialization must be called at the beginning to load the knowledge. 
	 *         This buffer is defined in the header file knowledge.h provided in the .zip file
	 * @retval NEAI_OK in case of success.
	 */
	enum neai_state neai_oneclass_init(const float knowledge_buffer[]);

	/**
	 * @brief  The result of outlier detection, whether or not the detected buffer is an outlier. 
	 * @PAram  data_input[] [IN]: Signal to be classified AXIS_NUMBER * DATA_INPUT_USER
	 * @PAram  is_outlier[] [OUT]: 1 if the input pattern is detected as an outlier
	 *                             0 if it is not
	 * @retval NEAI_OK in case of success.
	 */
	enum neai_state neai_oneclass(float data_input[], uint8_t *is_outlier);
#ifdef __cplusplus
}
#endif

#endif

/* =============
Here some sample declaration added in your main program for the use of the NanoEdge AI library.
You can directly copy this declaration or modify the names.
* WARNING: respect the size of the buffer.

uint8_t oneclass_result = 0; // Point to the result (see argument of neai_oneclass fct)
float input_user_buffer[DATA_INPUT_USER * AXIS_NUMBER]; // Buffer of input values
*/

 AI:How to create a current sensing classifier using NanoEdge AI Studio - stm32mcu Official examples: 

michael_yang_1-1733563946077.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Julian E.
ST Employee

Hello @michael_yang ,

 

It seems that you are doing N class classification, but in your code, you are using One class classification function...

enum neai_state neai_oneclass_init(const float knowledge_buffer[]);
enum neai_state neai_oneclass(float data_input[], uint8_t *is_outlier);

It works the same way in 1 class or N class, but the functions are not the same. Find the documentation here:

https://wiki.st.com/stm32mcu/wiki/AI:NanoEdge_AI_Library_for_n-class_classification_(nCC)

 

and concerning your issue with  NanoEdgeAI.h , I am not sure to understand what you want.

In this file, at the end, you have the id2class that you can use in your code to know which class is which (0,1,2 etc)

 

Have a good day,

Julian

 

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Julian E.
ST Employee

Hello @michael_yang ,

 

It seems that you are doing N class classification, but in your code, you are using One class classification function...

enum neai_state neai_oneclass_init(const float knowledge_buffer[]);
enum neai_state neai_oneclass(float data_input[], uint8_t *is_outlier);

It works the same way in 1 class or N class, but the functions are not the same. Find the documentation here:

https://wiki.st.com/stm32mcu/wiki/AI:NanoEdge_AI_Library_for_n-class_classification_(nCC)

 

and concerning your issue with  NanoEdgeAI.h , I am not sure to understand what you want.

In this file, at the end, you have the id2class that you can use in your code to know which class is which (0,1,2 etc)

 

Have a good day,

Julian

 

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.