Skip to content

Commit

Permalink
trying to avoid sigsev
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroHG committed Nov 22, 2024
1 parent 8c9689f commit fa04b3a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
42 changes: 22 additions & 20 deletions test_distortion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def load_scene(scene_name, house_path=None, run_in_editor=False, platform=None,
server_class=ai2thor.wsgi_server.WsgiServer,
)

enableDistortionMap = False

all_args = dict(
# local_executable_path="unity/builds/thor-OSXIntel64-local/thor-OSXIntel64-local.app/Contents/MacOS/AI2-THOR",
# local_build=True,
Expand All @@ -40,7 +42,7 @@ def load_scene(scene_name, house_path=None, run_in_editor=False, platform=None,
renderDistortionImage=distortion,
renderSemanticSegmentation=True,
renderInstanceSegmentation=True,
enableDistortionMap=distortion,
enableDistortionMap=enableDistortionMap,
fieldOfView=120,
**args,
)
Expand Down Expand Up @@ -103,25 +105,25 @@ def load_scene(scene_name, house_path=None, run_in_editor=False, platform=None,
intensityX=0.91,
intensityY=0.93
)

evt = controller.step(
action="GetDistortionMaps",
mainCamera=True,
thidPartyCameraIndices=[0]
)
distortionMaps = evt.metadata['actionReturn']
# keys = [key for (key, val) in result.items()]
maps = []

print(f"---Action {controller.last_action['action']} success: {evt.metadata['lastActionSuccess']} result {distortionMaps.keys()}")
# result is dict with 3d arrays in the following:
# {'mainCamera': float[height][width][2], 'thirdPartyCameras': float[thirdPartyCameraCount][height][width][2] }
print(f"[x,y] at (0,0) (bottom left corner) len {distortionMaps['mainCamera'][0][0]}")
tex_height = len(distortionMaps['mainCamera'])
tex_width = len(distortionMaps['mainCamera'][0])
print(f"[x,y] at (height, width) (top right corner) len {distortionMaps['thirdPartyCameras'][0][tex_height-1][tex_width-1]}")

print(f'Error: {evt.metadata["errorMessage"]}')
if enableDistortionMap:
evt = controller.step(
action="GetDistortionMaps",
mainCamera=True,
thidPartyCameraIndices=[0]
)
distortionMaps = evt.metadata['actionReturn']
# keys = [key for (key, val) in result.items()]
maps = []
print(f"---Action {controller.last_action['action']} success: {evt.metadata['lastActionSuccess']} result {distortionMaps.keys()}")
# result is dict with 3d arrays in the following:
# {'mainCamera': float[height][width][2], 'thirdPartyCameras': float[thirdPartyCameraCount][height][width][2] }
print(f"[x,y] at (0,0) (bottom left corner) len {distortionMaps['mainCamera'][0][0]}")
tex_height = len(distortionMaps['mainCamera'])
tex_width = len(distortionMaps['mainCamera'][0])
print(f"[x,y] at (height, width) (top right corner) len {distortionMaps['thirdPartyCameras'][0][tex_height-1][tex_width-1]}")

print(f'Error: {evt.metadata["errorMessage"]}')


# xpos = dict(x=0.0, y=0.900992214679718, z=0.0786)
Expand Down
2 changes: 1 addition & 1 deletion unity/Assets/Scripts/CapturePass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ protected RenderTexture CreateRenderTexture(int width, int height) {
this.renderTextureFormat = RenderTextureFormat.ARGB32;
}

rt = new RenderTexture(Screen.width, Screen.height, this.depthBits, this.renderTextureFormat, RenderTextureReadWrite.Default);
rt = new RenderTexture(Screen.width, Screen.height, 24, this.renderTextureFormat, RenderTextureReadWrite.Default);
// readTextureFormat = TextureFormat.RGBA32;

// RenderTextureFormat.RGFloat
Expand Down
12 changes: 6 additions & 6 deletions unity/Assets/Scripts/RenderingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,29 +167,29 @@ void Awake() {
cloudRenderingCapture = true;
#endif


//cloudRendering = cloudRenderingCapture, renderTextureFormat = RenderTextureFormat.RFloat
var depthPass = new RenderToTexture(
new CaptureConfig() { name = "_depth", antiAliasLevel = antiAliasLevel, depthBits = 32, shaderName = "Hidden/DepthBW", cloudRendering = cloudRenderingCapture, renderTextureFormat = RenderTextureFormat.RFloat },
new CaptureConfig() { name = "_depth", antiAliasLevel = antiAliasLevel, depthBits = 0, shaderName = "Hidden/DepthBW" },
camera: camera
);

var distPass = new RenderToTexture(
new CaptureConfig() { name = "_distortion", antiAliasLevel = antiAliasLevel, shaderName = "Custom/BarrelDistortion", cloudRendering = cloudRenderingCapture },
new CaptureConfig() { name = "_distortion", antiAliasLevel = antiAliasLevel, shaderName = "Custom/BarrelDistortion" },
camera: camera
);

var idPass = new ReplacementShaderCapture(
new CaptureConfig() { name = "_id", antiAliasLevel = antiAliasLevel, shaderName = "Hidden/UberReplacement", replacementMode = ReplacelementMode.ObjectId, toDisplay = IsMainCamera? 2 : null as int?, cloudRendering = cloudRenderingCapture },
new CaptureConfig() { name = "_id", antiAliasLevel = antiAliasLevel, shaderName = "Hidden/UberReplacement", replacementMode = ReplacelementMode.ObjectId, toDisplay = IsMainCamera? 2 : null as int? },
cameraParent: camera.transform
);

var classPass = new ReplacementShaderCapture(
new CaptureConfig() { name = "_class", antiAliasLevel = antiAliasLevel, shaderName = "Hidden/UberReplacement", replacementMode = ReplacelementMode.CatergoryId, toDisplay = IsMainCamera? 3 : null as int?, cloudRendering = cloudRenderingCapture },
new CaptureConfig() { name = "_class", antiAliasLevel = antiAliasLevel, shaderName = "Hidden/UberReplacement", replacementMode = ReplacelementMode.CatergoryId, toDisplay = IsMainCamera? 3 : null as int? },
cameraParent: camera.transform
);

var normalsPass = new ReplacementShaderCapture(
new CaptureConfig() { name = "_normals", antiAliasLevel = antiAliasLevel, shaderName = "Hidden/UberReplacement", replacementMode = ReplacelementMode.Normals, cloudRendering = cloudRenderingCapture },
new CaptureConfig() { name = "_normals", antiAliasLevel = antiAliasLevel, shaderName = "Hidden/UberReplacement", replacementMode = ReplacelementMode.Normals },
cameraParent: camera.transform
);

Expand Down

0 comments on commit fa04b3a

Please sign in to comment.