Forum

Author Topic: exportPoints()  (Read 8826 times)

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
exportPoints()
« on: March 01, 2016, 02:09:05 PM »
Hi, there,

I get a problem when i try to use script api to export points:

Code: [Select]
import PhotoScan
import os

doc = PhotoScan.app.document
chunk = doc.chunk

path = PhotoScan.app.getSaveFileName("Export Points")

export_point_config = {
'binary': True,
'normals': False,
'colors': True,
'format': "xyz"
}

chunk.exportPoints(path, **export_point_config)

But, the results that exported by script above are different from the results
that exported by GUI (Menu: File -> Export Points)  (shown in the attach)
Generally like below:
1. export by script
-4.147146 -2.210924 3.906164 183 179 179 0.942872 -0.142619 -0.301085
-4.187863 -2.191922 3.893496 183 177 177 0.802979 -0.429316 -0.413415
-4.164337 -2.200971 3.929689 183 179 180 0.315745 0.947234 -0.055255
-4.148955 -2.202780 3.933308 168 163 168 0.181774 0.916774 0.355645

2. export by GUI
-151.937057 89.993715 -6356748.407824 183 179 179 0.569418 0.764893 -0.301169
-152.372494 89.993679 -6356748.420488 183 177 177 0.752724 0.512296 -0.413472
-152.142275 89.993701 -6356748.384297 183 179 180 -0.689919 0.721768 -0.055335
-152.035090 89.993718 -6356748.380679 168 163 168 -0.724487 0.590492 0.355580


So, could anyone tell me the mistake i made?

Sincerely,
Chaoer



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportPoints()
« Reply #1 on: March 01, 2016, 02:13:09 PM »
Hello Chaoer,

It seems that from GUI you are exporting points in the geographic coordinates, while script export saves the coordinates in the internal coordinates.

So to export the points in the geographic coordinates you need to add projection argument, providing that chunk is referenced:
projection = chunk.crs.
Best regards,
Alexey Pasumansky,
Agisoft LLC

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
about exportPoints()
« Reply #2 on: March 01, 2016, 02:13:49 PM »
Hi, there,

I get a problem when i try to use script api to export points:
Code: [Select]
import PhotoScan
import os

doc = PhotoScan.app.document
chunk = doc.chunk

path = PhotoScan.app.getSaveFileName("Export Points")

export_point_config = {
'binary': True,
'normals': False,
'colors': True,
'format': "xyz"
}

chunk.exportPoints(path, **export_point_config)

But, the results that exported by script above are different from the results
that exported by GUI (Menu: File -> Export Points)  (shown in the attach)
Generally like below:
1. export by script
-4.147146 -2.210924 3.906164 183 179 179 0.942872 -0.142619 -0.301085
-4.187863 -2.191922 3.893496 183 177 177 0.802979 -0.429316 -0.413415
-4.164337 -2.200971 3.929689 183 179 180 0.315745 0.947234 -0.055255
-4.148955 -2.202780 3.933308 168 163 168 0.181774 0.916774 0.355645

2. export by GUI
-151.937057 89.993715 -6356748.407824 183 179 179 0.569418 0.764893 -0.301169
-152.372494 89.993679 -6356748.420488 183 177 177 0.752724 0.512296 -0.413472
-152.142275 89.993701 -6356748.384297 183 179 180 -0.689919 0.721768 -0.055335
-152.035090 89.993718 -6356748.380679 168 163 168 -0.724487 0.590492 0.355580


So, could anyone tell me the mistake i made?

Sincerely,
Chaoer

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: exportPoints()
« Reply #3 on: March 01, 2016, 02:23:14 PM »
Hello Chaoer,

It seems that from GUI you are exporting points in the geographic coordinates, while script export saves the coordinates in the internal coordinates.

So to export the points in the geographic coordinates you need to add projection argument, providing that chunk is referenced:
projection = chunk.crs.

Hi,  Alexey,
Thanks for your quickly answer.
When I export by GUI, I cannot choose the geographic coordinates (actually it is greyed. )
So, I don't know how to do it.
Could  you please tell me how to add projection argument?
Sincerely.


« Last Edit: March 01, 2016, 02:24:52 PM by chaoer »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportPoints()
« Reply #4 on: March 01, 2016, 02:32:38 PM »
Hello Chaoer,

Do you have any coordinates input for camera positions or markers in the Reference pane?
Best regards,
Alexey Pasumansky,
Agisoft LLC

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: exportPoints()
« Reply #5 on: March 01, 2016, 02:39:38 PM »
Hello Chaoer,

Do you have any coordinates input for camera positions or markers in the Reference pane?

Hello, Alexey,

I did not input any information about camera positions or markers.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportPoints()
« Reply #6 on: March 01, 2016, 02:53:59 PM »
Hello Chaoer,

I've tried both export options on a random project and got identical results. Maybe you can send the project file to support@agisoft.com? Actually PSZ with the sparse cloud only will be sufficient, in case the dense cloud is huge.
Best regards,
Alexey Pasumansky,
Agisoft LLC

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: exportPoints()
« Reply #7 on: March 01, 2016, 02:54:21 PM »
Hello Chaoer,

Do you have any coordinates input for camera positions or markers in the Reference pane?

Hi, Alexey,
And I am confused when I using the API  exportPoints(),
In the API reference (I just find v1.1.0  and  v1.2.3), the parameters of this function are:

v1.1.0
Code: [Select]
exportPoints(path, binary=True, precision=6, normals=True, colors=True[, source ][, comment ][,
format ][, projection ][, shift ])
where source (PhotoScan.PointsSource)
v1.2.3
Code: [Select]
exportPoints(path, binary=True, precision=6, normals=True, colors=True[, source ][, comment ][,
format ][, projection ][, shift ][, blockw ][, blockh ])
where source (PhotoScan.DataSource)

But when i type code as below in the console pane, PS says i am wrong.
(the version of my PS is v1.1.6)
Code: [Select]
chunk.exportPoints(r"C:\Users\Chaoer\Desktop\ps-py\pp.las", True)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: argument 2 must be PhotoScan.PointsSource, not bool


chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: exportPoints()
« Reply #8 on: March 01, 2016, 03:13:16 PM »
Hello Chaoer,

I've tried both export options on a random project and got identical results. Maybe you can send the project file to support@agisoft.com? Actually PSZ with the sparse cloud only will be sufficient, in case the dense cloud is huge.

Hi, Alexey,

I have sent you the project file. Please check your email.

Thanks for your help.

Chaoer.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportPoints()
« Reply #9 on: March 01, 2016, 03:13:52 PM »
Hello Chaoer,

The order of the arguments in the API reference is incorrect. So it's better to use the key words until we fix it in the documentation.

And there was really change in the version 1.2 compared to the version 1.1 (DataSource vs. PointsSource).
Best regards,
Alexey Pasumansky,
Agisoft LLC

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: exportPoints()
« Reply #10 on: March 01, 2016, 03:22:11 PM »
Hello Chaoer,

The order of the arguments in the API reference is incorrect. So it's better to use the key words until we fix it in the documentation.

And there was really change in the version 1.2 compared to the version 1.1 (DataSource vs. PointsSource).

Hi, Alexey,

Yeah, I got it.

By the way, I have sent you the project file via email. Please remember to check your email.

Chaoer.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportPoints()
« Reply #11 on: March 01, 2016, 03:31:44 PM »
Hello Chaoer,

Thank you for providing the project file.

In the Reference pane there are input camera coordinates (loaded from the EXIF by default on adding the images), but since the two points are not sufficient to georeference the model the chunk is not marked as referenced.

So I can suggest to Clear the coordinate information in the Reference pane and also use Reset Transform option in the chunk context menu after right-clicking on its label in the Workspace pane.
Best regards,
Alexey Pasumansky,
Agisoft LLC

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: exportPoints()
« Reply #12 on: March 01, 2016, 03:54:37 PM »
Hello Chaoer,

Thank you for providing the project file.

In the Reference pane there are input camera coordinates (loaded from the EXIF by default on adding the images), but since the two points are not sufficient to georeference the model the chunk is not marked as referenced.

So I can suggest to Clear the coordinate information in the Reference pane and also use Reset Transform option in the chunk context menu after right-clicking on its label in the Workspace pane.

Hello Alexey,

I tried again according to what you say, but i still get different results.(in las format)

I wonder is there any mistake in my script which lead to this difference?


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: exportPoints()
« Reply #13 on: March 01, 2016, 08:01:11 PM »
Hello Chaoer,

The script is fine and should work as expected. But you need to perform the following steps for this particular two cameras case:

- uncheck cameras in the Reference pane or clear the coordinate information,
- in the Reference pane settings dialog switch the coordinate system to the local coordinates,
- use Reset Transform option for the active chunk from the Workspace context menu.
Then export points.

Alternatively you can modify the script to export the points in the local coordinates:
Code: [Select]
crs = PhotoScan.CoordinateSystem('LOCAL_CS["Local Coordinates",LOCAL_DATUM["Local Datum",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]')
chunk.exportPoints(path, format = "xyz", projection = crs)
In your project the coordinate system is set to WGS84, so by default .exportPoints function uses this coordinate system, while from GUI you are exporting in local coordinates.
Best regards,
Alexey Pasumansky,
Agisoft LLC

chaoer

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: exportPoints()
« Reply #14 on: March 02, 2016, 04:02:17 AM »
Hello Chaoer,

The script is fine and should work as expected. But you need to perform the following steps for this particular two cameras case:

- uncheck cameras in the Reference pane or clear the coordinate information,
- in the Reference pane settings dialog switch the coordinate system to the local coordinates,
- use Reset Transform option for the active chunk from the Workspace context menu.
Then export points.

Alternatively you can modify the script to export the points in the local coordinates:
Code: [Select]
crs = PhotoScan.CoordinateSystem('LOCAL_CS["Local Coordinates",LOCAL_DATUM["Local Datum",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]')
chunk.exportPoints(path, format = "xyz", projection = crs)
In your project the coordinate system is set to WGS84, so by default .exportPoints function uses this coordinate system, while from GUI you are exporting in local coordinates.

Hello, Alexey,

Thanks for your advice.
Now, I can get the result I want.
You do me a big favor.
Thanks again.

Sincerely.
Chaoer.