1 using System.Collections.Generic;
8 namespace droid.Runtime.Prototyping.Sensors.Camera.Deprecated {
12 [AddComponentMenu(SensorComponentMenuPath._ComponentMenuPath
14 + SensorComponentMenuPath._Postfix)]
17 [SerializeField]
bool _black_white =
false;
19 [Header(
"Specific", order = 102)]
27 [SerializeField] Texture2D _texture = null;
32 [field : Header(
"Observation", order = 103)]
33 public float[] ObservationArray {
get;
private set; } = null;
44 if (this._manager == null) {
45 this._manager = FindObjectOfType<AbstractNeodroidManager>();
48 if (this._camera == null) {
49 this._camera = this.GetComponent<
UnityEngine.Camera>();
52 var target_texture = this._camera.targetTexture;
54 this._texture =
new Texture2D(target_texture.width, target_texture.height);
55 if (this._black_white) {
56 this.ObservationArray =
new float[this._texture.width * this._texture.height * 1];
58 this.ObservationArray =
new float[this._texture.width * this._texture.height * 3];
61 this.ObservationArray =
new float[0];
69 if (this._camera.targetTexture) {
84 var current_render_texture = RenderTexture.active;
85 var target_texture = this._camera.targetTexture;
86 RenderTexture.active = target_texture;
88 this._texture.ReadPixels(
new Rect(0, 0, target_texture.width, target_texture.height), 0, 0);
89 this._texture.Apply();
91 if (!this._black_white) {
92 for (var w = 0; w < this._texture.width; w++) {
93 for (var h = 0; h < this._texture.height; h++) {
94 var c = this._texture.GetPixel(w, h);
95 this.ObservationArray[this._texture.width * w + h * 3] = c.r;
96 this.ObservationArray[this._texture.width * w + h * 3 + 1] = c.g;
97 this.ObservationArray[this._texture.width * w + h * 3 + 2] = c.b;
101 for (var w = 0; w < this._texture.width; w++) {
102 for (var h = 0; h < this._texture.height; h++) {
103 var c = this._texture.GetPixel(w, h);
104 this.ObservationArray[this._texture.width * w + h] = (c.r + c.g + c.b) / 3;
109 RenderTexture.active = current_render_texture;
115 public override IEnumerable<float> FloatEnumerable {
get {
return this.ObservationArray; } }
123 Debug.LogWarning(
"WARNING! Camera Observations may be out of sync other data");
128 var manager = this._manager;
130 && manager.SimulatorConfiguration.SimulationType !=
SimulationType.Frame_dependent_) {
ISimulatorConfiguration SimulatorConfiguration
virtual void OnPostRender()
Contains everything relevant to configuring simulation environments engine specific settings ...
SimulationType SimulationType
virtual void UpdateArray()
SimulationType
Determines the discrete timesteps of the simulation environment.
override void UpdateObservation()