/// <summary> /// Initializes a new instance of the ImageAnalysis class. /// </summary> /// <param name="game">The game associated with the class</param> /// <param name="screenSize">The size of the sceen to analze</param> /// <param name="viewPortList1">A list of the view ports</param> public ImageAnalysis(Game game, Vector2 screenSize, List <Viewport> viewPortList1) : base(game) { this.screenWidth = (int)screenSize.X; this.screenHeight = (int)screenSize.Y; // Creates the image drawing analysis object. this.drawAnalysis = new DrawImageAnalysis(game, this.screenWidth, this.screenHeight, UpdateSquareDimForDrawing, UpdateSquareDimForAnalysis, NumberofLinesToFind, ThetaIncrement, RhoIncrement, viewPortList1, this); this.drawAnalysis.DrawOrder = game.Components.Count; Game.Components.Add(this.drawAnalysis); }
/// <summary> /// Called when the class is initialized. Creates many of the arrays and sets many of the values. /// </summary> public override void Initialize() { this.totalWhiteCnt = 0; // Create the arrays needed. Building them now will save CPU later. this.clearPathTrueFalseMap = new bool[this.screenWidth, this.screenHeight]; this.trueFalseMapB = new bool[this.screenWidth, this.screenHeight]; this.findWhiteTrueFalseMap = new bool[this.screenWidth, this.screenHeight]; this.accum2 = new short[360 / ThetaIncrement, AccumLength / RhoIncrement]; // Build the accumlator array. Make is smaller or shorter based on the size of the rho and theta increments this.accum1 = new short[360 / ThetaIncrement, AccumLengthOld / RhoIncrement]; this.colorArray1D = new Color[this.screenWidth * this.screenHeight]; // Create a 1D array of color this.colorArrayDirectlyFromRobotCamera = new Color[this.screenWidth, this.screenHeight]; // Create a 2D array of color //this.houghInfo = new double[(11 * numberOfLinesToFind) + 5]; // Make the array to store hough information. Must be double so that slopes which are fractions can be stored // Set the color thresholds this.redGood = ((SimulationMain)Game).config.whiteParam; this.blueGood = ((SimulationMain)Game).config.whiteParam; this.greenGood = ((SimulationMain)Game).config.whiteParam; //this.houghLineStartandStopVectors = new Vector3[numberOfLinesToFind * 4]; // for (int i = 0; i < numberOfLinesToFind * 4; i++) // { // this.houghLineStartandStopVectors[i] = Vector3.Zero; //} this.middleValues = new int[this.screenHeight]; // Steering desisions are based off the average middle clear value for each row // Creates the image drawing analysis object. this.drawAnalysis = new DrawImageAnalysis(Game); this.Game.Components.Add(this.drawAnalysis); // Great a some Hough lines (the number that of lines we are trying to find) for (int i = 0; i < numberOfLinesToFind; i++) { HoughLines houghLine = new HoughLines(Game); this.Game.Components.Add(houghLine); this.houghLineList.Add(houghLine); } this.debugText = new DebugText(Game); this.debugText.imageAnalysisLinked = this; this.Game.Components.Add(this.debugText); this.lineErrorAnalysis = new LineErrorAnalysis(Game); // base.Initialize(); }
/// <summary> /// Initializes a new instance of the ImageAnalysis class. /// </summary> /// <param name="game">The game associated with the class</param> /// <param name="screenSize">The size of the sceen to analze</param> /// <param name="viewPortList1">A list of the view ports</param> public ImageAnalysis(Game game, Vector2 screenSize, List<Viewport> viewPortList1) : base(game) { this.screenWidth = (int)screenSize.X; this.screenHeight = (int)screenSize.Y; // Creates the image drawing analysis object. this.drawAnalysis = new DrawImageAnalysis(game, this.screenWidth, this.screenHeight, UpdateSquareDimForDrawing, UpdateSquareDimForAnalysis, NumberofLinesToFind, ThetaIncrement, RhoIncrement, viewPortList1, this); this.drawAnalysis.DrawOrder = game.Components.Count; Game.Components.Add(this.drawAnalysis); }