Forum

Author Topic: Auto exporting of multiple single photos to ortho - phyton 1.1.0  (Read 6747 times)

Herman

  • Newbie
  • *
  • Posts: 22
    • View Profile
Auto exporting of multiple single photos to ortho - phyton 1.1.0
« on: February 02, 2015, 10:54:56 AM »
Hi.

I am modifying a sample script from Alexey from a previous version (1.0.0) to try and make it compatable with v1.1.0.  My knowledge of Python is limited and have a hard time finding samples of changes implemented in v1.1.0.  Please help.

I have defined my projection in a local coordinate system and would like to export single cameras as single ortho photos, type Planar, projection plane Top XY.  Attached is the modified script.  I get stuck at line 106,  PhotoScan.Matrix object has no attribute 'matrix'.

Thank you.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14890
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #1 on: February 02, 2015, 11:54:52 AM »
Hello Herman,

camera.transform is already a matrix, so you don't need to use .matrix method (like it's required for chunk.transform).

I also suggest to use the following code for surf_height function:
Code: [Select]
def surf_height(chunk, photo):

points_h = list()
point_cloud = chunk.point_cloud
points = point_cloud.points
npoints = len(points)
num_valid = 0

point_index = 0
for proj in point_cloud.projections[photo]:

track_id = proj.track_id
while point_index < npoints and points[point_index].track_id < track_id:
point_index += 1
if point_index < npoints and points[point_index].track_id == track_id:
if not points[point_index].valid:
continue

v = points[point_index].coord
vt = chunk.transform.matrix.mulp(v)
vt = chunk.crs.project(vt)
points_h.append(vt[2])
num_valid += 1

points_h.sort()
height = points_h[num_valid // 2]

return height


Also instead of chunk.projection you need to use chunk.crs (it appears in all lines where coordinates are transformed between geocentric and geographic coordinates).
« Last Edit: February 02, 2015, 11:57:35 AM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

Herman

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #2 on: February 02, 2015, 01:20:57 PM »
Hi Alexey,

I appreciate your quick response. 

If I use v0_gc = chunk.transform * photo.transform *v0, I get an error of unsupported types.  Pardon my ignorance, but what have changed?

Thank you.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14890
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #3 on: February 02, 2015, 06:31:11 PM »
Hello Herman,

chunk.transform -> chunk.transform.matrix
camera.transform -> camera.transform
Best regards,
Alexey Pasumansky,
Agisoft LLC

Herman

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #4 on: February 02, 2015, 07:21:51 PM »
Hi Alexey,

Thank you.  I am making progress but it is slow.  Attach is the script I have changed so far.  My current error is 'PhotoScan.PointCloudProject' object does not support indexing.  My assumption is that I am using a local coordinate system (no projection defined) which is causing the problem. The error is at line 44.

Regards.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14890
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #5 on: February 02, 2015, 07:26:36 PM »
Hello Herman,

Then I think you should comment line 43 as well:
Code: [Select]
vt = projActually you can just remove it as it will raise error even for referenced chunk.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Herman

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #6 on: February 02, 2015, 08:05:20 PM »
Hi Alexey,

I have excluded the projection definitions and the script proses up to line 186 with an error that the 'path' attribute is not defined.  However, it is defined and when I print 'path', I get a valid path.

Thank you in advance.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14890
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #7 on: February 02, 2015, 08:17:24 PM »
Hello Herman,

In the script path is defined in the line 57:
Code: [Select]
path = doc.path.rsplit("\\", 1)[0]from the path to the project file. In case the project is not saved (is Untitled), the definition will not work.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Herman

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #8 on: February 03, 2015, 12:05:31 PM »
Hi Alexey,

The project is saved but once the script start, all cameras are deactivated and the 1st camera is activated which cause changes to the project.  Do I have to save the project at line 184?  I have hard coded path = "c:\\Users\\project" at line 184 but still get the same error.

Thank you.


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14890
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #9 on: February 03, 2015, 09:18:01 PM »
Hello Herman,

Maybe you can send the project file (with the mesh and dense cloud removed) and script that you are using now to support@agisoft.com?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Herman

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Auto exporting of multiple single photos to ortho - phyton 1.1.0
« Reply #10 on: February 06, 2015, 09:06:44 AM »
Hi Alexey,

I have uploaded a sample project via a file sharing service.

Thank you.