private Image GetBoxImage(Bitmap img, PredictionBoundingBox box) { var rec = GetBoxFromImage(box, img.Size); var format = img.PixelFormat; var newImg = img.Clone(rec, format); newImg.Save(@"C:\Users\ch489gt\Pictures\Snag-Auto\marin.png"); return(newImg); }
private Rectangle GetBoxFromImage(PredictionBoundingBox box, Size imgSize) { return(new Rectangle() { X = Convert.ToInt32(imgSize.Width * box.Left), Y = Convert.ToInt32(imgSize.Height * box.Top), Width = Convert.ToInt32(imgSize.Width * box.Width), Height = Convert.ToInt32(imgSize.Height * box.Height) }); }
private Image GetBoxImage(string imageFileName, PredictionBoundingBox box) { return(GetBoxImage(new Bitmap(imageFileName), box)); }