ailia  1.3.0.0
Classes | Macros | Typedefs | Functions
ailia_detector.h File Reference

AILIA object detection library. More...

#include "ailia.h"
#include "ailia_format.h"
Include dependency graph for ailia_detector.h:

Go to the source code of this file.

Classes

struct  _AILIADetectorObject
 

Macros

#define AILIA_DETECTOR_OBJECT_VERSION   (1)
 
#define AILIA_DETECTOR_ALGORITHM_YOLOV1   (0)
 
#define AILIA_DETECTOR_ALGORITHM_YOLOV2   (1)
 
#define AILIA_DETECTOR_ALGORITHM_YOLOV3   (2)
 
#define AILIA_DETECTOR_ALGORITHM_YOLOV4   (3)
 
#define AILIA_DETECTOR_ALGORITHM_YOLOX   (4)
 
#define AILIA_DETECTOR_ALGORITHM_SSD   (8)
 
#define AILIA_DETECTOR_FLAG_NORMAL   (0)
 

Typedefs

typedef struct _AILIADetectorObject AILIADetectorObject
 

Functions

int AILIA_API ailiaCreateDetector (struct AILIADetector **detector, struct AILIANetwork *net, unsigned int format, unsigned int channel, unsigned int range, unsigned int algorithm, unsigned int category_count, unsigned int flags)
 Creates a detector instance. More...
 
void AILIA_API ailiaDestroyDetector (struct AILIADetector *detector)
 Destroys the detector instance. More...
 
int AILIA_API ailiaDetectorCompute (struct AILIADetector *detector, const void *src, unsigned int src_stride, unsigned int src_width, unsigned int src_height, unsigned int src_format, float threshold, float iou)
 Performs object detection. More...
 
int AILIA_API ailiaDetectorGetObjectCount (struct AILIADetector *detector, unsigned int *obj_count)
 Gets the number of detection results. More...
 
int AILIA_API ailiaDetectorGetObject (struct AILIADetector *detector, AILIADetectorObject *obj, unsigned int obj_idx, unsigned int version)
 Gets the detection results. More...
 
int AILIA_API ailiaDetectorSetAnchors (struct AILIADetector *detector, float *anchors, unsigned int anchors_count)
 Sets the anchor information (anchors or biases) for YoloV2 or other systems. More...
 
int AILIA_API ailiaDetectorSetInputShape (struct AILIADetector *detector, unsigned int input_width, unsigned int input_height)
 Sets the size of the input image for YoloV3 or YoloX model. More...
 

Detailed Description

AILIA object detection library.

Date
July 28, 2021

Macro Definition Documentation

◆ AILIA_DETECTOR_ALGORITHM_SSD

#define AILIA_DETECTOR_ALGORITHM_SSD   (8)

◆ AILIA_DETECTOR_ALGORITHM_YOLOV1

#define AILIA_DETECTOR_ALGORITHM_YOLOV1   (0)

◆ AILIA_DETECTOR_ALGORITHM_YOLOV2

#define AILIA_DETECTOR_ALGORITHM_YOLOV2   (1)

◆ AILIA_DETECTOR_ALGORITHM_YOLOV3

#define AILIA_DETECTOR_ALGORITHM_YOLOV3   (2)

◆ AILIA_DETECTOR_ALGORITHM_YOLOV4

#define AILIA_DETECTOR_ALGORITHM_YOLOV4   (3)

◆ AILIA_DETECTOR_ALGORITHM_YOLOX

#define AILIA_DETECTOR_ALGORITHM_YOLOX   (4)

◆ AILIA_DETECTOR_FLAG_NORMAL

#define AILIA_DETECTOR_FLAG_NORMAL   (0)

◆ AILIA_DETECTOR_OBJECT_VERSION

#define AILIA_DETECTOR_OBJECT_VERSION   (1)

Typedef Documentation

◆ AILIADetectorObject

Function Documentation

◆ ailiaCreateDetector()

int AILIA_API ailiaCreateDetector ( struct AILIADetector **  detector,
struct AILIANetwork *  net,
unsigned int  format,
unsigned int  channel,
unsigned int  range,
unsigned int  algorithm,
unsigned int  category_count,
unsigned int  flags 
)

Creates a detector instance.

Parameters
detectorA detector instance pointer
netThe network instance pointer
formatThe network image format (AILIA_NETWORK_IMAGE_FORMAT_*)
channelThe network image channel (AILIA_NETWORK_IMAGE_CHANNEL_*)
rangeThe network image range (AILIA_NETWORK_IMAGE_RANGE_*)
algorithmDetection algorithm(AILIA_DETECTOR_ALGORITHM_*)
category_countThe number of detection categories (specify 20 for VOC or 80 for COCO, etc.)
flagsAdditional option(AILIA_DETECTOR_FLAG_*)
Returns
If this function is successful, it returns AILIA_STATUS_SUCCESS , or an error code otherwise.

◆ ailiaDestroyDetector()

void AILIA_API ailiaDestroyDetector ( struct AILIADetector *  detector)

Destroys the detector instance.

Parameters
detectorA detector instance pointer

◆ ailiaDetectorCompute()

int AILIA_API ailiaDetectorCompute ( struct AILIADetector *  detector,
const void *  src,
unsigned int  src_stride,
unsigned int  src_width,
unsigned int  src_height,
unsigned int  src_format,
float  threshold,
float  iou 
)

Performs object detection.

Parameters
detectorA detector instance pointer
srcImage data (32 bpp)
src_strideThe number of bytes in 1 line
src_widthImage width
src_heightImage height
src_formatImage format (AILIA_IMAGE_FORMAT_*)
thresholdThe detection threshold (for example, 0.1f) (The smaller it is, the easier the detection will be and the more detected objects found.)
iouIou threshold (for example, 0.45f) (The smaller it is, the fewer detected objects found, as duplication is not allowed.)
Returns
If this function is successful, it returns AILIA_STATUS_SUCCESS , or an error code otherwise.

◆ ailiaDetectorGetObject()

int AILIA_API ailiaDetectorGetObject ( struct AILIADetector *  detector,
AILIADetectorObject obj,
unsigned int  obj_idx,
unsigned int  version 
)

Gets the detection results.

Parameters
detectorA detector instance pointer
objObject information
obj_idxObject index
versionAILIA_DETECTOR_OBJECT_VERSION
Returns
If this function is successful, it returns AILIA_STATUS_SUCCESS , or an error code otherwise.

If ailiaDetectorCompute() is not run at all, the function returns AILIA_STATUS_INVALID_STATE . The detection results are sorted in the order of estimated probability.

◆ ailiaDetectorGetObjectCount()

int AILIA_API ailiaDetectorGetObjectCount ( struct AILIADetector *  detector,
unsigned int *  obj_count 
)

Gets the number of detection results.

Parameters
detectorA detector instance pointer
obj_countThe number of objects
Returns
If this function is successful, it returns AILIA_STATUS_SUCCESS , or an error code otherwise.

◆ ailiaDetectorSetAnchors()

int AILIA_API ailiaDetectorSetAnchors ( struct AILIADetector *  detector,
float *  anchors,
unsigned int  anchors_count 
)

Sets the anchor information (anchors or biases) for YoloV2 or other systems.

Parameters
detectorA detector instance pointer
anchorsThe anchor dimensions (the shape, height and width of the detection box)
anchors_countThe number of anchors (half of the anchors array size)
Returns
If this function is successful, it returns AILIA_STATUS_SUCCESS , or an error code otherwise.

YoloV2 and other systems perform object detection with multiple detection boxes determined during training. By using this API function to set the shape of the detection box determined during training, correct inferences can be made. The {x, y, x, y ...} format is used for anchor storage. If anchors_count has a value of 5, then anchors is a 10-dimensional array.

◆ ailiaDetectorSetInputShape()

int AILIA_API ailiaDetectorSetInputShape ( struct AILIADetector *  detector,
unsigned int  input_width,
unsigned int  input_height 
)

Sets the size of the input image for YoloV3 or YoloX model.

Parameters
detectorA detector instance pointer
input_widthWidth of the model's input image
input_heightHeight of the model's input image
Returns
If this function is successful, it returns AILIA_STATUS_SUCCESS , or an error code otherwise.

The same YoloV3 model can be used for any input image size that is a multiple of 32. The same YoloX model can be used for any input image size. You can use this API if you want to choose the input image size, for example to reduce the calculation complexity. It must be called between ailiaCreateDetector() () and ailiaDetectorCompute() (). If this API is not used, a default size of 416x416 is assumed. If used with some model other than YoloV3 or YoloX, it will return the error status AILIA_STATUS_INVALID_STATE .