# how to set the camera to a fixed focus camera

**URL:** <https://discourse.vtk.org/t/how-to-set-the-camera-to-a-fixed-focus-camera/11168>\
**Category:** Development\
**Tags:** python\
**Created:** [April 9, 2023, 10:30am UTC](https://discourse.vtk.org/t/how-to-set-the-camera-to-a-fixed-focus-camera/11168 "2023-04-09T10:30:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xu\_siang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xu_siang/32/6860_2.png) [@xu\_siang](https://discourse.vtk.org/u/xu_siang)\
**Post date:** [April 9, 2023, 10:30am UTC](https://discourse.vtk.org/t/how-to-set-the-camera-to-a-fixed-focus-camera/11168/1 "2023-04-09T10:30:38Z")

</div>

Hi everyone,  
I want to know is there any function in vtk that can set the camera to a fixed focus camera? I want the focal length to be a fixed constant which won’t change when I move my camera.  
I use python vtk 8.2.0.  
Thank you!

---

<div class="post-metadata">

**Author:** ![charly\_bollinger](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charly_bollinger/32/6973_2.png) [@charly\_bollinger](https://discourse.vtk.org/u/charly_bollinger)\
**Post date:** [April 21, 2023, 2:16pm UTC](https://discourse.vtk.org/t/how-to-set-the-camera-to-a-fixed-focus-camera/11168/2 "2023-04-21T14:16:19Z")

</div>

Hi,

Did you solve your issue? I’m not sure to understand what you want.

When you move your camera’s position, it doesn’t change your target position (ie `FocalPoint`). Do you want to keep the distance between camera’s position and its focal point constant, or do you mean the `FocalDistance` that is used for focus when using ray tracing renderers?

As far as I’m aware, there is no function that allows setting a constant distance between camera’s position and its focal point but you may find useful the `Distance` property that moves the `FocalPoint` to a given distance from `Position` or `DirectionOfProjection` that gives the direction from the camera position to the focal point.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [April 21, 2023, 4:40pm UTC](https://discourse.vtk.org/t/how-to-set-the-camera-to-a-fixed-focus-camera/11168/3 "2023-04-21T16:40:10Z")

</div>

I don’t quite understand the question, either. But I’ll make a guess that it’s really a question about interaction.

With VTK’s default interaction style, when you “zoom in”, it moves the camera closer to the focal point. This changes the distance, and therefore changes the perspective. There is no interaction style in VTK that allows you to “zoom in” by changing the field of view (and hence keeping the same perspective).

The only simple way around this is to call `camera.ParallelProjectionOn()`, which turns perspective off completely. If you don’t need perspective, this is the best solution.

But if you do need perspective, but need to keep the perspective constant, the only real solution is to customize the VTK interaction (which is possible). A custom interaction mode that used `camera.SetViewAngle()` would be able to change the field of view without changing the perspective.

---

<div class="post-metadata">

**Author:** ![xu\_siang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xu_siang/32/6860_2.png) [@xu\_siang](https://discourse.vtk.org/u/xu_siang)\
**Post date:** [April 22, 2023, 7:43am UTC](https://discourse.vtk.org/t/how-to-set-the-camera-to-a-fixed-focus-camera/11168/4 "2023-04-22T07:43:59Z")

</div>

Thanks a lot for your kind reply!  
I think what you’re saying is exactly what I want.I found when I use Right Click to move my camera,the camera position is changed but focalpoint isn’t move.I wish the distance between camera position and focalpoint won’t change because my real camera is a fixed-focus camera.Now I use **interactor.AddObserver** to move camera and let the distance be fixed by **SetPosition** and **SetFocalPoint**.
