public class AiliaDetector
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ALGORITHM_SSD
Deprecated.
Please use (
AiliaDetectorAlgorithm.SSD ) |
static int |
ALGORITHM_YOLOV1
Deprecated.
Please use (
AiliaDetectorAlgorithm.YOLOV1 ) |
static int |
ALGORITHM_YOLOV2
Deprecated.
Please use (
AiliaDetectorAlgorithm.YOLOV2 ) |
static int |
ALGORITHM_YOLOV3
Deprecated.
Please use (
AiliaDetectorAlgorithm.YOLOV3 ) |
static int |
ALGORITHM_YOLOV4
Deprecated.
Please use (
AiliaDetectorAlgorithm.YOLOV4 ) |
static int |
ALGORITHM_YOLOX
Deprecated.
Please use (
AiliaDetectorAlgorithm.YOLOX ) |
static int |
FLAG_NORMAL
Deprecated.
Please use (
AiliaDetectorFlags.NORMAL ) |
Constructor and Description |
---|
AiliaDetector() |
Modifier and Type | Method and Description |
---|---|
static void |
Compute(long handle,
byte[] src,
int srcStride,
int srcWidth,
int srcHeight,
int srcFormat,
float threshold,
float iou)
Performs object detection.
|
static long |
Create(long netHandle,
int format,
int channel,
int range,
int algorithm,
int category_count,
int flags)
Creates a detector instance.
|
static void |
Destroy(long handle)
Destroys the detector instance.
|
static AiliaDetectorObject |
GetObject(long handle,
int objIdx,
int version)
Gets the detection results.
|
static int |
GetObjectCount(long handle)
Gets the number of detection results.
|
static void |
SetAnchors(long handle,
float[] anchors,
int anchorsCount)
Sets the anchor information (anchors or biases) for YoloV2 or other systems.
|
static void |
SetInputShape(long handle,
int input_width,
int input_height)
Sets the size of the input image for YoloV3 model.
|
@Deprecated public static final int ALGORITHM_YOLOV1
AiliaDetectorAlgorithm.YOLOV1
)@Deprecated public static final int ALGORITHM_YOLOV2
AiliaDetectorAlgorithm.YOLOV2
)@Deprecated public static final int ALGORITHM_YOLOV3
AiliaDetectorAlgorithm.YOLOV3
)@Deprecated public static final int ALGORITHM_YOLOV4
AiliaDetectorAlgorithm.YOLOV4
)@Deprecated public static final int ALGORITHM_YOLOX
AiliaDetectorAlgorithm.YOLOX
)@Deprecated public static final int ALGORITHM_SSD
AiliaDetectorAlgorithm.SSD
)@Deprecated public static final int FLAG_NORMAL
AiliaDetectorFlags.NORMAL
)public static long Create(long netHandle, int format, int channel, int range, int algorithm, int category_count, int flags) throws AiliaException
netHandle
- A network instance handleformat
- The network image format (AiliaNetworkImageFormat
)channel
- The network image channel (AiliaNetworkImageChannel
)range
- The network image range (AiliaNetworkImageRange
)algorithm
- The network algorithm (AiliaDetectorAlgorithm
)category_count
- The number of detection categories (specify 20 for VOC or 80 for COCO, etc.)flags
- Additional flags (AiliaDetectorFlags
)AiliaException
- Exceptionpublic static void Destroy(long handle)
handle
- A detector instance handlepublic static void Compute(long handle, byte[] src, int srcStride, int srcWidth, int srcHeight, int srcFormat, float threshold, float iou) throws AiliaException
handle
- A detector instance handlesrc
- Image data (32 bpp)srcStride
- The number of bytes in 1 linesrcWidth
- Image widthsrcHeight
- Image heightsrcFormat
- Image format (AiliaImageFormat
)threshold
- The detection threshold (for example, 0.1f) (The smaller it is, the easier the detection will be and the more detected objects found.)iou
- Iou threshold (for example, 0.45f) (The smaller it is, the fewer detected objects found, as duplication is not allowed.)AiliaException
- Exceptionpublic static int GetObjectCount(long handle) throws AiliaException
handle
- A detector instance handleAiliaException
- Exceptionpublic static AiliaDetectorObject GetObject(long handle, int objIdx, int version) throws AiliaException
If ailiaPredict is not run at all, the method throws AiliaException
.
The detection results are sorted in the order of estimated probability.
handle
- A detector instance handleobjIdx
- Object indexversion
- AiliaDetectorObject.version
AiliaException
- Exceptionpublic static void SetAnchors(long handle, float[] anchors, int anchorsCount) throws AiliaException
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 has a value of 5, then anchors is a 10-dimensional array.
handle
- A detector instance handleanchors
- The anchor dimensions (the shape, height and width of the detection box)anchorsCount
- The number of anchors (half of the anchors array size)AiliaException
- Exceptionpublic static void SetInputShape(long handle, int input_width, int input_height) throws AiliaException
The same YoloV3 model can be used for any input image size that is a multiple of 32.
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 Create(long, int, int, int, int, int, int)
and Compute(long, byte[], int, int, int, int, float, float)
.
If this API is not used, a default size of 416x416 is assumed.
If used with some model other than YoloV3, it will throw AiliaException
handle
- A detector instance handleinput_width
- Width of the model's input imageinput_height
- Height of the model's input imageAiliaException
- Exception