ailia  1.3.0.0
Public Member Functions | Protected Member Functions | List of all members
AiliaDetectorModel Class Reference
Inheritance diagram for AiliaDetectorModel:
Inheritance graph
[legend]
Collaboration diagram for AiliaDetectorModel:
Collaboration graph
[legend]

Public Member Functions

bool Settings (uint set_format, uint set_channel, uint set_range, uint set_algorithm, uint set_category_n, uint set_flag)
 Set up the model. More...
 
bool Anchors (float [] anchors)
 Set the anchors (anchors or biases) information for YoloV2 and others. More...
 
bool SetInputShape (uint x, uint y)
 Sets the input geometry for YoloV3 and YOLOX. More...
 
override bool OpenFile (string prototxt, string model_path)
 Create a network object from a model file. More...
 
override bool OpenEx (Ailia.ailiaFileCallback callback, IntPtr arg1, IntPtr arg2)
 Creates a network object from a file callback. More...
 
override bool OpenMem (byte[] prototxt_buf, byte[] model_buf)
 Creates network objects from memory. More...
 
List< AiliaDetector.AILIADetectorObjectComputeFromImage (Color32 [] image, int tex_width, int tex_height, float threshold, float iou)
 Detection from images and obtaining results. More...
 
List< AiliaDetector.AILIADetectorObjectComputeFromImageB2T (Color32 [] image, int tex_width, int tex_height, float threshold, float iou)
 Detection from bottom-top images and obtaining results. More...
 
override void Close ()
 Discard the detection object. More...
 
override void Dispose ()
 Release resources. More...
 
- Public Member Functions inherited from AiliaModel
bool Environment (int type)
 Selects the specified type of calculation environment. More...
 
string EnvironmentName ()
 Displays the name of the selected environment. More...
 
int GetEnvironmentCount ()
 Get the number of available computing environments (CPU, GPU). More...
 
Ailia.AILIAEnvironment GetEnvironment (int idx)
 Obtains the computing environment for the specified index. More...
 
bool SelectEnvironment (int idx)
 Select the calculation environment. More...
 
Ailia.AILIAEnvironment GetSelectedEnvironment ()
 Retrieves the selected computing environment. More...
 
void SetMemoryMode (uint set_memory_mode)
 Sets the memory mode. More...
 
void DisableLayerFusion ()
 Disables speedup due to layer fusion. More...
 
bool Predict (float[] output_data, float[] input_data)
 Perform inference and obtain inference results. More...
 
Ailia.AILIAShape GetInputShape ()
 
uint [] GetInputShapeND ()
 Obtains the shape of the input data at the time of inference. More...
 
bool SetInputShape (Ailia.AILIAShape shape)
 Sets the shape of the input data during inference. More...
 
bool SetInputShapeND (uint[] shape, int dim)
 Change the shape of the input data during inference. More...
 
Ailia.AILIAShape GetOutputShape ()
 Obtains the shape of the output data during inference. More...
 
uint [] GetOutputShapeND ()
 Obtains the shape of the output data during inference. More...
 
Ailia.AILIAShape GetBlobShape (string layer_name)
 Obtains the shape (layer format) of the internal data (Blob) at the time of inference. (Obsolete) More...
 
int FindBlobIndexByName (string name)
 Look up and retrieve the index of the internal data (Blob) at the time of inference by name. More...
 
Ailia.AILIAShape GetBlobShape (uint idx)
 Obtains the shape (layer format) of the internal data (Blob) at the time of inference. More...
 
Ailia.AILIAShape GetBlobShape (int idx)
 
bool GetBlobData (float[] output_data, uint idx)
 Obtains internal data (Blob) at the time of inference. More...
 
bool GetBlobData (float[] output_data, int idx)
 
bool SetInputBlobData (float[] input_data, uint idx)
 Set input data to the specified Blob. More...
 
bool SetInputBlobData (float[] input_data, int idx)
 
bool SetInputBlobShape (Ailia.AILIAShape shape, uint idx)
 Sets the format of the specified input data (Blob). (4 dimensions or less) More...
 
bool SetInputBlobShape (Ailia.AILIAShape shape, int idx)
 
bool SetInputBlobShapeND (uint[] shape, uint dim, uint idx)
 Sets the format of the input data (Blob). (5D or more) More...
 
bool SetInputBlobShapeND (uint[] shape, int dim, int idx)
 
uint [] GetInputBlobList ()
 Obtains a list of the indices of the input data (Blob). More...
 
uint [] GetOutputBlobList ()
 Obtains a list of indices of the output data (Blob). More...
 
bool CopyBlobData (uint dst_blob_idx, uint src_blob_idx, AiliaModel src_model=null)
 Perform copies between blobs that specified. More...
 
bool Update ()
 Inference is performed with pre-populated data. More...
 
string GetStatusString (int status)
 Returns a string corresponding to the status code. More...
 
string GetErrorDetail ()
 Returns error details. More...
 
bool SetProfileMode (uint profile_mode)
 Enable profile mode. More...
 
string GetSummary ()
 Obtain network information and profile results. More...
 

Protected Member Functions

override void Dispose (bool disposing)
 

Additional Inherited Members

- Protected Attributes inherited from AiliaModel
IntPtr ailia = IntPtr.Zero
 
bool logging = true
 
- Properties inherited from AiliaModel
int Status [get, protected set]
 Status code Get the library status code. More...
 

Member Function Documentation

◆ Anchors()

bool AiliaDetectorModel.Anchors ( float []  anchors)
inline

Set the anchors (anchors or biases) information for YoloV2 and others.

Parameters
anchorsDimensions of the anchors (possible shape, height and width of the detection box)
Returns
Returns true on success, false on failure.

AiliaDetector.ailiaDetectorSetAnchors() sets the anchors (anchors or biases) information for YoloV2 and others. YoloV2, for example, tries to detect multiple default shapes of a box at the same time. This data describes the information of the multiple forms of the box. The anchors are stored in the form {x,y,x,y...} The nchors are stored in the form {x,y,x,y...}.

93  {
94  UInt32 anchors_count=(UInt32)(anchors.Length/2);
95  if (ailia_detector == IntPtr.Zero) {
96  if(logging){
97  Debug.Log("ailia_detector must be opened");
98  }
99  return false;
100  }
101  int status=AiliaDetector.ailiaDetectorSetAnchors(ailia_detector,anchors,anchors_count);
102  if(status!=Ailia.AILIA_STATUS_SUCCESS){
103  if(logging){
104  Debug.Log("ailiaDetectorSetAnchors failed "+status);
105  }
106  return false;
107  }
108  return true;
109  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
Definition: AiliaDetector.cs:20
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34
static int ailiaDetectorSetAnchors(IntPtr detector, float [] anchors, UInt32 anchors_count)
Set anchors or biases information for YoloV2 etc.

◆ Close()

override void AiliaDetectorModel.Close ( )
inlinevirtual

Discard the detection object.

Returns
Return nothing

Destroys the detection object.

Reimplemented from AiliaModel.

428  {
429  if(ailia_detector!=IntPtr.Zero){
430  AiliaDetector.ailiaDestroyDetector(ailia_detector);
431  ailia_detector=IntPtr.Zero;
432  }
433  base.Close();
434  }
Definition: AiliaDetector.cs:20
static void ailiaDestroyDetector(IntPtr detector)
Destroy the detector object.

◆ ComputeFromImage()

List<AiliaDetector.AILIADetectorObject> AiliaDetectorModel.ComputeFromImage ( Color32 []  image,
int  tex_width,
int  tex_height,
float  threshold,
float  iou 
)
inline

Detection from images and obtaining results.

Parameters
imageInput Image
tex_widthImage width
tec_heightImage height
threadholdDetection threshold (e.g., 0.1f) (the smaller the threshold, the easier it is to detect and the greater the number of detections)
iouDuplicate exclusion threshold (e.g., 0.45f) (the smaller the threshold, the less duplicates are tolerated and the fewer the number of detections)
Returns
List of detected objects.

Inference is made from the given image and the results of inference are retrieved in a list.

311  {
312  return ComputeFromImageWithFormat(image,tex_width,tex_height,threshold,iou,AiliaFormat.AILIA_IMAGE_FORMAT_RGBA);
313  }
Definition: AiliaFormat.cs:20
const Int32 AILIA_IMAGE_FORMAT_RGBA
Definition: AiliaFormat.cs:33

◆ ComputeFromImageB2T()

List<AiliaDetector.AILIADetectorObject> AiliaDetectorModel.ComputeFromImageB2T ( Color32 []  image,
int  tex_width,
int  tex_height,
float  threshold,
float  iou 
)
inline

Detection from bottom-top images and obtaining results.

Parameters
imageInput image
tex_widthImage width
tec_heightImage height
threadholdDetection threshold (e.g., 0.1f) (the smaller the threshold, the easier it is to detect and the greater the number of detections)
iouDuplicate exclusion threshold (e.g., 0.45f) (the smaller the threshold, the less duplicates are tolerated and the fewer the number of detections)
Returns
List of detected objects.

Inference is made from the given image and the results of inference are retrieved in a list.

341  {
342  return ComputeFromImageWithFormat(image,tex_width,tex_height,threshold,iou,AiliaFormat.AILIA_IMAGE_FORMAT_RGBA_B2T);
343  }
Definition: AiliaFormat.cs:20
const Int32 AILIA_IMAGE_FORMAT_RGBA_B2T
Definition: AiliaFormat.cs:50

◆ Dispose() [1/2]

override void AiliaDetectorModel.Dispose ( )
inlinevirtual

Release resources.

Reimplemented from AiliaModel.

444  {
445  Dispose(true);
446  }
override void Dispose()
Release resources.
Definition: AiliaDetectorModel.cs:443

◆ Dispose() [2/2]

override void AiliaDetectorModel.Dispose ( bool  disposing)
inlineprotectedvirtual

Reimplemented from AiliaModel.

449  {
450  if (disposing){
451  // release managed resource
452  }
453  Close(); // release unmanaged resource
454  base.Dispose(disposing);
455  }
override void Close()
Discard the detection object.
Definition: AiliaDetectorModel.cs:428

◆ OpenEx()

override bool AiliaDetectorModel.OpenEx ( Ailia.ailiaFileCallback  callback,
IntPtr  arg1,
IntPtr  arg2 
)
inlinevirtual

Creates a network object from a file callback.

Parameters
callbackUser-defined file access callback function structure
alg1Argument pointer notified to AILIA_USER_API_FOPEN
arg2Argument pointer notified to AILIA_USER_API_FOPEN
Returns
If this function is successful, it returns true , or false otherwise.

 Creates a network object from a file callback.

Reimplemented from AiliaModel.

214  {
215  Close();
216  bool status=base.OpenEx(callback,arg1,arg2);
217  if(!status){
218  if(logging){
219  Debug.Log("ailiaModelOpenEx failed");
220  }
221  return false;
222  }
223  return OpenDetector();
224  }
bool logging
Definition: AiliaModel.cs:32
override void Close()
Discard the detection object.
Definition: AiliaDetectorModel.cs:428

◆ OpenFile()

override bool AiliaDetectorModel.OpenFile ( string  prototxt,
string  model_path 
)
inlinevirtual

Create a network object from a model file.

Parameters
prototxtPath name of the prototxt file (MBSC or UTF16)
model_pathPathname of the protobuf/onnx file (MBSC or UTF16)
Returns
If this function is successful, it returns true , or false otherwise.

Create a network object from a model file.

Reimplemented from AiliaModel.

180  {
181  Close();
182  bool status=base.OpenFile(prototxt,model_path);
183  if(!status){
184  if(logging){
185  Debug.Log("ailiaModelOpenFile failed");
186  }
187  return false;
188  }
189  return OpenDetector();
190  }
bool logging
Definition: AiliaModel.cs:32
override void Close()
Discard the detection object.
Definition: AiliaDetectorModel.cs:428

◆ OpenMem()

override bool AiliaDetectorModel.OpenMem ( byte []  prototxt_buf,
byte []  model_buf 
)
inlinevirtual

Creates network objects from memory.

Parameters
prototxt_bufPointer to data in prototxt file
model_bufPointer to data in protobuf/onnx file
Returns
If this function is successful, it returns true , or false otherwise.

Creates network objects from memory.

Reimplemented from AiliaModel.

246  {
247  Close();
248  bool status=base.OpenMem(prototxt_buf,model_buf);
249  if(!status){
250  if(logging){
251  Debug.Log("ailiaModelOpenMem failed");
252  }
253  return false;
254  }
255  return OpenDetector();
256  }
bool logging
Definition: AiliaModel.cs:32
override void Close()
Discard the detection object.
Definition: AiliaDetectorModel.cs:428

◆ SetInputShape()

bool AiliaDetectorModel.SetInputShape ( uint  x,
uint  y 
)
inline

Sets the input geometry for YoloV3 and YOLOX.

Parameters
xModel input image width
yModel input image height
Returns
Return ture on success, false on failure.

AiliaDetector.ailiaDetectorSetInputShape() allows you to specify the input image size for the model in YoloV3 and YOLOX.

YoloV3 and YOLOX allows a single model to support any input resolution. (with a multiple limit of 32) Use this API when specifying the input image size to the model, for example, to reduce computational complexity. It must be executed between Open() and Compute(). If this API is not executed, the default of 416x416 is used. If executed outside of YOLOv3, returns AILIA_STATUS_INVALID_STATE

143  {
144  if (ailia_detector == IntPtr.Zero) {
145  if(logging){
146  Debug.Log("ailia_detector must be opened");
147  }
148  return false;
149  }
150  int status=AiliaDetector.ailiaDetectorSetInputShape(ailia_detector,x,y);
151  if(status!=Ailia.AILIA_STATUS_SUCCESS){
152  if(logging){
153  Debug.Log("ailiaDetectorSetInputShape failed "+status);
154  }
155  return false;
156  }
157  return true;
158  }
bool logging
Definition: AiliaModel.cs:32
Definition: Ailia.cs:20
static int ailiaDetectorSetInputShape(IntPtr detector, UInt32 input_width, UInt32 input_height)
Specifies the input image size to the model in YoloV3.
Definition: AiliaDetector.cs:20
const Int32 AILIA_STATUS_SUCCESS
Definition: Ailia.cs:34

◆ Settings()

bool AiliaDetectorModel.Settings ( uint  set_format,
uint  set_channel,
uint  set_range,
uint  set_algorithm,
uint  set_category_n,
uint  set_flag 
)
inline

Set up the model.

Parameters
set_formatNetwork image format
set_channelNetwork channel format
set_rangeNetwoek range
set_algorithmAlgorithm
set_categoryNumber of categories to be recognized
set_flagFlag
Returns
Returns true when configuration is complete.

Set up the model.

61  {
62  format=set_format;
63  channel=set_channel;
64  range=set_range;
65  algorithm=set_algorithm;
66  category_n=set_category_n;
67  flag=set_flag;
68  return true;
69  }

The documentation for this class was generated from the following file: