public _Tensor[] QLearningTensors() { Texture2D[] textures = textureQueue.ToArray(); _Tensor[] tensorCube = new _Tensor[textures.Length]; float[] yChannelValues; for (int i = 0; i < textures.Length; i++) { pixels = textures[i].GetPixels(); currentTextures[i] = new Texture2D(textures[i].width, textures[i].height, textureFormat, false); currentTextures[i].SetPixels(Preprocessing.RGB2Gray(pixels)); currentTextures[i].Apply(); yChannelValues = new float[pixels.Length]; for (int j = 0; j < pixels.Length; j++) { yChannelValues[j] = Preprocessing.RGB2Gray(pixels[j]).a; } tensorCube[i] = new _Tensor(yChannelValues, textures[i].width, textures[i].height); } return(tensorCube); }
public double[,,] GetInputTensor() { Texture2D[] textures = textureQueue.ToArray(); double[,,] result = new double[rtHeight, rtWidth, stepFrames]; int totalLength = rtHeight * rtWidth; float[] yValues; for (int i = 0; i < textures.Length; i++) { pixels = textures[i].GetPixels(); yValues = new float[pixels.Length]; for (int j = 0; j < yValues.Length; j++) { yValues[0] = Preprocessing.RGB2Gray(pixels[j]).a; } int row = 0; int column = 0; for (int pos = 0; pos < totalLength; pos++) { result[row, column, i] = yValues[pos]; column = (column + 1) % result.GetLength(1); if (column == 0) { row++; } } } return(result); }