SeaBee-no / seabeepy

Useful Python functions for common SeaBee workflows
1 stars 1 forks source link

Convert GCPs from ODM <=> Pix4D #7

Open JamesSample opened 1 year ago

JamesSample commented 1 year ago

It would be nice to add a function to sb.ortho to convert between the different text formats used for Ground Control Points (GCPs) in ODM and Pix4D. This would make it easier to re-run missions previously processed using Pix4D on NodeODM, which is useful for making "fair" comparisons.

Open Drone Map

The GCP format for NodeODM is documented here and looks like this:

+proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
297616.62 6699989.92 44.5 2304 1057 DJI_0001.JPG gcp3
297616.62 6699989.92 44.5 2320 1731 DJI_0002.JPG gcp3
297616.62 6699989.92 44.5 2291 2519 DJI_0003.JPG gcp3

In other words:

<projection>
geo_x geo_y geo_z im_x im_y image_name gcp_name

What software do you use to generate these files, @awigeon?

Pix4D

Pix4D assumes WGS84-based geographic co-ordinates by default. The basic format is documented here and looks like this:

GS18T_1;565025.763;6541468.499;1.798
GS18T_2;565043.528;6541413.865;4.962
GS18T_3;565074.924;6541368.255;0.506
GS18T_4;565108.528;6541304.199;0.965
GS18T_5;564998.028;6541340.293;0.489

i.e.

gcp_name;geo_x;geo_y;geo_z

How do you generate these files, @medyang?


The ODM format makes sense to me, as it clearly maps ground co-ordinates to image co-ordinates. However, the Pix4D files do not contain image/pixel co-ordinates, so I guess Pix4D must store them separately? Any thoughts on how this works in Pix4D, @medyang, @awigeon? How does Pix4D link geographic co-ordinates in the GCP file to pixel co-ordinates in the raw images (I've never used Pix4D)?

Writing a function to convert between formats will be straightforward, but only if we can get all the necessary information from the Pix4D files.

JamesSample commented 1 year ago

According to Bing AI:

Pix4D stores the pixel coordinates internally. However, when exporting the GCPs, Pix4D only includes the name of the GCPs along with their geographic coordinates. The image/pixel coordinates are not included in the exported GCP file.

To get the image/pixel coordinates, you would need to manually mark the GCPs on the images in Pix4D and note down the pixel coordinates along with the image name. This can be a time-consuming process, especially if you have a large number of images and GCPs.

Unfortunately, there is no direct way to export the GCPs from Pix4D with the image/pixel coordinates included. You might need to use a combination of Pix4D and other tools or scripts to automate this process.

If this is correct, there is no easy way to convert between formats and we'll need to generate GCP files independently for ODM and Pix4D. So either Bing is wrong, or the design of Pix4D is really irritating!