internal Watcher(WatchZone watchZone, string name, double frequency = 1d, ColorSpace colorSpace = ColorSpace.RGB) { WatchZone = watchZone; Name = name; ColorSpace = colorSpace; Frequency = frequency; }
// TO REMOVE public void SetName(Screen screen, WatchZone watchZone, Watcher watcher) { _Name = screen.Name + "/" + watchZone.Name + "/" + watcher.Name + " - " + FileName; }
public CompiledFeatures(GameProfile gameProfile, Geometry cropGeometry, int pixelLimit = INIT_PIXEL_LIMIT) { CaptureGeometry = cropGeometry; _HasDupeCheck = false; PixelLimit = pixelLimit; // Todo: Implement resizing when (total) PixelCount exceeds PixelLimit. It won't be easy. PixelCount = 0; var nameDictionary = new Dictionary <string, List <int> >(); var cWatchZones = new CWatchZone[gameProfile.WatchZones.Count]; var indexCount = 0; // Using this until full implementation of multiple screens. foreach (var s in gameProfile.Screens) { s.CropGeometry = CaptureGeometry; } for (int i1 = 0; i1 < gameProfile.WatchZones.Count; i1++) { WatchZone watchZone = gameProfile.WatchZones[i1]; Screen screen = watchZone.Screen; var CWatches = new CWatcher[watchZone.Watches.Count]; var gameGeo = screen.GameGeometry.HasSize ? screen.GameGeometry : screen.Geometry; var wzCropGeo = watchZone.WithoutScale(gameGeo); wzCropGeo.RemoveAnchor(gameGeo); wzCropGeo.ResizeTo(screen.CropGeometry, gameGeo); wzCropGeo.Adjust(screen.CropGeometry.X, screen.CropGeometry.Y); wzCropGeo = wzCropGeo.Clamp(MIN_GEOMETRY, MAX_GEOMETRY); for (int i2 = 0; i2 < watchZone.Watches.Count; i2++) { Watcher watcher = watchZone.Watches[i2]; if (watcher.WatcherType == WatcherType.Standard) { var wiCount = watcher.WatchImages.Count; var CWatchImages = new CWatchImage[wiCount]; if (wiCount <= 0) { throw new ArgumentException("Standard Watchers require at least one image to compare against."); } for (int i3 = 0; i3 < wiCount; i3++) { WatchImage watchImage = watcher.WatchImages[i3]; var mi = new MagickImage(watchImage.Image) { ColorSpace = watcher.ColorSpace }; GetComposedImage(ref mi, watcher.Channel); StandardResize(ref mi, wzCropGeo); //PreciseResize(ref mi, watchZone.Geometry, gameGeo, screen.CropGeometry, watcher.ColorSpace); if (watcher.Equalize) { mi.Equalize(); } PixelCount += (int)Math.Round(wzCropGeo.Width) * (int)Math.Round(wzCropGeo.Height); // Todo: Un-hardcode the rounding var metricUpperBound = watcher.ErrorMetric.UpperBound(PixelCount, mi.ChannelCount); CWatchImages[i3] = new CWatchImage(watchImage.Name, indexCount, mi, metricUpperBound); AddIndexName(nameDictionary, indexCount, watchZone.Name, watcher.Name, watchImage.FileName); indexCount++; } CWatches[i2] = new CWatcher(CWatchImages, watcher); } else if (watcher.WatcherType == WatcherType.DuplicateFrame) { _HasDupeCheck = true; CWatches[i2] = new CWatcher(new CWatchImage[] { new CWatchImage(watcher.Name, indexCount) }, watcher); AddIndexName(nameDictionary, indexCount, watchZone.Name, watcher.Name, string.Empty); PixelCount += (int)Math.Round(wzCropGeo.Width) * (int)Math.Round(wzCropGeo.Height); // Todo: Un-hardcode the rounding indexCount++; } else { throw new NotImplementedException("WatcherType is not set or does not exist. This really shouldn't happen."); } } cWatchZones[i1] = new CWatchZone(watchZone.Name, wzCropGeo, CWatches); } var nameDicArray = new Dictionary <string, IEnumerable <int> >(); foreach (var entry in nameDictionary) { nameDicArray.Add(entry.Key, entry.Value.Distinct().OrderBy(x => x)); } IndexNames = nameDicArray; FeatureCount = indexCount; CWatchZones = cWatchZones; }