Forum

Author Topic: ViewPoint Rotation Matrix  (Read 2588 times)

giryit

  • Newbie
  • *
  • Posts: 2
    • View Profile
ViewPoint Rotation Matrix
« on: August 08, 2017, 11:14:22 PM »
Hello,

I am trying to generate a matching camera rotation matrix to the viewpoint. I use the "look through" option of camera 0 to get the correct viewpoint in the model viewer. From there, I want to reproduce chunk.cameras[0].transform using only the PhotoScan.app.viewpoint datastructure in my script.

I figured out I could get the translation component using the viewpoint center as follows:
chunk.transform.inv().mulp(PhotoScan.app.viewpoint.center)

However I could not get the same process to work on the rotation component.

Any help would be appreciated, thanks!


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: ViewPoint Rotation Matrix
« Reply #1 on: August 09, 2017, 11:44:13 AM »
Hello giryit,

You can use 3x3 matrix R from the following equation as camera.transform.rotation and vector t as camera.center:
Code: [Select]
R = PhotoScan.app.document.chunk.transform.matrix.rotation().inv() * PhotoScan.app.viewpoint.rot * PhotoScan.Matrix.Diag([1, -1, -1])
t = PhotoScan.app.document.chunk.transform.matrix.inv().mulp(PhotoScan.app.viewpoint.center)
Best regards,
Alexey Pasumansky,
Agisoft LLC

giryit

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: ViewPoint Rotation Matrix
« Reply #2 on: August 09, 2017, 09:29:18 PM »
Thank you, that worked nicely!

I have one followup question. I am now capturing the model view, and storing it as a .jpg, and I want to add a marker projection based on this 2D image. However, the coordinate of the marker in this viewpoint image does not seem to correspond to the coordinate in the actual image in a way which I comprehend. A toy example is as follows:

1. All camera dimensions are set at 2000x2000
2. Model viewer dimensions are set at 500x300
3. I "look through" camera 0
4. I capture the 500x300 image from the model viewpoint
5. I label a point on that 500x300 image

At this stage I want to be able to take that labelled point from the 500x300 viewpoint image and map it to the corresponding point on the 2000x2000 image.