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); }
public byte[] ToJpegBytes(FrameEntry frame) { var cvBuffer = NNHelpers.ToCVPixelBuffer(frame); cvBuffer.ToCGImage(out CGImage image); cvBuffer.Dispose(); return(UIImage.FromImage(image).AsJPEG().ToArray()); }
public object ToNativeImage(FrameEntry frame) { return(NNHelpers.ToCVPixelBuffer(frame)); }