Forum

Author Topic: Is it a bug o feature?  (Read 244 times)

godszerg

  • Newbie
  • *
  • Posts: 11
    • View Profile
Is it a bug o feature?
« on: January 23, 2019, 05:41:39 PM »
In the attached image you can see my project, where Y axis goes vertically. But running script to get the size of the bounding box mixes X and Y axes.
 
The second image is from unity which detects bounds size correctly.

ps

Script i run is just printing X,Y,Z of size vector of the bounding box:

Code: [Select]
print("Size - X: ",chunk.size.x, "Y: ",chunk.size.y, "Z: ",chunk.size.z)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9890
    • View Profile
Re: Is it a bug o feature?
« Reply #1 on: January 23, 2019, 06:00:49 PM »
Hello godszerg,

Is the chunk that you are working with scaled, transformed or referenced?

The dimensions of the region is given via Python API in the internal chunk's coordinate system, that doesn't fit the system that you see in the Model view, if any manual modifications (Rotate Object, Scale Object, Move Object) have been applied or the chunk has been referenced or scaled via the checked on items in the Reference pane.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

godszerg

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Is it a bug o feature?
« Reply #2 on: January 23, 2019, 08:15:28 PM »
Here what I did:

1. Created a blank project.
2. Add photos from dataset from Agisoft page.
3. Workflow -> Align Photos.
then run the script to check the size of the bounding box.

That is it.

Here is a full script:
Code: [Select]
import Metashape

doc = Metashape.app.document
chunk = doc.chunks[0]
print("Size - X: ",chunk.region.size.x, "Y: ",chunk.region.size.y, "Z: ",chunk.region.size.z)


To be more clear here is the goal I try to achieve.

I want to import point cloud to unity.
Edit bounding box.
Adjust bounding box in Metashape with python to new position and size.

I played with different photo sets and it turns out that every time different axes are mixed up.

I case of doll X and Y mixed up, in case of building set Z and Y.

Is there any way to set the coordinate system to be exactly the same every time?
« Last Edit: January 23, 2019, 08:43:30 PM by godszerg »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9890
    • View Profile
Re: Is it a bug o feature?
« Reply #3 on: January 23, 2019, 08:54:53 PM »
Hello godszerg,

These X, Y and Z dimensions should be measured according to the axis directions that you see on the trackball, when Rotate Region tool is active. Also you can see it in another way:
region Z direction is normal to the colored side of the bounding box (that also has cross mark in the middle), X side is that has vertical marks on it (that are normal to the colored box side), and the third side is Y.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

godszerg

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Is it a bug o feature?
« Reply #4 on: January 24, 2019, 07:35:14 PM »
Thanks for the answer!

I wonder if there is a way to set region by 4 vertexes? just providing X,Y and z of each vertex?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9890
    • View Profile
Re: Is it a bug o feature?
« Reply #5 on: January 24, 2019, 09:16:59 PM »
Hello godszerg,

Please check the similar script in the following thread:
https://www.agisoft.com/forum/index.php?topic=10102.msg46135#msg46135
It estimates the limiting coordinates for X and Y according to the estimated cameras locations and then generates the box fitting these values. Basically, instead of these values you can use any numbers (coordinates of points), but not that the box may not perfectly fit four points, if they do not form the rectangle.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

godszerg

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Is it a bug o feature?
« Reply #6 on: January 25, 2019, 12:07:22 AM »
Hello godszerg,

Please check the similar script in the following thread:
https://www.agisoft.com/forum/index.php?topic=10102.msg46135#msg46135
It estimates the limiting coordinates for X and Y according to the estimated cameras locations and then generates the box fitting these values. Basically, instead of these values you can use any numbers (coordinates of points), but not that the box may not perfectly fit four points, if they do not form the rectangle.

Tried that script, got an error:
unsupported operand type(s) for /: 'float' and 'NoneType'

Code: [Select]
new_size = ((100 + BUFFER) / 100) * Metashape.Vector([side2g.norm()/s, side1g.norm()/s, 3*side3g.norm() / s]) ##
s is None
« Last Edit: January 25, 2019, 12:10:53 AM by godszerg »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9890
    • View Profile
Re: Is it a bug o feature?
« Reply #7 on: January 25, 2019, 01:27:29 PM »
Try to reassign s in the beginning of the script to chunk.transform.matrix.scale():
Code: [Select]
s = chunk.transform.matrix.scale()It's None when accessed in the given case, since the chunk is not scaled, but it means that s value would be 1. Using the approach above should fix the issue anyway. I will also make a correction in the source thread.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 9890
    • View Profile
Re: Is it a bug o feature?
« Reply #8 on: January 25, 2019, 01:28:18 PM »
And since you do not have any coordinate system defined, you can skip/remove chunk.crs utilization.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

jedfrechette

  • Jr. Member
  • **
  • Posts: 80
  • Lidar Guys
    • View Profile
    • www.lidarguys.com
Re: Is it a bug o feature?
« Reply #9 on: January 26, 2019, 09:21:19 PM »
The conversion between chunk coordinates and world coordinates ends up requiring quite a bit of boiler plate code. Furthermore, to my knowledge, the use of the different coordinate systems isn't documented very well anywhere except in forum posts like the one linked to earlier in this thread. As a result, what is ultimately just a simple transform, causes a lot more confusion than it needs to.

Therefore, my feature request would be for the addition of a couple convenience functions to the API that would convert from world coordinates to chunk coordinates and vice versa.
Jed