Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: Christian on August 16, 2019, 12:10:38 PM

Title: Scale a model / Accuracy / multiple sizes
Post by: Christian on August 16, 2019, 12:10:38 PM
Hi!
My task is to export models in different scales / sizes as some programs, my clients are using, are not configurable with regard to the import units. A model that has 30cm in Agisoft is very small (factor 1000) compared to models created with other software. I know that OBJ and other fileformats do not contain any information regarding the units (Meters, cm, mm, inch....) and that the interpretation has to be done within the 3D software that is importing.

To help my client, importing 3D models from different programs in same sizes/scales, I want to export the created model in different "scales". I use markers and scalebars to size the model automatically and it works perfect. See picture 30cm.jpg.

My idea was to change the definied distance of the scalebar from 0.3 Meters to 300 Meters and have the same model - just larger by factor 1000. Basically that works - but it is not scaled by factor 1000 - it has deviations as visible in picture 300m.jpg. A former distance from approx. 19 cm becomes 18.6 cm. I expect that it comes from accuracy and that the error will multiply, when changing scales.

Is there any other way to scale a model *exacty* by factor 1000? And no - it is not possible to do this during the import into the other software - it does not contain any feature / configuration to set the units.

Thank you - Christian
Title: Re: Scale a model / Accuracy / multiple sizes
Post by: Alexey Pasumansky on August 22, 2019, 07:07:03 PM
Hello Christian,

According to the second screenshot you have not modified the coordinate values for the markers, but are still using them for referencing.

You either need to uncheck all markers in the second case (with 300 m distance) and press Update button on the pane's toolbar, or to multiply the markers' coordinates by the same factor and then press update button.
Title: Re: Scale a model / Accuracy / multiple sizes
Post by: Christian on August 30, 2019, 03:51:24 PM
Dear Alexey,
as always - you are right - I can do that manually and the calculated length is correct. But for me the problem still exists:

I can not use the GUI - I have to use python console.

This is part of the script I am using:
----------------------------------------------
import PhotoScan
chunk = PhotoScan.app.document.chunks[0]
for m in chunk.markers:
   try:
      print (str(m.label))
      m.reference.enabled = 0
   except Exception as e:
      print(e)
for sbs in chunk.scalebars:
   print (str(sbs))
   sbs.reference.distance = 300
   sbs.reference.accuracy = 0.00001

chunk.updateTransform()
----------------------------------------------

And get an Output:

2019-08-30 14:44:48 target 1
2019-08-30 14:44:48 'PhotoScan.Marker.Reference' object attribute 'enabled' is read-only
2019-08-30 14:44:48 target 2
2019-08-30 14:44:48 'PhotoScan.Marker.Reference' object attribute 'enabled' is read-only
2019-08-30 14:44:48 target 3
2019-08-30 14:44:48 'PhotoScan.Marker.Reference' object attribute 'enabled' is read-only
2019-08-30 14:44:48 target 4
2019-08-30 14:44:48 'PhotoScan.Marker.Reference' object attribute 'enabled' is read-only
2019-08-30 14:44:48 <Scalebar 'target 2_target 3'>
2019-08-30 14:44:48 <Scalebar 'target 1_target 2'>


(I use Photoscan 1.4.3 - 6529 & Win10)