I need to save several progressions of Mats (colored image, inverted, etc...). Currently I'm struggling to find out how to save these efficiently whether it be to;
- Save all progression as images and store them in a folder (Could Get out of hand fast)
- Save the Mat to a txt/CSV file somehow then read that string data back in when needed.
If anyone has any insight and could provide examples it would be much appreciated. I know this is going to be one of my major features so it's important I get this right. Any suggestions I will give a shot so feel free to throw anything you think might work out.
Here is some of the code I'm using to define the mats needing to be saved
// Question Number, Question in color, Question inverted, Question Final, Final Bubbles
Dictionary<int, Tuple<Mat, Mat, Mat, List<Mat>>> questions = new Dictionary<int, Tuple<Mat, Mat, Mat, List<Mat>>>();
for (int questionNumber = 0; questionNumber < ColorQuestionMats.Count(); questionNumber )
{
questions.Add(questionNumber 1, new Tuple<Mat, Mat, Mat, List<Mat>>
(
ColorQuestionMats[questionNumber],
InvertedQuestions[questionNumber],
finalQuestionMat[questionNumber],
finalBubbles
));
}
CodePudding user response:
I decided not to go with this dictionary and only save the images needed for later use to a folder. The name of the save would included the question number so I could reference it in a json save I had. There were two different ways we could save the images, a Static and Dynamic file save amount.
The math worked out like;
Static -> 47 (Locations) x 10 (Tests) x 700 (AVG People per Location) x 50Kb (Size of save) = 16,450,000Kb -> 16.45 Gb
This Method assumes all people have this many questions bad, some may not have any. This also doesn't factor in test with more than 24 questions.
Dynamic -> 47 (Locations) x 10 (Tests) x 700 (AVG People per Location) x (3Kb (Size of save) x 24 (Bad Question Answers we save)) =
24 Bad = 23,688,000Kb -> 23.69Gb
10 Bad = 9,860,000Kb -> 9.86Gb
2 Bad = 1,974,000Kb -> 1.97Gb
The Static held less space in a long run, but since for my purpose the amount of bad questions may actually only be like max 6 in worst case scenarios, I went with Dynamic so I only stored the bad sections I needed.
Bitmap bitimg;
using (var ms = ColorQuestionMats[BQ].ToMemoryStream())
{
bitimg = (Bitmap)Image.FromStream(ms);
}
// Save the bitmap
bitimg.Save(MainWindow.FolderPath_BadAnswers @"\" MainWindow.curLocation @"\" MainWindow.curTT @"\Q" (questionNumber 1) "_BadAnswer.png");