You can now save presets to JSON and load them
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Test_Merge
|
||||
|
||||
public ConfigurationTool(Bitmap fullImage, Rectangle mainZoneDimensions)
|
||||
{
|
||||
MainZone = new Zone(fullImage, mainZoneDimensions);
|
||||
MainZone = new Zone(fullImage, mainZoneDimensions,"Main");
|
||||
AutoCalibrate();
|
||||
}
|
||||
public void ResetMainZone()
|
||||
@@ -29,7 +29,7 @@ namespace Test_Merge
|
||||
{
|
||||
MainZone.ResetWindows();
|
||||
}
|
||||
public void SaveToJson(List<string> drivers,string configName)
|
||||
public void SaveToJson(List<string> drivers, string configName)
|
||||
{
|
||||
string JSON = "";
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Test_Merge
|
||||
JSON += MainZone.ToJSON() + "," + Environment.NewLine;
|
||||
JSON += "\"Drivers\":[" + Environment.NewLine;
|
||||
|
||||
for (int i = 0; i < drivers.Count;i++)
|
||||
for (int i = 0; i < drivers.Count; i++)
|
||||
{
|
||||
JSON += "\"" + drivers[i] + "\"";
|
||||
if (i < drivers.Count - 1)
|
||||
@@ -49,16 +49,16 @@ namespace Test_Merge
|
||||
|
||||
JSON += "}";
|
||||
|
||||
if(!Directory.Exists(CONFIGS_FOLDER_NAME))
|
||||
if (!Directory.Exists(CONFIGS_FOLDER_NAME))
|
||||
Directory.CreateDirectory(CONFIGS_FOLDER_NAME);
|
||||
|
||||
string path = CONFIGS_FOLDER_NAME + configName;
|
||||
|
||||
if(File.Exists(path + ".json"))
|
||||
if (File.Exists(path + ".json"))
|
||||
{
|
||||
//We need to create a new name
|
||||
int count = 2;
|
||||
while(File.Exists(path + "_" + count + ".json"))
|
||||
while (File.Exists(path + "_" + count + ".json"))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace Test_Merge
|
||||
path += ".json";
|
||||
}
|
||||
|
||||
File.WriteAllText(path,JSON);
|
||||
File.WriteAllText(path, JSON);
|
||||
}
|
||||
public void AddWindows(List<Rectangle> rectangles)
|
||||
{
|
||||
@@ -107,15 +107,15 @@ namespace Test_Merge
|
||||
break;
|
||||
case 7:
|
||||
//First zone should be the driver's First Sector
|
||||
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i - 1], false));
|
||||
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i - 1], 1, false));
|
||||
break;
|
||||
case 8:
|
||||
//First zone should be the driver's Second Sector
|
||||
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i - 1], false));
|
||||
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i - 1], 2, false));
|
||||
break;
|
||||
case 9:
|
||||
//First zone should be the driver's Position Sector
|
||||
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i - 1], false));
|
||||
driverZone.AddWindow(new DriverSectorWindow(driverZone.ZoneImage, rectangles[i - 1], 3, false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -167,6 +167,8 @@ namespace Test_Merge
|
||||
}
|
||||
} while (iter.Next(PageIteratorLevel.Word));
|
||||
}
|
||||
//DEBUG
|
||||
int i = 1;
|
||||
foreach (Rectangle Rectangle in detectedText)
|
||||
{
|
||||
Rectangle windowRectangle;
|
||||
@@ -174,7 +176,11 @@ namespace Test_Merge
|
||||
Point windowLocation = new Point(0, (Rectangle.Y + Rectangle.Height / 2) - windowSize.Height / 2);
|
||||
windowRectangle = new Rectangle(windowLocation, windowSize);
|
||||
//We add the driver zones
|
||||
MainZone.AddZone(new Zone(MainZone.ZoneImage, windowRectangle));
|
||||
Zone driverZone = new Zone(MainZone.ZoneImage, windowRectangle, "DriverZone");
|
||||
MainZone.AddZone(driverZone);
|
||||
|
||||
driverZone.ZoneImage.Save("Driver" + i+".png");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user