2 using System.Collections.Generic;
10 namespace droid.Runtime.Prototyping.Sensors.Camera.Deprecated {
11 [AddComponentMenu(SensorComponentMenuPath._ComponentMenuPath
12 +
"NativeColorArrayCamera" 13 + SensorComponentMenuPath._Postfix)]
16 [Header(
"Specific", order = 102)]
24 [SerializeField] Texture2D _texture = null;
29 [field : Header(
"Observation", order = 103)]
30 public float[] ObservationArray {
get;
private set; }
38 if (this._manager == null) {
39 this._manager = FindObjectOfType<AbstractNeodroidManager>();
42 if (this._camera == null) {
43 this._camera = this.GetComponent<
UnityEngine.Camera>();
46 var target_texture = this._camera.targetTexture;
48 this.ObservationArray =
new float[target_texture.width * target_texture.height * 4];
51 Debug.LogWarning(
"Texture not available!");
53 this._texture =
new Texture2D(NeodroidConstants._Default_Width,
54 NeodroidConstants._Default_Height,
55 NeodroidConstants._Default_TextureFormat,
57 this.ObservationArray =
new float[this._texture.width * this._texture.height * 4];
70 if (this._camera.targetTexture) {
75 Graphics.DrawTexture(
new Rect(
new Vector2(0,0),
new Vector2(128,128)), this._texture);
91 var current_render_texture = RenderTexture.active;
92 RenderTexture.active = this._camera.targetTexture;
95 && this._camera.targetTexture.width ==
this._texture.width
96 &&
this._camera.targetTexture.height ==
this._texture.height) {
97 this._texture.ReadPixels(
new Rect(0, 0, this._texture.width,
this._texture.height), 0, 0);
101 Debug.LogWarning(
"Texture not available!");
103 this._texture =
new Texture2D(this._camera.targetTexture.width,
104 this._camera.targetTexture.height,
105 NeodroidConstants._Default_TextureFormat,
107 this.ObservationArray =
new float[this._texture.width * this._texture.height * 4];
114 var a = this._texture.GetRawTextureData<Color>();
132 for (var index = 0; index < a.Length; index++) {
135 this.ObservationArray[i] = b.r;
136 this.ObservationArray[i + 1] = b.g;
137 this.ObservationArray[i + 2] = b.b;
138 this.ObservationArray[i + 3] = b.a;
144 max[0] = Mathf.Max(b[0], max[0]);
145 min[0] = Mathf.Min(b[0], min[0]);
146 max[1] = Mathf.Max(b[1], max[1]);
147 min[1] = Mathf.Min(b[1], min[1]);
148 max[2] = Mathf.Max(b[2], max[2]);
149 min[2] = Mathf.Min(b[2], min[2]);
150 max[3] = Mathf.Max(b[3], max[3]);
151 min[3] = Mathf.Min(b[3], min[3]);
158 Debug.Log($
"len(a):{a.Length}, min:{min}, max:{max}");
161 RenderTexture.active = current_render_texture;
163 Debug.LogWarning($
"No camera found on {this}");
167 public override String PrototypingTypeName {
get {
return ""; } }
169 public override IEnumerable<float> FloatEnumerable {
178 Debug.Log($
"{this._manager?.SimulatorConfiguration?.SimulationType}");
179 if (Application.isPlaying) {
180 this._camera.Render();
192 var rep = $
"Float Array (Length: {this.ObservationArray.Length}), " 193 + $
"Sample [{Mathf.Clamp01(this.ObservationArray[0])}.." 194 + $
"{Mathf.Clamp01(this.ObservationArray[this.ObservationArray.Length - 1])}]";
override string ToString()
virtual void UpdateArray()
override void UpdateObservation()
Contains everything relevant to configuring simulation environments engine specific settings ...
virtual void OnPostRender()
SimulationType
Determines the discrete timesteps of the simulation environment.