protected virtual void ProcessRetina(Texture2D tex, Texture2D tex2) { int x, y, width, height; //width represents the width of each retinal patch width = (int)(this.retinaWidth / this.retinalColumns); //height represents the height of each retinal patch height = (int)(this.retinaHeight / this.retinalRows); //loop through the retinal patches for (int i = 0; i < this.retinalColumns; i++) { for (int j = 0; j < this.retinalRows; j++) { //calculate the x and y positions of the patch x = i * width; y = j * height; this.retinalPatchesVisualInfo [i, j] = this.GetColorInformationFromPatch(tex, x, y, width, height, i, j); } } if (this.RecordEyeTestData()) { EyeTestData eyeData = new EyeTestData(this._tag, tex, tex2, this.hasColorVision, this.isComplexEye, this.retinalPatchesVisualInfo); this.eyeTest.WriteTestData(eyeData); this.lastEyeTestTime = Time.time; } }
internal void WriteTestData(EyeTestData data) { //Debug.Log ("writing eye test data:" + data.Tag); //if there was an initialization error then return if (this.initializationError) { return; } // if the relevant amount of time has not passed then return if (this.timeInterval > Time.time) { return; } this.counter++; // encode the texture into a PNG byte[] bytes = data.mainTexture.EncodeToPNG(); //write the texture to a file System.IO.File.WriteAllBytes(System.IO.Path.Combine(this.outputFolder, data.tag + "_" + data.time + ".png"), bytes); if (data.processedTexture != null) { byte[] bytes2 = data.processedTexture.EncodeToPNG(); //write the texture to a file System.IO.File.WriteAllBytes(System.IO.Path.Combine(this.outputFolder, data.tag + "_" + data.time + "_processed.png"), bytes2); } //write the eye data to a file System.IO.File.WriteAllText(System.IO.Path.Combine(this.outputFolder, data.tag + "_" + data.time + ".txt"), data.ToString()); //update the time interval this.timeInterval = Time.time + this.rate; }