浏览代码

Optimize BatchVisualObservations

/hotfix-v0.9.2a
maxiaoxiao1991 7 年前
当前提交
8f3c5a11
共有 1 个文件被更改,包括 11 次插入10 次删除
  1. 21
      unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs

21
unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs


else
pixels = 3;
float[,,,] result = new float[batchSize, height, width, pixels];
float[] resultTemp = new float[batchSize * height * width * pixels];
int hwp = height * width * pixels;
int wp = width * pixels;
for (int w = 0; w < width; w++)
for (int h = height - 1; h >= 0; h--)
for (int h = 0; h < height; h++)
for (int w = 0; w < width; w++)
Color32 currentPixel = cc[h * width + w];
Color32 currentPixel = cc[(height - h - 1) * width + w];
result[b, textures[b].height - h - 1, w, 0] =
currentPixel.r / 255.0f;
result[b, textures[b].height - h - 1, w, 1] =
currentPixel.g / 255.0f;
result[b, textures[b].height - h - 1, w, 2] =
currentPixel.b / 255.0f;
resultTemp[b * hwp + h * wp + w * pixels] = currentPixel.r / 255.0f;
resultTemp[b * hwp + h * wp + w * pixels + 1] = currentPixel.g / 255.0f;
resultTemp[b * hwp + h * wp + w * pixels + 2] = currentPixel.b / 255.0f;
result[b, textures[b].height - h - 1, w, 0] =
resultTemp[b * hwp + h * wp + w * pixels] =
(currentPixel.r + currentPixel.g + currentPixel.b)
/ 3;
}

System.Buffer.BlockCopy(resultTemp, 0, result, 0, batchSize * hwp * sizeof(float));
return result;
}
正在加载...
取消
保存