- Nov 20, 2010
- 1,487
- 1
- 81
Hi all,
I'm writing/ a piece of software which takes an analysis of a video. It will capture the numberplate of a vehicle and take a screenshot at the same time. So the output is the numberplate and a picture of the vehicle.
It works really well except if we use it on a PC with a single mechanical hard drive we get disk errors when the disk can't keep up with writing the screenshots to disk. To keep the program running i'm made an exception and i just count the amount of disk errors. So the analysis still runs, but we end up missing a few pictures.
To solve the problem we have switched over to an SSD and we don't have any problems, however I'm wondering if maybe there is a way to solve it without forcing users to use an SSD.
It's not a really a problem, but i figured if someone here had an awesome idea i might give it a go
.
Here is the code:
Source
I'm writing/ a piece of software which takes an analysis of a video. It will capture the numberplate of a vehicle and take a screenshot at the same time. So the output is the numberplate and a picture of the vehicle.
It works really well except if we use it on a PC with a single mechanical hard drive we get disk errors when the disk can't keep up with writing the screenshots to disk. To keep the program running i'm made an exception and i just count the amount of disk errors. So the analysis still runs, but we end up missing a few pictures.
To solve the problem we have switched over to an SSD and we don't have any problems, however I'm wondering if maybe there is a way to solve it without forcing users to use an SSD.
It's not a really a problem, but i figured if someone here had an awesome idea i might give it a go
Here is the code:
Source
Code:
public void Capture(Control ctrl, string fileName)
{
Rectangle bounds = ctrl.Bounds;
Point pt = ctrl.PointToScreen(bounds.Location);
Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(pt.X - ctrl.Location.X, pt.Y - ctrl.Location.Y), Point.Empty, bounds.Size);
}
bitmap.Save(fileName, ImageFormat.Png);
}
}
}
