private void evaluate_Click(object sender, EventArgs e) { var bitmap = GetImage(this.textBox1.Text); var output = (Bitmap)bitmap.Clone(); bitmap = BitmapTool.ResizeImage(bitmap, 300, 300); bitmap.Save("input.jpg"); var boxes = new List <BoundingBox>(); int divisor = (int)this.divisorUpDown.Value; var allExtracts = BitmapTool.SlideWindow(bitmap, 140, 140 / divisor) .Concat(BitmapTool.SlideWindow(bitmap, 100, 100 / divisor)) .Concat(BitmapTool.SlideWindow(bitmap, 80, 80 / divisor)) .Concat(BitmapTool.SlideWindow(bitmap, 30, 30 / divisor)); foreach (var extracts in allExtracts.Batch(20)) { boxes.AddRange(BitmapTool.Evaluate(extracts.ToList(), this._yhat, IMAGE_WIDTH, IMAGE_HEIGHT, (float)this.minProbaUpDown.Value / 100.0f)); } this.currentBoundingBoxes.Clear(); var nms = new NonMaximumSuppresion(); var result = nms.Nms(boxes, (float)this.nmsUpDown.Value / 100.0f); foreach (var boundingBox in result) { BitmapTool.DrawBoundingBox(output, boundingBox, Color.FromArgb(50, 0, 0, 255), false); this.currentBoundingBoxes.Add(BitmapTool.Capture(bitmap, boundingBox)); } this.pictureBox1.Image = output; }
private void StartAI() { BuilderInstance <float> .Volume = new VolumeBuilder(); // Needed for GPU, must be done on AI thread // Must be done after setting BuilderInstance<float>.Volume this._yhat = SerializationExtensions.Load <float>("FaceDetection", false)[0]; while (true) { if (this._queueIn.TryDequeue(out var bitmap)) { bitmap = BitmapTool.ResizeImage(bitmap, 300, 300); var boxes = new List <BoundingBox>(); var allExtracts = BitmapTool.SlideWindow(bitmap, 100, 100 / 9); // .Concat(BitmapTool.SlideWindow(bitmap, 40, 40 / 3)); //.Concat(BitmapTool.SlideWindow(bitmap, 50, 50/3)); foreach (var extracts in allExtracts.Batch(10)) { boxes.AddRange(BitmapTool.Evaluate(extracts.ToList(), this._yhat, IMAGE_WIDTH, IMAGE_HEIGHT, 0.8f)); } this._queueOut.Enqueue(boxes); } } }