Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

59 行
1.8 KiB

using UnityEngine;
namespace MLAgents
{
/// <summary>
/// A SensorComponent that creates a <see cref="CameraSensor"/>.
/// </summary>
[AddComponentMenu("ML Agents/Camera Sensor", (int)MenuGroup.Sensors)]
public class CameraSensorComponent : SensorComponent
{
/// <summary>
/// Camera object that provides the data to the sensor.
/// </summary>
public new Camera camera;
/// <summary>
/// Name of the generated <see cref="CameraSensor"/> object.
/// </summary>
public string sensorName = "CameraSensor";
/// <summary>
/// Width of the generated image.
/// </summary>
public int width = 84;
/// <summary>
/// Height of the generated image.
/// </summary>
public int height = 84;
/// <summary>
/// Whether to generate grayscale images or color.
/// </summary>
public bool grayscale;
/// <summary>
/// The compression type to use for the sensor.
/// </summary>
public SensorCompressionType compression = SensorCompressionType.PNG;
/// <summary>
/// Creates the <see cref="CameraSensor"/>
/// </summary>
/// <returns>The created <see cref="CameraSensor"/> object for this component.</returns>
public override ISensor CreateSensor()
{
return new CameraSensor(camera, width, height, grayscale, sensorName, compression);
}
/// <summary>
/// Computes the observation shape of the sensor.
/// </summary>
/// <returns>The observation shape of the associated <see cref="CameraSensor"/> object.</returns>
public override int[] GetObservationShape()
{
return CameraSensor.GenerateShape(width, height, grayscale);
}
}
}