Beispiel #1
0
        public DetectResult Detect(byte[] file)
        {
            using var frame = Cv2.ImDecode(file, CvLoadImage.Grayscale);
            if (frame.IsEmpty)
            {
                throw new NotSupportedException("This file is not supported!!");
            }

            if (Ncnn.IsSupportVulkan)
            {
                Ncnn.CreateGpuInstance();
            }

            using var inMat = Mat.FromPixels(frame.Data, NcnnDotNet.PixelType.Bgr2Rgb, frame.Cols, frame.Rows);

            var faceInfos = this._UltraFace.Detect(inMat).ToArray();

            if (Ncnn.IsSupportVulkan)
            {
                Ncnn.DestroyGpuInstance();
            }

            return(new DetectResult(frame.Cols, frame.Rows, faceInfos));
        }