ailia  1.5.0.0
Public Member Functions | Protected Member Functions | List of all members
ailia.AiliaDetectorModel Class Reference
Inheritance diagram for ailia.AiliaDetectorModel:
Inheritance graph
[legend]
Collaboration diagram for ailia.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 ailia.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 ailia.AiliaModel
IntPtr ailia = IntPtr.Zero
 
bool logging = true
 
- Properties inherited from ailia.AiliaModel
int Status [get, protected set]
 Status code @detail Get the library status code. More...
 

Member Function Documentation

◆ Anchors()

bool ailia.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...}.

94  {
95  UInt32 anchors_count=(UInt32)(anchors.Length/2);
96  if (ailia_detector == IntPtr.Zero) {
97  if(logging){
98  Debug.Log("ailia_detector must be opened");
99  }
100  return false;
101  }
102  int status=AiliaDetector.ailiaDetectorSetAnchors(ailia_detector,anchors,anchors_count);
103  if(status!=Ailia.AILIA_STATUS_SUCCESS){
104  if(logging){
105  Debug.Log("ailiaDetectorSetAnchors failed "+status);
106  }
107  return false;
108  }
109  return true;
110  }
bool logging
Definition: AiliaModel.cs:33

◆ Close()

override void ailia.AiliaDetectorModel.Close ( )
inlinevirtual

Discard the detection object.

Returns
Return nothing

Destroys the detection object.

Reimplemented from ailia.AiliaModel.

429  {
430  if(ailia_detector!=IntPtr.Zero){
431  AiliaDetector.ailiaDestroyDetector(ailia_detector);
432  ailia_detector=IntPtr.Zero;
433  }
434  base.Close();
435  }

◆ ComputeFromImage()

List<AiliaDetector.AILIADetectorObject> ailia.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.

312  {
313  return ComputeFromImageWithFormat(image,tex_width,tex_height,threshold,iou,AiliaFormat.AILIA_IMAGE_FORMAT_RGBA);
314  }

◆ ComputeFromImageB2T()

List<AiliaDetector.AILIADetectorObject> ailia.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.

342  {
343  return ComputeFromImageWithFormat(image,tex_width,tex_height,threshold,iou,AiliaFormat.AILIA_IMAGE_FORMAT_RGBA_B2T);
344  }

◆ Dispose() [1/2]

override void ailia.AiliaDetectorModel.Dispose ( )
inlinevirtual

Release resources.

Reimplemented from ailia.AiliaModel.

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

◆ Dispose() [2/2]

override void ailia.AiliaDetectorModel.Dispose ( bool  disposing)
inlineprotectedvirtual

Reimplemented from ailia.AiliaModel.

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

◆ OpenEx()

override bool ailia.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 ailia.AiliaModel.

215  {
216  Close();
217  bool status=base.OpenEx(callback,arg1,arg2);
218  if(!status){
219  if(logging){
220  Debug.Log("ailiaModelOpenEx failed");
221  }
222  return false;
223  }
224  return OpenDetector();
225  }

◆ OpenFile()

override bool ailia.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 ailia.AiliaModel.

181  {
182  Close();
183  bool status=base.OpenFile(prototxt,model_path);
184  if(!status){
185  if(logging){
186  Debug.Log("ailiaModelOpenFile failed");
187  }
188  return false;
189  }
190  return OpenDetector();
191  }

◆ OpenMem()

override bool ailia.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 ailia.AiliaModel.

247  {
248  Close();
249  bool status=base.OpenMem(prototxt_buf,model_buf);
250  if(!status){
251  if(logging){
252  Debug.Log("ailiaModelOpenMem failed");
253  }
254  return false;
255  }
256  return OpenDetector();
257  }

◆ SetInputShape()

bool ailia.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

144  {
145  if (ailia_detector == IntPtr.Zero) {
146  if(logging){
147  Debug.Log("ailia_detector must be opened");
148  }
149  return false;
150  }
151  int status=AiliaDetector.ailiaDetectorSetInputShape(ailia_detector,x,y);
152  if(status!=Ailia.AILIA_STATUS_SUCCESS){
153  if(logging){
154  Debug.Log("ailiaDetectorSetInputShape failed "+status);
155  }
156  return false;
157  }
158  return true;
159  }

◆ Settings()

bool ailia.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.

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

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