private void Classifier(AiliaDetector.AILIADetectorObject box, Color32[] camera, int tex_width, int tex_height)
        {
            //Convert to pixel domain
            int x1 = (int)(box.x * tex_width);
            int y1 = (int)(box.y * tex_height);
            int x2 = (int)((box.x + box.w) * tex_width);
            int y2 = (int)((box.y + box.h) * tex_height);

            int w = (x2 - x1);
            int h = (y2 - y1);

            if (w <= 0 || h <= 0)
            {
                return;
            }

            Color color = Color.white;

            color = Color.HSVToRGB((float)box.category / category_n, 1.0f, 1.0f);
            DrawRect2D(color, x1, y1, w, h, tex_width, tex_height);

            float  p    = (int)(box.prob * 100) / 100.0f;
            string text = "";

            text += classifierLabel[box.category];
            text += " " + p;
            int margin = 4;

            DrawText(color, text, x1 + margin, y1 + margin, tex_width, tex_height);
        }
        private List <AiliaDetector.AILIADetectorObject> ComputeFromImageWithFormat(Color32[] camera, int tex_width, int tex_height, float threshold, float iou, uint format)
        {
            if (ailia_detector == IntPtr.Zero)
            {
                return(null);
            }

            //バッファの固定
            GCHandle preview_handle  = GCHandle.Alloc(camera, GCHandleType.Pinned);
            IntPtr   preview_buf_ptr = preview_handle.AddrOfPinnedObject();

            //画像認識を行ってカテゴリを表示
            int status = AiliaDetector.ailiaDetectorCompute(ailia_detector, preview_buf_ptr, (UInt32)tex_width * 4, (UInt32)tex_width, (UInt32)tex_height, format, threshold, iou);

            if (status != Ailia.AILIA_STATUS_SUCCESS)
            {
                if (logging)
                {
                    Debug.Log("ailiaDetectorCompute failed " + status);
                }
                return(null);
            }

            //推論結果を表示
            List <AiliaDetector.AILIADetectorObject> result_list = new List <AiliaDetector.AILIADetectorObject>();
            uint count = 0;

            AiliaDetector.ailiaDetectorGetObjectCount(ailia_detector, ref count);
            for (uint i = 0; i < count; i++)
            {
                AiliaDetector.AILIADetectorObject detector_obj = new AiliaDetector.AILIADetectorObject();
                status = AiliaDetector.ailiaDetectorGetObject(ailia_detector, detector_obj, (uint)i, AiliaClassifier.AILIA_CLASSIFIER_CLASS_VERSION);
                if (status != Ailia.AILIA_STATUS_SUCCESS)
                {
                    if (logging)
                    {
                        Debug.Log("ailiaDetectorGetObject failed " + status);
                    }
                    break;
                }
                result_list.Add(detector_obj);
            }

            //バッファの開放
            preview_handle.Free();

            return(result_list);
        }
        private void FaceClassifier(AiliaDetector.AILIADetectorObject box, Color32[] camera, int tex_width, int tex_height)
        {
            //Convert to pixel position
            int x1 = (int)(box.x * tex_width);
            int y1 = (int)(box.y * tex_height);
            int x2 = (int)((box.x + box.w) * tex_width);
            int y2 = (int)((box.y + box.h) * tex_height);

            //Get face image
            Color32[] face;

            int w = (x2 - x1);
            int h = (y2 - y1);

            float expand = 1.4f;

            x1 -= (int)(w * expand - w) / 2;
            y1 -= (int)(h * expand - h) / 2;
            w   = (int)(w * expand);
            h   = (int)(h * expand);

            if (w <= 0 || h <= 0)
            {
                return;
            }

            face = new Color32[w * h];

            GetFace(face, x1, y1, w, h, camera, tex_width, tex_height);

            //Feature extractor
            long start_time = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond;;

            float[] feature = ailia_feature_extractor.ComputeFromImage(face, w, h);

            //Match
            float  distance     = 0.0f;
            string feature_text = "";
            Color  color        = Color.white;

            if (capture_feature_value != null)
            {
                distance     = ailia_feature_extractor.Match(capture_feature_value, feature);
                feature_text = "Distance " + distance + "\n";
                if (distance < threshold)
                {
                    feature_text += "Same person";
                    color         = Color.green;
                }
                else
                {
                    feature_text += "Not same person";
                    color         = Color.red;
                }
            }
            else
            {
                feature_text = "Please capture some face";
            }
            before_feature_value = feature;
            long end_time = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond;;

            DrawRect2D(color, x1, y1, w, h, tex_width, tex_height);

            int margin = 4;

            DrawText(color, feature_text, x1 + margin, y1 + margin, tex_width, tex_height);

            if (label_text != null)
            {
                label_text.text = (end_time - start_time) + "ms\n" + ailia_face.EnvironmentName();
            }
        }