diff --git a/OCR_Decode/Reader.cs b/OCR_Decode/Reader.cs index 54bae7b..63d6d29 100644 --- a/OCR_Decode/Reader.cs +++ b/OCR_Decode/Reader.cs @@ -117,12 +117,22 @@ namespace OCR_Decode float offset = (((float)MainZone.ZoneImage.Height - (float)(Drivers.Count * FirstZoneSize.Height)) / (float)Drivers.Count); Bitmap MainZoneImage = MainZone.ZoneImage; + List zonesToAdd = new List(); + List zonesImages = new List(); for (int i = 0; i < NUMBER_OF_DRIVERS; i++) { - Point tmpPos = new Point(0, FirstZonePosition.Y + i * FirstZoneSize.Height - Convert.ToInt32(i * offset) /*- (i* (FirstZoneSize.Height / 32))*/); + Point tmpPos = new Point(0, FirstZonePosition.Y + i * FirstZoneSize.Height - Convert.ToInt32(i * offset)); Zone newDriverZone = new Zone(MainZoneImage, new Rectangle(tmpPos, FirstZoneSize)); - Bitmap zoneImg = newDriverZone.ZoneImage; + zonesToAdd.Add(newDriverZone); + zonesImages.Add(newDriverZone.ZoneImage); + } + + //Parallel.For(0, NUMBER_OF_DRIVERS, i => + for (int i = 0; i < NUMBER_OF_DRIVERS; i++) + { + Zone newDriverZone = zonesToAdd[(int)i]; + Bitmap zoneImg = zonesImages[(int)i]; newDriverZone.AddWindow(new DriverPositionWindow(zoneImg, new Rectangle(driverPositionPosition, driverPositionArea))); newDriverZone.AddWindow(new DriverGapToLeaderWindow(zoneImg, new Rectangle(driverGapToLeaderPosition, driverGapToLeaderArea))); @@ -135,7 +145,7 @@ namespace OCR_Decode newDriverZone.AddWindow(new DriverSector3Window(zoneImg, new Rectangle(driverSector3Position, driverSector3Area))); MainZone.AddZone(newDriverZone); - } + }//); //MessageBox.Show("We have a main zone with " + MainZone.Zones.Count() + " Driver zones with " + MainZone.Zones[4].Windows.Count() + " windows each and we have " + Drivers.Count + " drivers"); MainZones.Add(MainZone); }