[Amira / Avizo]
Context
In Amira-Avizo, the camera type determines how 3D objects are projected and displayed in the viewer. Choosing the appropriate camera projection can be important depending on whether the goal is realistic 3D visualization, visual inspection, or geometric comparison.
Two main camera types are available:
- Perspective (default): Provides a realistic view in which objects farther from the camera appear smaller than objects that are closer. This projection is generally well suited for exploring and understanding 3D structures and spatial relationships.
- Orthographic: Displays objects without perspective distortion. Their apparent size does not change with their distance from the camera. This projection can be particularly useful for technical visualization, geometric inspection, and situations where dimensions or relative sizes need to be visually compared without the influence of perspective.
Understanding the difference between these two camera types helps users select the most appropriate visualization mode for their workflow and determine how to perform zoom operations through scripting.
Description
For each camera type, the following values can be set:
- For a perspective camera, the height angle represents the vertical angle, in degrees, of the viewing volume. For orthographic camera, the height represents the height of the viewing volume.
- The camera position is defined in the same way for both camera types and represents the coordinates in 3D space where the camera is located.
- The near distance represents the distance from the camera viewpoint to the near clipping plane.
- The far distance represents the distance from the camera viewpoint to the far clipping plane.
- The focal distance represents the distance from the camera viewpoint to the focal point. This parameter is generally not used unless a specific point of interest is required, for example, to apply a depth-of-field blurring:
Accessing Camera Properties Through Scripting
From a scripting perspective, these camera parameters can be accessed through both the Tcl and Python consoles. In Tcl, the current camera settings can be retrieved using the getCamera command. For example:
Tcl script: GET/SET Camera (click to expand/collapse)
Get the current camera settings for Viewer 0:
>viewer 0 getCamera
viewer setCameraOrientation 1 0 0 3.14159
viewer setCameraPosition 3.2615 2.255 -2.90692
viewer setCameraFocalDistance 4.00692
viewer setCameraNearDistance 4.00291
viewer setCameraFarDistance 4.01093
viewer setCameraType perspective
viewer setCameraHeightAngle 44.9023
To assign the same camera settings to Viewer 1, copy the lines printed above and change the viewer number accordingly. The viewer number is optional and defaults to 0:
viewer 1 setCameraOrientation 1 0 0 3.14159
viewer 1 setCameraPosition 3.2615 2.255 -2.90692
viewer 1 setCameraFocalDistance 4.00692
viewer 1 setCameraNearDistance 4.00291
viewer 1 setCameraFarDistance 4.01093
viewer 1 setCameraType perspective
viewer 1 setCameraHeightAngle 44.9023
For Python, refer to the HxCamera, HxOrthographicCamera, HxPerspectiveCamera documentation under Developer > Documentation > Amira-Avizo Python API. The camera can be accessed through the viewer manager.
The following method can be used to display the values of all camera parameters:
Python script: GET/SET (click to expand/collapse)
Get the current camera settings for viewer 0:
def printcamera():
print(f"hx_viewer_manager.viewers[0].camera.orientation = {hx_viewer_manager.viewers[0].camera.orientation}")
print(f"hx_viewer_manager.viewers[0].camera.position = {hx_viewer_manager.viewers[0].camera.position}")
print(f"hx_viewer_manager.viewers[0].camera.focal_distance = {hx_viewer_manager.viewers[0].camera.focal_distance}")
print(f"hx_viewer_manager.viewers[0].camera.near_distance = {hx_viewer_manager.viewers[0].camera.near_distance}")
print(f"hx_viewer_manager.viewers[0].camera.far_distance = {hx_viewer_manager.viewers[0].camera.far_distance}")
camera_type = type(hx_viewer_manager.viewers[0].camera).__name__
if camera_type == 'HxOrthographicCamera':
print("hx_viewer_manager.viewers[0].camera = HxOrthographicCamera()")
print(f"hx_viewer_manager.viewers[0].camera.height_angle = {hx_viewer_manager.viewers[0].camera.height}")
else:
print("hx_viewer_manager.viewers[0].camera = HxPerspectiveCamera()")
print(f"hx_viewer_manager.viewers[0].camera.height_angle = {hx_viewer_manager.viewers[0].camera.height_angle}")>>>printcamera()
hx_viewer_manager.viewers[0].camera.orientation = ((1.0, 0.0, 0.0), 3.1415927410125732)
hx_viewer_manager.viewers[0].camera.position = (3.2614998817443848, 2.255000114440918, -2.9069180488586426)
hx_viewer_manager.viewers[0].camera.focal_distance = 4.006917953491211
hx_viewer_manager.viewers[0].camera.near_distance = 4.00291109085083
hx_viewer_manager.viewers[0].camera.far_distance = 4.01092529296875
hx_viewer_manager.viewers[0].camera = HxPerspectiveCamera()
hx_viewer_manager.viewers[0].camera.height_angle = 0.7836931943893433
To assign the same camera settings to Viewer 1, copy the lines printed above and change the viewer number accordingly:
hx_viewer_manager.viewers[1].camera.orientation = ((1.0, 0.0, 0.0), 3.1415927410125732)
hx_viewer_manager.viewers[1].camera.position = (3.2614998817443848, 2.255000114440918, -2.9069180488586426)
hx_viewer_manager.viewers[1].camera.focal_distance = 4.006917953491211
hx_viewer_manager.viewers[1].camera.near_distance = 4.00291109085083
hx_viewer_manager.viewers[1].camera.far_distance = 4.01092529296875
hx_viewer_manager.viewers[1].camera = HxPerspectiveCamera()
hx_viewer_manager.viewers[1].camera.height_angle = 0.7836931943893433
Controlling Zoom
Among the available camera properties, zoom is generally controlled by:
- Orthographic camera:
setCameraHeightcan be used to control the zoom level. - Perspective camera:
setCameraHeightAnglecontrols the field of view and can be used to change the zoom level.
These commands do not move the camera closer to or farther from the object. Instead, they modify the size or angle of the viewing volume:
- Smaller value → smaller field of view → object appears larger (zoom in)
- Larger value → larger field of view → objects appears smaller (zoom out)
Reducing the camera height or height angle therefore produces a zoom-in effect by narrowing the visible field. However, for a Perspective camera, if the goal is simply to make an object appear larger without changing the perspective characteristics, it is generally preferable to move the camera closer to the object (often referred to as dollying in) rather than modifying the camera's field of view.
→ Load the tutorial dataset located at <your installation folder>\data\tutorials\chocolat-bar.am and attach both a Volume Rendering module and an Ortho Slice module:
- To zoom in, decrease the camera's
height anglevalue:
hx_viewer_manager.viewers[0].camera.height_angle = 0.3
A smaller height angle reduces the field of view, making the object appear larger.
- To zoom out, increase the camera's
height anglevalue:
hx_viewer_manager.viewers[0].camera.height_angle = 20
A larger height angle increases the field of view, making the object appear smaller.
Notes
When managing zoom, some exceptions may occur. For example, with an Orthographic camera, the zoom behavior depends on the aspect ratio of the viewer window.
- When viewer width ≥ viewer height, the camera height can generally remain unchanged.
- When viewer width < viewer height, the visible horizontal area becomes smaller while the camera height remains fixed.
For a narrow viewer (width < height), the camera height can be adjusted to maintain a similar visible area. In this case, adjust the camera height using the viewer aspect ratio:
Adjusted Camera Height = Camera Height × (Viewer Width / Viewer Height)
The example below illustrates a case where:
- The camera height is set to 0.7789, but
- the effective height differs due to the aspect-ratio adjustment.
Related Links
For more details on viewer commands, refer to the documentation page Developer Tools > Tcl Scripting > Viewer Command Options.
