Beispiel #1
0
        internal static IEnumerable<ImageSample> GetNegativeSamples(List<FileAccess.FileEntry> fileList, int numNegative)
        {
            var negatives = new ImageSample[numNegative];
            var fileIter = fileList.GetEnumerator();
            var intIter = new PermutedSequence(fileList.Max(entry => entry.Window.NumWindows));
            try
            {
                intIter.MoveNext();

                var i = 0;
                while (i < numNegative)
                {
                    if (fileIter.MoveNext())
                    {
                        if (fileIter.Current == null) continue;
                        Rectangle rect;
                        try
                        {
                            rect = fileIter.Current.Window.GetRectangle(intIter.Current);
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            continue;
                        }
                        if (!fileIter.Current.Rectangles.Any(rect.Overlaps))
                        {
                            negatives[i] = new ImageSample(fileIter.Current.FileName, intIter.Current,
                                fileIter.Current.Window);
                            i++;
                        }
                    }
                    else
                    {
                        fileIter.Dispose();
                        fileIter = fileList.GetEnumerator();
                        if (!intIter.MoveNext()) throw new CryptographicUnexpectedOperationException("Not enough integers.");
                    }
                }
                return negatives;
            }
            finally
            {
                fileIter.Dispose();
                intIter.Dispose();
            }
        }
Beispiel #2
0
 public bool FileEquals(ImageSample other)
 {
     return other != null && FileName.Equals(other.FileName);
 }