Configure inference engine and pipelines of NCC camera. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Classes | |
struct | NccUsbPortSpec_t |
USB port information to query device serial number. More... | |
struct | NccPipeInput_t |
Frame data send to ncc device for AI inference. More... | |
struct | NccPipeOutput_t |
AI Meta frame with header and data, get back from ncc device after finished one frame AI inference. More... | |
struct | NccPipeHandle_t |
Inference engine handle. After the user initializes the model file information, the SDK will automatically allocate inference engine resources according to the device conditions to complete registration and initialization. More... | |
struct | NccTensorSpec_t |
Tensor structure. More... | |
Macros | |
#define | MAX_DEV_NUM (2) |
The maximum of the ncc devices which the sdk supported by one host APP. More... | |
#define | MAX_PIPELINE_NUM (6) |
The maximum of the AI inference pipelines which one device supported. More... | |
Enumerations | |
enum | LOG_LEVEL { LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_SHOW } |
enum | usb_error { USB_SUCCESS = 0, USB_ERROR_IO = -1, USB_ERROR_INVALID_PARAM = -2, USB_ERROR_ACCESS = -3, USB_ERROR_NO_DEVICE = -4, USB_ERROR_NOT_FOUND = -5, USB_ERROR_BUSY = -6, USB_ERROR_TIMEOUT = -7, USB_ERROR_OVERFLOW = -8, USB_ERROR_PIPE = -9, USB_ERROR_INTERRUPTED = -10, USB_ERROR_NO_MEM = -11, USB_ERROR_NOT_SUPPORTED = -12, USB_ERROR_OTHER = -99 } |
The list of the usb error code. More... | |
enum | FRAMETYPE { YUV420p = 2, YUV422p, H26X = 22, JPEG, METEDATA, BLOB = 27, BLOB_CFG, NONE } |
The list of the image format which ncc camera supported. More... | |
enum | METATYPE { META_FORMAT_U8 =100, META_FORMAT_FP16, META_FORMAT_FP32 } |
The list of the AI meta format which ncc camera supported. More... | |
enum | PROCESS_MODE { NCC_SYNC, NCC_ASYNC } |
The list of the AI inference mode which ncc camera supported. More... | |
Functions | |
int | sync_process (NccPipeHandle_t *handle, NccPipeInput_t *input, NccPipeOutput_t *output, unsigned int timeout_ms) |
Synchronous inference function,blocking operation. return when the device inference is completed. More... | |
int | async_process (NccPipeHandle_t *handle, NccPipeInput_t *input) |
Inference function,Asynchronous non blocking operation. When the device inference is completed, the callback is triggered. More... | |
int | ncc_pipe_queue_read (NccPipeHandle_t *handle, NccPipeOutput_t *pbuf, int time_out) |
Gets the output tensor information of the current pipeline. More... | |
NccPipeInput_t * | ncc_malloc (int size) |
ncc sdk malloc memory block More... | |
void | ncc_free (NccPipeInput_t *buff) |
ncc sdk free memory block More... | |
int | ncc_dev_number_get (void) |
scan all the ncc devices connected with the Host More... | |
int | ncc_dev_init (char *fw_path, int dev_num) |
Initialize ncc device,if your device don't have flash on it,need download the firmware. More... | |
int | ncc_dev_id_get (NccPipeHandle_t *handle) |
Get index of device handle according to handle. More... | |
int | ncc_dev_serial_number_get (NccUsbPortSpec_t *port, char *string, int size) |
Get serial number of device according to usb port. More... | |
int | ncc_pipe_create (NccPipeHandle_t *handle, PROCESS_MODE mode) |
Initialize the inference engine, read the parameters from the JSON file and . More... | |
int | ncc_dev_start (int dev_id) |
Start all the pipelines on the device with specified serial number. More... | |
int | ncc_pipe_id_get (NccPipeHandle_t *handle) |
Get the pipe index of this NccPipeHandle_t on the device. Generally speaking this pipe index is automatically assigned by SDK. More... | |
int | ncc_input_tensor_descriptor_get (NccPipeHandle_t *handle, NccTensorSpec_t *input_tensor) |
Gets the input tensor information of the current pipeline. More... | |
int | ncc_output_tensor_descriptor_get (NccPipeHandle_t *handle, NccTensorSpec_t *output_tensor) |
Gets the output tensor information of the current pipeline. More... | |
void | set_log_level (LOG_LEVEL level) |
set level of log print More... | |
Configure inference engine and pipelines of NCC camera.
#define MAX_DEV_NUM (2) |
The maximum of the ncc devices which the sdk supported by one host APP.
MAX_DEV_NUM
#define MAX_PIPELINE_NUM (6) |
The maximum of the AI inference pipelines which one device supported.
MAX_PIPELINE_NUM
enum FRAMETYPE |
enum LOG_LEVEL |
enum METATYPE |
enum PROCESS_MODE |
enum usb_error |
The list of the usb error code.
int async_process | ( | NccPipeHandle_t * | handle, |
NccPipeInput_t * | input | ||
) |
Inference function,Asynchronous non blocking operation.
When the device inference is completed, the callback is triggered.
*handle | Pointer to the inference handle,which has been initialized by SDK. |
*input | Pointer NccPipeInput_t |
0 | Success |
int ncc_dev_id_get | ( | NccPipeHandle_t * | handle | ) |
Get index of device handle according to handle.
[in] | *handle | pointer to the NccPipeHandle_t |
>0 | index of device which handle allocated to |
-1 | None corresponding handle created |
int ncc_dev_init | ( | char * | fw_path, |
int | dev_num | ||
) |
Initialize ncc device,if your device don't have flash on it,need download the firmware.
[in] | *fw_path | file path of firmware |
[in] | dev_num | number of devices scanned |
>0 | Number of devices successfully initialized |
-1 | The input parameter exceeds the maximum number of devices |
-2 | There are no devices need to initialize |
-3 | USB initialization failed |
int ncc_dev_number_get | ( | void | ) |
scan all the ncc devices connected with the Host
0 | None ncc devices scanned,others scanned number |
int ncc_dev_serial_number_get | ( | NccUsbPortSpec_t * | port, |
char * | string, | ||
int | size | ||
) |
Get serial number of device according to usb port.
[in] | *port | pointer to NccUsbPortSpec_t |
[in] | *string | buffer to storage serial number |
[in] | *size | size of string buffer |
0 | Get successfully |
-1 | No corresponding serial number found |
-2 | Size of buffer is shorter than length of serial number |
int ncc_dev_start | ( | int | dev_id | ) |
Start all the pipelines on the device with specified serial number.
[in] | dev_id | serial number of the device |
0 | Success |
-1 | Failure |
void ncc_free | ( | NccPipeInput_t * | buff | ) |
ncc sdk free memory block
[in] | *pData | pointer to the NccPipeInput_t memory block |
int ncc_input_tensor_descriptor_get | ( | NccPipeHandle_t * | handle, |
NccTensorSpec_t * | input_tensor | ||
) |
Gets the input tensor information of the current pipeline.
[in] | *handle | pointer to the NccPipeHandle_t |
[in] | *input_tensor | pointer to the NccTensorSpec_t |
0 | Success |
-1 | Failure |
NccPipeInput_t* ncc_malloc | ( | int | size | ) |
ncc sdk malloc memory block
[in] | size | memory byte size want to malloc |
0 | Failure |
int ncc_output_tensor_descriptor_get | ( | NccPipeHandle_t * | handle, |
NccTensorSpec_t * | output_tensor | ||
) |
Gets the output tensor information of the current pipeline.
[in] | *handle | pointer to the NccPipeHandle_t |
[in] | *output_tensor | pointer to the NccTensorSpec_t |
0 | Success |
-1 | Failure |
int ncc_pipe_create | ( | NccPipeHandle_t * | handle, |
PROCESS_MODE | mode | ||
) |
Initialize the inference engine, read the parameters from the JSON file and
.
[in] | *handle | pointer to the NccPipeHandle_t |
[in] | mode | enum PROCESS_MODE |
int ncc_pipe_id_get | ( | NccPipeHandle_t * | handle | ) |
Get the pipe index of this NccPipeHandle_t on the device.
Generally speaking this pipe index is automatically assigned by SDK.
[in] | *handle | pointer to the NccPipeHandle_t |
int ncc_pipe_queue_read | ( | NccPipeHandle_t * | handle, |
NccPipeOutput_t * | pbuf, | ||
int | time_out | ||
) |
Gets the output tensor information of the current pipeline.
[in] | *handle | pointer to the NccPipeHandle_t |
[in] | *pbuf | pointer to buffer |
[in] | time_out | option to control blocking read. |
0 | Success |
-1 | Read error |
void set_log_level | ( | LOG_LEVEL | level | ) |
set level of log print
[in] | level | enum LOG_LEVEL |
int sync_process | ( | NccPipeHandle_t * | handle, |
NccPipeInput_t * | input, | ||
NccPipeOutput_t * | output, | ||
unsigned int | timeout_ms | ||
) |
Synchronous inference function,blocking operation.
return when the device inference is completed.
[in] | *handle | Pointer to the inference handle,which has been initialized by SDK. |
[in] | *input | Pointer to the NccPipeInput_t |
[out] | *output | Pointer NccPipeOutput_t |
[in] | timeout_ms | time out millisecond. The sdk would return after timeout |
0 | Success |
-1 | Timeout |
-2 | Repeated call .................... NccPipeInput_t *pInData = ncc_malloc(imageWidth*imageHeight*3); if(pInData==0) { printf("ncc_malloc error\n"); return 0; } ........... ........... NccPipeOutput_t pOutData; int maxOutSize = 1024*1024; pOutData.output = malloc(maxOutSize); if(pOutData.output==0) { printf("'nccMalloc error\n"); return 0; } pOutData.alloc_size = maxOutSize; ...................... ret = sync_process(&handle, pInData, &pOutData, 10000); |