# How to define camera perspective of 3D view window

**URL:** <https://discourse.slicer.org/t/how-to-define-camera-perspective-of-3d-view-window/17136>\
**Category:** Support\
**Created:** [April 16, 2021, 5:23pm UTC](https://discourse.slicer.org/t/how-to-define-camera-perspective-of-3d-view-window/17136 "2021-04-16T17:23:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deferd](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@deferd](https://discourse.slicer.org/u/deferd)\
**Post date:** [April 16, 2021, 5:23pm UTC](https://discourse.slicer.org/t/how-to-define-camera-perspective-of-3d-view-window/17136/1 "2021-04-16T17:23:56Z")

</div>

Hello

I am trying to control the perspective of an X-ray-like image generated from CT data. E.g., I would like to define the distance between the focal point and a specific anatomical feature and control the viewing angle so that the perspective (distortion) of the X-ray-like image is equal to an actual X-ray.

I am able to generate an image that looks quite similar to an x-ray (using volume rendering - CT-X-Ray properties) and I am able to zoom, rotate the viewing angle and change the focal axis with my mouse, however I am unable to quantify or define these values.

Is there a way to access this perspective information and to actively control them?

Thank you for your help

Best  
deferd

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [April 16, 2021, 6:56pm UTC](https://discourse.slicer.org/t/how-to-define-camera-perspective-of-3d-view-window/17136/2 "2021-04-16T18:56:15Z")

</div>

Here is how I was able to do it:

```auto
viewNode = slicer.mrmlScene.GetSingletonNode("1", "vtkMRMLViewNode")
cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(viewNode)
position = [0,0,0]
focalPoint = [20,20,20]
viewUpDirection = [0,1,0]
cameraNode.SetPosition(position)
cameraNode.SetFocalPoint(focalPoint)
cameraNode.SetViewUp(viewUpDirection)

```

---

<div class="post-metadata">

**Author:** ![deferd](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@deferd](https://discourse.slicer.org/u/deferd)\
**Post date:** [April 19, 2021, 7:14am UTC](https://discourse.slicer.org/t/how-to-define-camera-perspective-of-3d-view-window/17136/3 "2021-04-19T07:14:28Z")

</div>

Hello Mauro,

thank you for your fast response, your solution is extremely useful. I could further define the camera angle with:  
cameraNode.SetViewAngle().

Am I correct in assuming that the coordinates are global coordinates? And do you know if there is a simple way to transform these coordinates into metric measures?

Also, is there a way to access the coordinates of the camera position, focal point etc. after manual manipulation?

Best

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [April 19, 2021, 7:57pm UTC](https://discourse.slicer.org/t/how-to-define-camera-perspective-of-3d-view-window/17136/4 "2021-04-19T19:57:28Z")

</div>

> [@deferd](#):
>
> Am I correct in assuming that the coordinates are global coordinates? And do you know if there is a simple way to transform these coordinates into metric measures?

From what I know this coordinates are in RAS and longitudes are measured in mm.

> [@deferd](#):
>
> Also, is there a way to access the coordinates of the camera position, focal point etc. after manual manipulation?

You can change “Set” by “Get” in the previous methods to get the information you want. I think you have to provide a list of lenght equal 3 as parameter of the function
