Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: michaelzhangxc on August 24, 2014, 01:30:11 AM

Title: shift vector function in exportModel
Post by: michaelzhangxc on August 24, 2014, 01:30:11 AM
Dear Sir,

I want to export a pdf file with a fixed model position.

I found the model position in the exported pdf file does not change with different shift vector values, for exemple [0,0,0] and [1000,1000,1000].
What's the reason?

Thank you for your advise.

Code: [Select]
[new_chunk = PhotoScan.app.document.activeChunk
filename="C:/3D/zx2.pdf"
Format="pdf"
new_chunk.exportModel(filename, binary=True, precision=6, texture_format="jpg", texture=True, normals=True,colors=True, cameras=True, format=Format, shift=[0,0,0])]
Title: Re: shift vector function in exportModel
Post by: Alexey Pasumansky on August 24, 2014, 08:04:07 AM
Hello michaelzhangxc,

Shift parameter subtracts the values from model coordinates, but doesn't effect on the view point. PDF is exported according to the current view in the Model frame. Viewpoint camera position and orientation can be changed via PhotoScan.app.viewpoint.
Title: Re: shift vector function in exportModel
Post by: michaelzhangxc on August 24, 2014, 06:50:14 PM
Thank you for your prompy reply, Alexey.

Then how can I input a parameter to change the viewpoint? The code below seems can not change the viwepoint.

Code: [Select]
[import PhotoScan
new_chunk = PhotoScan.app.document.activeChunk
filename="C:/zx1.pdf"
Format="pdf"
PhotoScan.Application.viewpoint
new_chunk.exportModel(filename, binary=True, precision=6, texture_format="jpg", texture=True, normals=True,colors=True, cameras=True, format=Format)

]
Title: Re: shift vector function in exportModel
Post by: Alexey Pasumansky on August 25, 2014, 04:48:47 PM
Hello michaelzhangxc,

viewpoint (= PhotoScan.app.viewpoint) has four parameters:
coo - center of the camera position,
fov - field of view (in degrees),
mag - magnitude,
rot - 3x3 rotational matrix.

So you need to input new values to one or more of them.
Title: Re: shift vector function in exportModel
Post by: michaelzhangxc on August 25, 2014, 06:32:31 PM
Thank you Alexey.

I tried to input a parameter, however it says the object is not callable as below:

Traceback (most recent call last):
  File "C:/Python33/test.py", line 6, in <module>
    PhotoScan.Application.viewpoint(coo=[0,0,0])
TypeError: 'getset_descriptor' object is not callable

Maybe I input in a wrong format?
Code: [Select]
[import PhotoScan
new_chunk = PhotoScan.app.document.activeChunk
filename="C:/3D PHOTO MANAGER/zx2.pdf"
Format="pdf"
PhotoScan.Application.viewpoint(coo=[0,0,0])
new_chunk.exportModel(filename, binary=True, precision=6, texture_format="jpg", texture=True, normals=True,colors=True, cameras=True, format=Format)]
Title: Re: shift vector function in exportModel
Post by: Alexey Pasumansky on August 26, 2014, 01:17:03 PM
Hello michaelzhangxc,

New values for viewpoint parameters should be assigned like shown below:

Code: [Select]
viewpoint = PhotoScan.app.viewpoint
viewpoint.coo = ...
viewpoint.rot = ...
viewpoint.mag = ...
viewpoint.fov = ...
Title: Re: shift vector function in exportModel
Post by: michaelzhangxc on August 26, 2014, 06:30:06 PM
It works well, thank you Alexey!
Title: Re: shift vector function in exportModel
Post by: r0xx on December 24, 2014, 01:26:07 PM
How would this work in 1.1.0 preview?