In my project i take video frames one by one, compress them into 1x1 pixel and then get its color to store in a List. Problem is, if i take ~9,5 minute video, at 25 fps it only processes about 15-20% before it runs out of memory at 2gb used. But i use 64 bit os and processor, and i dont know how to allocate more ram to my project. Also, List of colors will be read quickly (25-30 times per second) so i dont think that creating temp files is an option, or at least i would like to try allocating more ram. So, question is: how do i allocate more than 2 gb to my .net 4.7 code?
My image processing code:
List<Color> VideoFramesData = new List<Color>();
//fires when i click "parse" button in my form:
private void ParseVideoButton_Click(object sender, EventArgs e)
{
while (VideoReader.Read())
{
VideoFramesData.Add(CollapseBitmap(VideoReader.GetFrame()));
}
}
//Image downscaling function:
public Color CollapseBitmap(Bitmap bmp)
{
Color FrameColor;
Bitmap result = new Bitmap(1, 1);
Graphics g = Graphics.FromImage(result);
g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.DrawImage(bmp, 0, 0, 1, 1);
FrameColor = result.GetPixel(0, 0);
result.Dispose();
g.Dispose();
return FrameColor;
}