Forum

Author Topic: Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model  (Read 6790 times)

mcstieg

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model
« on: December 29, 2017, 11:35:33 AM »
Hello Alexey,

I've been programming with python in the last 2 weeks and created some nice personal tools for Photoscan.
Now I want to write some code which should do the following:

I know some "correct" values of my cams orientation from my selfmade IMU. These are:
  - yaw+pitch+roll [degrees]
  - altitude [m]
  - gps coordinates
  - accuracy for each value

Of course I want to let PhotoScan process these values to have (pre-)scaled but well rotated model.
How can I import these values to my cams? 
I don't know where to store Pitch,Roll,Yaw ...

To give you an example:
Please see the EXIF of a MavicPro-IMU attached. I guess the orientation PhotoScan reads from EXIF are not the ones it should read - am I right?
I can access Pitch_Value = chunk.cameras[camnum].photo.meta["DJI/GimbalPitchDegree"]) but I don't know where to store these values and how to tell PhotoScan to use them for alignment,

Please let me know if you can help me with that! Thank you!
All the best for the new year!  :)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14107
    • View Profile
Re: Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model
« Reply #1 on: December 29, 2017, 11:50:20 AM »
Hello mcstieg,

You can access the source values for the camera orientation angles using camera.reference.rotation:

Code: [Select]
for camera in chunk.cameras:
   yaw = float(camera.photo.meta["DJI/GimbalYawDegree"])
   pitch = float(camera.photo.meta["DJI/GimbalPitchDegree"])
   roll = float(camera.photo.meta["DJI/GimbalRollDegree"])
   camera.reference.rotation = PhotoScan.Vector([yaw, pitch, roll])
Best regards,
Alexey Pasumansky,
Agisoft LLC

mcstieg

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model
« Reply #2 on: December 29, 2017, 12:23:38 PM »
That was quick  ;D Thanks for that!

Some questions:
1) Are these orientation values used only when aligning cameras with reference preselection?

2) How does PhotoScan expect Pitch & Roll ...
      -90° pitch is down?
      -90° roll is rolling left?
      -90° yaw is west?

3) Where can I store the accuracy for yaw, pitch, roll?

4) Where can I store my own better GPS coordinates and the better accuracy for them?

5) Do I need to update something after adding my values or just align my cams?

THANK YOU SO MUCH!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14107
    • View Profile
Re: Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model
« Reply #3 on: December 29, 2017, 04:35:50 PM »
Hello mcstieg,

1. Angles would be used for the Reference pre-selection only if Ground Altitude value is defined for the chunk:
Code: [Select]
chunk.meta["ground_altitude"] = "110"Also the values will be used according to their weights (either global or individual - camera.reference.rotation_accuracy) during the optimization process and final step of the Align Photos stage, if cameras are checked on in the Reference pane (camera.reference.enabled = True)

2. In PhotoScan the following convention is used:
Yaw is a counterclockwise rotation around Z axis
Pitch is a clockwise rotation around X axis
Roll is a clockwise rotation around Y axis
 
Code: [Select]
R = Rz(-yaw) * Rx(pitch) * Ry(roll) It comes to an accordance with the Wikipedia definition (https://en.wikipedia.org/wiki/Aircraft_principal_axes) in case the coordinate system related to the aircraft is defined in the following way:
 Z axis pointing upwards,
 X axis pointing to the right (to the right wing),
 Y axis pointing forward (to the aircraft nose).

3. Global parameters are in chunk.camera_rotation_accuracy, also you can set it individually for each camera:
Code: [Select]
camera.reference.rotation_accuracy = PhotoScan.Vector([yaw_acc, pitch_acc, roll_acc])
4. camera.reference.location and camera.reference.location_accuracy

5. You can just run image matching / alignment process after modification of the reference information.
Best regards,
Alexey Pasumansky,
Agisoft LLC

mcstieg

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model
« Reply #4 on: December 30, 2017, 09:22:29 PM »
Hello Alexey,

1) Do I understand correctly...?
- pos. pitch = nose up
- pos. roll = left wing up
- pos. yaw = turn from north to east (to right)

2) I guess the min/max values for pitch, roll, yaw are different...
- Pitch: Level=0°; -90 (nose down) to +90 (nose up)
- Roll: Level=0°; +-180° ... Roll left wing down = -90°
- Yaw: North = 0;   East=+90;   South= +-180;   West=-90?
Or is there a different convention?

3) What is wrong with this example?
- All the photos of this chunk are shot at yaw= -55°, roll=0° and pitch= -90° (nose down)
- I've added these information. After aligning the models rotation is not how expected..."Top View ... NW -55"
What is wrong?

4) Clear all / clear rotation
I just noticed that I can clear all or just rotation in reference menu - but there is no function to clear location only.
Is it possible to use rotation without location to auto-rotate a model?

THANK YOU!!!!  :)

... just saw that one picture is named incorrectly. The Rotation wasn't cleared in picture "Top View cleared NW -55.jpg"
« Last Edit: December 31, 2017, 03:11:56 PM by mcstieg »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14107
    • View Profile
Re: Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model
« Reply #5 on: December 31, 2017, 11:40:19 PM »
Hello mcstieg,

Values 0, 0, 0 for yaw, pitch and roll means that the plane is flying to the north, the left wing is oriented to the east and the camera is mounted under the plane and is looking vertically down.

90 degrees for pitch means that the camera is looking to the horizon (parallel to the ground level).
Best regards,
Alexey Pasumansky,
Agisoft LLC

mcstieg

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model
« Reply #6 on: January 01, 2018, 01:08:32 PM »
Hello Alexex,

thank you for that! I can now manipulate pitch in that way. 
But it's still unclear if roll is seen in PhotoScan as a value of 0-360 or -180 + 180 but I try to figure it out.
Is YAW a Value of +-180 or 0-360?

What about question 4? Is it possible to use rotation values only to autorotate a model or does PhotoScan need Location for this? (Photos inside a building...no GPS but Orientation)

THANK YOU!  :)

jomey

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Add known Pitch/Roll/Yaw to Exif and Auto-Rotate Model
« Reply #7 on: July 21, 2018, 12:36:01 AM »
Hi Alexey,

any more details on the value range for pitch/roll/yaw?

Mainly wondering whether it is 0-360 or 0 to +/- 180.

Maybe you could give an different example than for 0,0,0.

Thank you.