void ITemplate.Initialize(Feature[] features, Size size, string classLabel) { this.Features = features; this.Size = size; this.ClassLabel = classLabel; }
// ----------------------- // Public Constructors // ----------------------- /// <summary> /// Rectangle Constructor /// </summary> /// /// <remarks> /// Creates a Rectangle from Point and Size values. /// </remarks> public Rectangle(Point location, Size size) { x = location.X; y = location.Y; width = size.Width; height = size.Height; }
/// <summary> /// Inflate Method /// </summary> /// /// <remarks> /// Inflates the Rectangle by a specified Size. /// </remarks> public void Inflate(Size size) { x -= size.Width; y -= size.Height; Width += size.Width * 2; Height += size.Height * 2; }
public static Size Subtract(Size sz1, Size sz2) { return new Size (sz1.Width - sz2.Width, sz1.Height - sz2.Height); }
public static Size Add(Size sz1, Size sz2) { return new Size (sz1.Width + sz2.Width, sz1.Height + sz2.Height); }
/// <summary> /// Creates template from the input image by using provided parameters. /// </summary> /// <param name="orientation">Orientation image.</param> /// <param name="maxNumberOfFeatures">Maximum number of features per template. The features will be extracted so that their locations are semi-uniformly spread.</param> /// <param name="classLabel">Template class label.</param> /// <param name="featureImportanceFunc">Function which returns feature's strength.</param> public void Initialize(Image<Gray, int> orientation, int maxNumberOfFeatures, string classLabel, Func<Feature, int> featureImportanceFunc = null) { maxNumberOfFeatures = System.Math.Max(0, System.Math.Min(maxNumberOfFeatures, GlobalParameters.MAX_NUM_OF_FEATURES)); featureImportanceFunc = (featureImportanceFunc != null) ? featureImportanceFunc: (feature) => 0; Image<Gray, Byte> importantQuantizedOrient = FeatureMap.Calculate(orientation, 0); List<Feature> features = ExtractTemplate(importantQuantizedOrient, maxNumberOfFeatures, featureImportanceFunc); BoundingRect = GetBoundingRectangle(features); //if (boundingRect.X == 1 && boundingRect.Y == 1 && boundingRect.Width == 18) // Console.WriteLine(); for (int i = 0; i < features.Count; i++) { features[i].X -= BoundingRect.X; features[i].Y -= BoundingRect.Y; //if(features[i].X < 0 || features[i].Y < 0) // Console.WriteLine(); //PATCH!!! features[i].X = System.Math.Max(0, features[i].X); features[i].Y = System.Math.Max(0, features[i].Y); } this.Features = features.ToArray(); this.Size = BoundingRect.Size; this.ClassLabel = classLabel; }
private static Rectangle createRect(PointF centerPoint, Size size, Size frameSize) { return new Rectangle((int)centerPoint.X - size.Width / 2, (int)centerPoint.Y - size.Height / 2, size.Width, size.Height).Intersect(frameSize); }
private static void filterPartialShownObjects(ref List<Match> matches, Size originalImageSize) { List<Match> filteredMatches = new List<Match>(); foreach (Match m in matches) { Rectangle mRect = new Rectangle(m.X, m.Y, m.Template.Size.Width, m.Template.Size.Height); if (!(mRect.Right > originalImageSize.Width)) filteredMatches.Add(m); } matches = filteredMatches; }