public TransformImageTests() { Environment.SetEnvironmentVariable("Sizes", "256,128,64"); _queueRepository = new Mock <IQueueRepository>(); _logger = new Mock <ILogger <TransformImageTests> >(); _function = new TransformImage(_queueRepository.Object); }
// The '1' indicates there should only be 1 processing thread. // While you *can* set this higher, Grayscaling doesn't really // benefit from it. See the TypeConverter for an MFT that does. public GrayscaleAsync() : base(1) { Trace("GrayscaleAsync Constructor"); m_pTransformFn = null; m_MediaSubtypes = new Guid[] { FOURCC_NV12.ToMediaSubtype(), FOURCC_YUY2.ToMediaSubtype(), FOURCC_UYVY.ToMediaSubtype() }; }
private void RecognizeImage(SKBitmap bitmap) { float[] bmp = TransformImage.ImageToFloat(bitmap); float[] output = neuralNetwork.Think(bmp); int result = Training.OutputNumber(output); Output_label.Text = result.ToString(); TotalOutput_label.Text = string.Empty; for (int i = 0; i < output.Length; i++) { TotalOutput_label.Text += i + ": " + output[i].ToString("0.00") + "\n"; } }
public Grayscale() : base() { Trace("Grayscale Constructor"); m_pTransformFn = null; m_MediaSubtypes = new Guid[] { FOURCC_NV12.ToMediaSubtype(), FOURCC_YUY2.ToMediaSubtype(), FOURCC_UYVY.ToMediaSubtype() }; m_SampleDone = new AutoResetEvent(false); m_SampleReady = new AutoResetEvent(false); m_ProcessThread = new Thread(new ThreadStart(ProcessingThread)); m_ProcessThread.IsBackground = true; #if DEBUG m_ProcessThread.Name = "MFT Processing Thread for Grayscale"; #endif m_ProcessThread.Start(); }
private void Canvas_Paint(object sender, SKPaintSurfaceEventArgs e) { surface = e.Surface; canvas = surface.Canvas; float width = e.Info.Width; float height = e.Info.Height; drawSize = Math.Min(width, height); drawPaint.StrokeWidth = drawSize / 10F; canvas.Clear(SKColors.Gray); canvas.DrawRect(new SKRect(0, 0, drawSize, drawSize), backPaint); foreach (SKPath path in completedPaths) { canvas.DrawPath(path, drawPaint); } foreach (SKPath path in inProgressPaths.Values) { canvas.DrawPath(path, drawPaint); } if (saveImage && completedPaths.Count != 0) { image = surface.Snapshot().Subset(new SKRectI(0, 0, (int)drawSize, (int)drawSize)); bitmap = SKBitmap.Decode(image.Encode()); bitmap = TransformImage.CenterImage(bitmap); RecognizeImage(bitmap); saveImage = false; //FileStream fstream = new FileStream("/storage/sdcard/Pictures/img.png", FileMode.Create); //SKImage.FromBitmap(bitmap).Encode().AsStream().CopyTo(fstream); //fstream.Close(); } else { saveImage = false; } }