示例#1
0
        public async Task <float[]> Classify(object image)
        {
            PreprocessTime = TimeSpan.FromTicks(0);

            var startInferTime = DateTimeOffset.UtcNow;

            var multiarr = await NNHelpers.PlayMN(_VNMLModel, image as CVPixelBuffer);

            InferenceTime = DateTimeOffset.UtcNow - startInferTime;

            // ------------------------------------------- //

            var startPostprocessTime = DateTimeOffset.UtcNow;

            double[] newfloat = new double[_outSize];
            Marshal.Copy(multiarr.DataPointer, newfloat, 0, newfloat.Length);
            multiarr.Dispose();

            var probs = newfloat.Select(x => (float)x).ToArray();

            PostprocessTime = DateTimeOffset.UtcNow - startPostprocessTime;

            // ------------------------------------------- //

            return(probs);
        }
示例#2
0
        public byte[] ToJpegBytes(FrameEntry frame)
        {
            var cvBuffer = NNHelpers.ToCVPixelBuffer(frame);

            cvBuffer.ToCGImage(out CGImage image);
            cvBuffer.Dispose();
            return(UIImage.FromImage(image).AsJPEG().ToArray());
        }
示例#3
0
 public object ToNativeImage(FrameEntry frame)
 {
     return(NNHelpers.ToCVPixelBuffer(frame));
 }