Forum

Author Topic: Resize Region in Python  (Read 8094 times)

beth182

  • Newbie
  • *
  • Posts: 5
    • View Profile
Resize Region in Python
« on: July 14, 2017, 05:21:45 PM »
Hello,

I have the x,y,z coordinates for a centre point of a chunk in meters, eg:

vectcentre = PhotoScan.Vector( (700000, 5700000, 0) )

I am wanting to resize the region in python to be a rectangle of 50m x 50m x 300m (x by z by z) around the centre point, but I am unsure how to do this using chunk.region in python?

Thank you for your help

beth182

  • Newbie
  • *
  • Posts: 5
    • View Profile
Setting Coordinates for Corners of Region
« Reply #1 on: July 18, 2017, 11:15:51 AM »
Hello all,

I am wondering if anyone knows if there is a way in python to set the 8 coordinates of the corners of the region box? I am having difficulties with resizing the region of my chunk with no rotation, so think that this will be the easiest method (if there is a way of doing it).

Thank you in advance for any help,
Beth

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15420
    • View Profile
Re: Resize Region in Python
« Reply #2 on: July 18, 2017, 11:54:59 AM »
Hello Beth,

Assuming that the chunk is georeferenced you can use the following code to move the region center and resize it:
Code: [Select]
new_center = PhotoScan.Vector([700000, 5700000, 0]) #coordinates in the chunk coordinate system
new_size = PhotoScan.Vector([1500, 1000, 100]) #size in the coordinate system units

T = chunk.transform.matrix
S = chunk.transform.scale
crs = chunk.crs

region = chunk.region
region.center = T.inv().mulp(crs.unproject(new_center))
region.size = new_size / S

chunk.region = region
Best regards,
Alexey Pasumansky,
Agisoft LLC

beth182

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Resize Region in Python
« Reply #3 on: July 18, 2017, 12:51:14 PM »
Hi Alexey,

That worked well for me, thank you for your response. I have another question, slightly unrelated to this;

with PhotoScan.Chunk.loadReference(), when assigning the columns to 'nxyzabc', is there any way to have extra information in the file for other uses, and if so, how would you skip a column in the file when assigning 'nxyz'?

Thank you for your time,
Beth

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15420
    • View Profile
Re: Resize Region in Python
« Reply #4 on: July 18, 2017, 01:01:44 PM »
Hello Beth,

You can use "space" symbols for skipping rows, for example:
Code: [Select]
" n xyz"It will work for the following kind of data:
Code: [Select]
1,IMG0001_JPG,12:00:01,1000,2000.1,100.33
2,IMG0002_JPG,12:00:05,1001,2000.2,100.35
So the first and third columns will be skipped.
Best regards,
Alexey Pasumansky,
Agisoft LLC

beth182

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Resize Region in Python
« Reply #5 on: July 18, 2017, 01:42:39 PM »
Great, thanks again for your help!

Beth