Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: ruyi7952 on October 03, 2017, 03:48:49 AM

Title: help me! about export point cloud to Local Coordinates
Post by: ruyi7952 on October 03, 2017, 03:48:49 AM
Hello

I try to do this, the result is not correct.
Code: [Select]
chunk.exportMatches("d:\\222.txt",format=PhotoScan.MatchesFormatBINGO,precision=10,export_points=True,export_markers=False,use_labels=True)
please help me ,for export matches point to Local coordinates

and try
Code: [Select]
PhotoScan.PointCloud.export("d:\test.ply", format = 'ply')
get error

Quote
2017-10-03 08:47:37 Traceback (most recent call last):
2017-10-03 08:47:37   File "C:/Users/Administrator/PycharmProjects/test/test.py", line 10, in <module>
2017-10-03 08:47:37     PhotoScan.PointCloud.export("d:\test.ply", format = 'ply')
2017-10-03 08:47:37 TypeError: descriptor 'export' requires a 'PhotoScan.PointCloud' object but received a 'str'
Title: Re: help me! about export point cloud to Local Coordinates
Post by: Alexey Pasumansky on October 04, 2017, 10:36:25 AM
Hello ruyi7952,

exportMatches() function saves the tie points between the images. They are defined on the 2D images.

PhotoScan.PointCloud is the name of the Python class. It's not related to the actual project, so if you need to save the sparse point cloud, you should use:
Code: [Select]
chunk.exportPoints("d:\test.ply", source = PhotoScan.DataSource.PointCloudData, format = PhotoScan.PointsFormatPLY)
By default the points will be exported in chunk coordinate system, if you need to use local coordinates, use projection = crs arguments in the export, where:
Code: [Select]
crs = PhotoScan.CoordinateSystem('LOCAL_CS["Local Coordinates",LOCAL_DATUM["Local Datum",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]')
Title: Re: help me! about export point cloud to Local Coordinates
Post by: ruyi7952 on October 04, 2017, 02:05:12 PM
Hello Alexey ,thank you。

I have needed tie points export to Datem Summit Evolution with  Local Coordinates.

like *.smtxml files

Code: [Select]
<SummitProject>
……
……
<SystemOut>  your   coordinates    </SystemOut>
<SystemIn>     your   coordinates     </SystemIn>
<UseCoordSystems>0</UseCoordSystems>

<ControlList>
<Control> your con file</Control>
</ControlList>
<CameraList>
<Camera>your cam file</Camera>
</CameraList>

……
……

<Images>
<ImageInfo>
<ImageFile>F:\test\DJI_0728.JPG</ImageFile>
<AssignedCamera>0</AssignedCamera>
<Rotation>270</Rotation>
<ImageHeights Terrain="9.962999999999999" flightHeight="217.298129999999986"/>
<TiePoints>
<TP ID="Cw3L1C164" Mea="1" Sel="1">1828.669760 1406.386490</TP>
<TP ID="Cw3L1C165" Mea="1" Sel="1">2333.308340 1577.668370</TP>
<TP ID="Cw3L1C166" Mea="1" Sel="1">2585.240460 1528.700010</TP>
……
……

like *.con files there are tie point list.
Code: [Select]
Cw3L1C0 HV 648515.0543 3656576.3083 -5.4156 0.1470 0.1590 0.1760 1
Cw3L1C1 HV 648547.1471 3656538.0566 -4.8616 0.1490 0.1660 0.1770 1
Cw3L1C10 HV 648756.0820 3656470.4243 -0.6713 0.1630 0.1870 0.1920 1
Cw3L1C100 HV 648316.1219 3657156.4925 7.1347 0.1800 0.1870 0.1880 1
Cw3L1C101 HV 648235.2612 3656960.7998 1.8623 0.1890 0.1660 0.1910 1
Cw3L1C102 HV 648536.2190 3657098.9499 4.4924 0.1500 0.1670 0.1770 1
Cw3L1C103 HV 648920.3660 3656439.8140 3.5941 0.1910 0.2030 0.2120 1
Cw3L1C104 HV 649043.0260 3657031.5729 11.0279 0.2040 0.1790 0.2010 1

** the  tie point it's Coordinates,not image Coordinates.

Alexey ,i can do it with write python scripts?or do you make new function for export to SummitProject??

thanks you.
Title: Re: help me! about export point cloud to Local Coordinates
Post by: Alexey Pasumansky on October 04, 2017, 02:09:15 PM
Hello ruyi7952,

Export to the Summit Evolution project is available via export cameras function:
Code: [Select]
chunk.exportCameras(path, format = PhotoScan.CamerasFormatSummit)
Title: Re: help me! about export point cloud to Local Coordinates
Post by: ruyi7952 on October 04, 2017, 03:20:38 PM
Hello ruyi7952,

Export to the Summit Evolution project is available via export cameras function:
Code: [Select]
chunk.exportCameras(path, format = PhotoScan.CamerasFormatSummit)

a summit projects have .smtxml .cam .con file

only two file *.cam *.smtxml ,doesn't include any tie point? and i have used Local Coordinates,but export's file it's images Coordinates.

Title: Re: help me! about export point cloud to Local Coordinates
Post by: ruyi7952 on October 04, 2017, 03:31:37 PM
second question

Code: [Select]
chunk.exportPoints("d:\\test.ply",  binary = 0, precision = 10, normals= 0, colors= 1, source = PhotoScan.DataSource.PointCloudData, format = PhotoScan.PointsFormatPLY)
2017-10-04 20:29:02 Traceback (most recent call last):
2017-10-04 20:29:02   File "C:/Users/12985/PycharmProjects/untitled/test.py", line 5, in <module>
2017-10-04 20:29:02     chunk.exportPoints("d:\\test.ply",  binary = 0, precision = 10, normals= 0, colors= 1, source = PhotoScan.DataSource.PointCloudData, format = PhotoScan.PointsFormatPLY)
2017-10-04 20:29:02 AttributeError: 'NoneType' object has no attribute 'exportPoints'
Title: Re: help me! about export point cloud to Local Coordinates
Post by: Alexey Pasumansky on October 04, 2017, 03:50:25 PM
Hello ruyi7952,

.con file is generated is there are control points in the project (defined via marker instances in PhotoScan), this file is not utilized for the automatic tie points.

As for the second question, have you defined chunk before using export? For the active chunk it can be:
Code: [Select]
chunk = PhotoScan.app.document.chunk
Title: Re: help me! about export point cloud to Local Coordinates
Post by: ruyi7952 on October 04, 2017, 04:04:44 PM
Hello ruyi7952,

.con file is generated is there are control points in the project (defined via marker instances in PhotoScan), this file is not utilized for the automatic tie points.

As for the second question, have you defined chunk before using export? For the active chunk it can be:
Code: [Select]
chunk = PhotoScan.app.document.chunk

Hello

Quote
.con file is generated is there are control points


please see my  sample post ,*.con and *.smtxml file are inclued tie points .
Title: Re: help me! about export point cloud to Local Coordinates
Post by: Alexey Pasumansky on October 04, 2017, 08:51:48 PM
Hello ruyi7952,

.con file will be created if you have any markers in your project that are checked on in the Reference pane.

As for the TiePoints section, I'll check that.
Title: Re: help me! about export point cloud to Local Coordinates
Post by: ruyi7952 on October 04, 2017, 09:03:55 PM
Hello Alexey,thanks you。

I have uploaded UASMaster 8.1.x projects export as attach.

Hope to help with your work。

Cheers!
Title: Re: help me! about export point cloud to Local Coordinates
Post by: Alexey Pasumansky on October 24, 2017, 11:07:52 AM
Hello ruyi7952,

You can check with the version 1.4.0 pre-release (build 5251) Summit evolution export settings in File Menu -> Export -> Export Cameras. Now it allows to enable markers export and tie points export. Please note, however, that for large sparse clouds the tie points information would result in large file size.
Title: Re: help me! about export point cloud to Local Coordinates
Post by: ruyi7952 on November 08, 2017, 05:59:53 PM
Hello Alexey Pasumansky

large file needed large memory... i think you make file body  in  memory.can you fix it?