예제 #1
0
        /// <summary>
        /// Charge la définition d'un classifieur depuis un fichier
        /// </summary>
        public static StrongClassifier LoadFromFile(string Path)
        {
            var asm = Assembly.GetExecutingAssembly();

            Func<string, WeakClassifier> RestoreClassifier = (str) => {
                string[] vals = str.Split(';');

                var alpha = double.Parse(vals[0]);
                var threshold = int.Parse(vals[1]);
                var parity = sbyte.Parse(vals[2]);

                var featureType = asm.GetType(vals[3]);
                //if (!(featureType is IFeature)) { Console.WriteLine(featureType);
                //	throw new Exception("Invalid feature type"); }

                var featureX = int.Parse(vals[4]);
                var featureY = int.Parse(vals[5]);
                var featureWidth = int.Parse(vals[6]);
                var featureHeight = int.Parse(vals[7]);
                var featureFrame = new Rectangle(new Point(featureX, featureY),
                                                 featureWidth, featureHeight);

                var feature = (IFeature) Activator.CreateInstance(featureType, featureFrame);

                return new WeakClassifier(alpha, threshold, parity, feature);
            };

            var classifiers = File.ReadAllLines(Path).Select(RestoreClassifier)
                                                     .ToArray();

            return new StrongClassifier(classifiers);
        }
예제 #2
0
 /// <summary>
 /// Retourne un nouveau rectangle dont les coordonnées sont celles du
 /// rectangle en cours relative à celle d'un rectangle parent.
 /// </summary>
 public Rectangle NestedRectangle(Rectangle Parent)
 {
     return new Rectangle(this.TopLeft.NestedPoint(Parent.TopLeft),
                          this.Width, this.Height);
 }
 public TwoVerticalRectanglesFeature(Rectangle Frame)
 {
     this.Frame = Frame;
 }
 public FourRectanglesFeature(Rectangle Frame)
 {
     this.Frame = Frame;
 }
 public TwoHorizontalRectanglesFeature(Rectangle Frame)
 {
     this.Frame = Frame;
 }