Forum

Author Topic: Calculate/ export camera direction?  (Read 4883 times)

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Calculate/ export camera direction?
« on: May 03, 2016, 08:43:48 PM »
Hi, I need to get the direction of the camera to apply backface culling to my project. How would one go about exporting these?

I presume these can be exported as the cameras are shown in the PhotoScan Model tab. Otherwise, is it possible to recreate the cameras' locations in 3D space?

regards,
Jonathan

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Calculate/ export camera direction?
« Reply #1 on: May 03, 2016, 11:15:36 PM »
I've created [X,Y,Z] co-ordinates for all cameras using the dot-product of: a camera's transformation matrix, and the 'centre' [x,y,z,1] matrix that are both located in an exported cameras.xml file (exported camera calibration).

Is this a correct approach to re-calculating each camera's co-ordinates in 3D space? -Relative to the model?

stihl

  • Sr. Member
  • ****
  • Posts: 410
    • View Profile
Re: Calculate/ export camera direction?
« Reply #2 on: May 04, 2016, 11:30:55 AM »
It's much simpler if I'm understanding you correctly.

In Photoscan in the reference panel (where you import and export markers/GCP's), next to the import button there's an export button. If you hover over it, in the left lower corner it will say "Export reference data to file".

If you click  that a new window appears. Here you name your file. In the next window you select Cameras in items, Tab as the Delimiter, and you enable Save estimated values and Save orientation with a precision of 6.

You'll end up with a .txt file of all the estimated camera positions (based on their relative position of the georeferenced (or local) model) and their attitude as XYZ and Roll, Pitch, Yaw.

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Calculate/ export camera direction?
« Reply #3 on: May 04, 2016, 06:31:59 PM »
I've tried this but all of the values for all cameras are empty  :-[

I get something like this:

#Label   X/East   Y/North   Z/Altitude   Yaw   Pitch   Roll   X_est   Y_est   Z_est   Yaw_est   Pitch_est   Roll_est
488.png                                    
489.png                                    
490.png                                    
491.png                                    
492.png                                    
493.png                                    
494.png                                    
495.png                                    
496.png                                    
497.png                                    
498.png                                    
499.png                                    
500.png                                    
501.png                                    
502.png                                    
503.png                                                                     
504.png                                    
505.png                                    
506.png                                    
507.png                                    
508.png                                                                     
509.png                                    

stihl

  • Sr. Member
  • ****
  • Posts: 410
    • View Profile
Re: Calculate/ export camera direction?
« Reply #4 on: May 06, 2016, 01:37:36 PM »
That's very strange. It should show up the coordinates.

Are you positive that your project isn't done in local coordinates?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Calculate/ export camera direction?
« Reply #5 on: May 06, 2016, 02:51:26 PM »
Estimated coordinates can be exported from the Reference pane only for referenced chunk.

You can "simulate" the referencing if you type in the following command in the Console pane:
Code: [Select]
PhotoScan.app.document.chunk.transform.matrix = PhotoScan.app.document.chunk.transform.matrix
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Calculate/ export camera direction?
« Reply #6 on: May 06, 2016, 02:53:11 PM »
Hello Jonathan,

Also some of the model formats support camera export (like FBX, 3DS, COLLADA), so it may be a more convenient way for you, if you are going to work with this data in the model editing applications.
Best regards,
Alexey Pasumansky,
Agisoft LLC

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Calculate/ export camera direction?
« Reply #7 on: May 06, 2016, 02:57:14 PM »
I've managed to export the transformation matrix and I'm fairly sure this gives an accurate location for each camera (I've used a dot product of this and the centre point of the model).

However, now that I have the locations of the cameras is it possible to get the orientation/ direction a camera is facing?

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Calculate/ export camera direction?
« Reply #8 on: May 06, 2016, 03:02:34 PM »
Also I am using this data to create a sort of 'timeline' slideshow (temporal viewer) for a group of models, purely using Python. Unfortunately this is a low-cost research project so I can't afford any fancy equipment, and all photos are recorded  from mobile phones without a gyroscope or GPS