# Endoscopy flythrough loop doesn't start from the same camera angle and changes every loop

**URL:** <https://discourse.slicer.org/t/endoscopy-flythrough-loop-doesnt-start-from-the-same-camera-angle-and-changes-every-loop/15961>\
**Category:** Development\
**Tags:** python\
**Created:** [February 11, 2021, 10:34pm UTC](https://discourse.slicer.org/t/endoscopy-flythrough-loop-doesnt-start-from-the-same-camera-angle-and-changes-every-loop/15961 "2021-02-11T22:34:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [February 11, 2021, 10:34pm UTC](https://discourse.slicer.org/t/endoscopy-flythrough-loop-doesnt-start-from-the-same-camera-angle-and-changes-every-loop/15961/1 "2021-02-11T22:34:07Z")

</div>

Operating system: Windows 10  
Slicer version: 4.11.20200930  
I am using the endoscopy module and in it, the flythrough works fine but once one loop is over the camera angle(or up, down) changes and starts from a different angle. is there any way to fix the camera orientation?  
Also, can the camera be set to one view and not rotate every loop.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 14, 2021, 6:17am UTC](https://discourse.slicer.org/t/endoscopy-flythrough-loop-doesnt-start-from-the-same-camera-angle-and-changes-every-loop/15961/2 "2021-02-14T06:17:39Z")

</div>

There are many methods for moving a camera along a curve. The current method just updates the camera view plane normal and orthogonalizes the axes ([Slicer/Endoscopy.py at master · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/blob/master/Modules/Scripted/Endoscopy/Endoscopy.py#L300)).

We compute a transform that keeps one axis of the frame orthogonal to the curve’s plane ([Slicer/Endoscopy.py at master · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/blob/master/Modules/Scripted/Endoscopy/Endoscopy.py#L314-L318)). You could change the Endoscopy module (it is just a Python script, you can edit with any text editor then click “Reload”) to use these axes as camera plane normal and view up directions.

Markups curves can provide coordinate frame for each curve point, too  
(computed by parallel transport method). You could modify the code to use these axes (returned by  
[GetCurvePointToWorldTransformAtPointIndex()](https://apidocs.slicer.org/master/classvtkMRMLMarkupsCurveNode.html#ab23760b90d69d1b2e8392c75ce0a7123)).

---

<div class="post-metadata">

**Author:** ![akshay\_pillai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/akshay_pillai/32/8301_2.png) [@akshay\_pillai](https://discourse.slicer.org/u/akshay_pillai)\
**Post date:** [February 17, 2021, 9:54pm UTC](https://discourse.slicer.org/t/endoscopy-flythrough-loop-doesnt-start-from-the-same-camera-angle-and-changes-every-loop/15961/3 "2021-02-17T21:54:21Z")

</div>

Thanks, this pointed me in the right direction

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 17, 2021, 11:34pm UTC](https://discourse.slicer.org/t/endoscopy-flythrough-loop-doesnt-start-from-the-same-camera-angle-and-changes-every-loop/15961/4 "2021-02-17T23:34:57Z")

</div>

If you make any improvements to the camera trajectory creation in Endoscopy module then it would be great if you could contribute it back. It allows other users benefit from your work and you can save time by not having to maintain your own version of the module.
