Forum

Author Topic: Java API: Metashape 1.8.2 - point coordinates of pointcloud wrong  (Read 6811 times)

M.Eli

  • Newbie
  • *
  • Posts: 8
    • View Profile
Hey everybody,

I updated the Metashape JAR in my java project to version 1.8.2. and run into a problem. I generated a georeferenced point cloud with ground control points. When I open the project everything is fine.
However, if I like to continue working with the java code and print the trackID + coordinates of my (sparse) point cloud, e.g. using this command:

Quote
for (int p = 0; p < pointCloud.get().getPoints().get().getSize(); p++) {
               PointCloud.Point pp = pointCloud.get().getPoints().get().get(p);
               System.out.println(pp.getTrackId() + ","+ pp.getCoord().getX() + "," + pp.getCoord().getY() +","+pp.getCoord().getZ());   
            }
            
I get an weird result like this:
ID,X,Y,Z
1617,-1.001014896494884E-14, 0.007812505590406374, 3.4312671939913E-311
1618,-1.4160203828280833E-14, 0.007812505591220983, 3.4333891897823E-311
1619,-3.233755625624215E-14, 0.007812505590504133, 3.4355111855733E-311
1620,-2.344639034314182E-14, 0.007812505590581154, 3.437633181364E-311
[...]

Almost all coordinates are 0,0,0 (rounded). When I open the project in the GUI, I can see the correctly determined sparse cloud (coordinates are as expected...).
 
Furthermore, I got an error when I try to calculate the reprojection error by camera.getError (pt (3D), proj (2)) -> "Exception in thread "main" java.lang.IllegalArgumentException: invalid array length" using the Vector from points.get(pointIdx).getCoord(). The 2D projections look good and plausible.

The entire procedure worked before the update!
What I´m doing wrong now?

Thank you very much!
« Last Edit: March 23, 2022, 04:34:03 PM by M.Eli »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15275
    • View Profile
Re: Java API: Metashape 1.8.2 - point coordinates of pointcloud wrong
« Reply #1 on: March 25, 2022, 01:42:09 PM »
Hello M.Eli,

Thank you for reporting the problem, we will fix the issue in the next version update.
Best regards,
Alexey Pasumansky,
Agisoft LLC

M.Eli

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Java API: Metashape 1.8.2 - point coordinates of pointcloud wrong
« Reply #2 on: March 25, 2022, 03:04:50 PM »
Hey Alexey,

thank you very much for your fast response and intended fix in the next version!
Much appreciated :)

Best regards!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15275
    • View Profile
Re: Java API: Metashape 1.8.2 - point coordinates of pointcloud wrong
« Reply #3 on: March 28, 2022, 06:05:19 PM »
Hello M.Eli,

Can you please check, if pre-release update of 1.8.3 solves the issue with the point coordinates now:
https://s3-eu-west-1.amazonaws.com/download.agisoft.com/metashape-java-api-1.8.3.zip
Best regards,
Alexey Pasumansky,
Agisoft LLC

M.Eli

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Java API: Metashape 1.8.2 - point coordinates of pointcloud wrong
« Reply #4 on: March 29, 2022, 08:29:50 AM »
Hey Alexey,

thanks a lot for the fast fix!
Yep, the error estimation works perfectly fine (results are the same compared to those from the GUI) and the point coordinates makes sense.

One minor question (might be off topic). The 3D point coords looks like being aligned in a local or the camera CRS (very small numbers) and not in the global project CRS (UTM). The processing included reference information (RTK-measured GCPs). Thus, I would expect that the 3D points from  pointCloud.get().getPoints() are located in the georeferenced project CRS, too.
Are those in the camera CRS and still need to be transfered into the project CRS?

Paulo

  • Hero Member
  • *****
  • Posts: 1389
    • View Profile
Re: Java API: Metashape 1.8.2 - point coordinates of pointcloud wrong
« Reply #5 on: March 29, 2022, 06:09:48 PM »
Hello MEli,

the point_cloud point coordinates are in the Internal CS. to get the coordinates in the project CRS, you must apply the chunk transform matrix to get geocentric CS coordinates and then chunk CRS projection to get coordinates in chunk CRS projection  (ex. UTM)....
Best Regards,
Paul Pelletier,
Surveyor

M.Eli

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Java API: Metashape 1.8.2 - point coordinates of pointcloud wrong
« Reply #6 on: March 29, 2022, 06:11:57 PM »
Hello MEli,

the point_cloud point coordinates are in the Internal CS. to get the coordinates in the project CRS, you must apply the chunk transform matrix to get geocentric CS coordinates and then chunk CRS projection to get coordinates in chunk CRS projection  (ex. UTM)....

Ah ok! This makes absolute sense. Thanks a lot, Paulo :)