The topic is originally posted on opensfm (#915), but I didn’t get an answer for a few days. I think I may get some help here.
Basically, I want to project ground control point to image to get the pixel coordinates of the control point. I believe this can relieve people from picking the gcps on the image one by one. Although there are some great work(e.g. Find_GCP ) on automatically detecting gcp with some patterns, but not all the gcps have these patterns, so it may fail.
Below are my findings for these days:
First, we need to transform the gcp coordinates to WGS84, we can get lat, lon, alt. Then use the following code to project the ground control point to image.
pt3D= reference.to_topocentric(lat,` lon, alt)
pt2D= shot.project(pt3D)
pt2D_px = cam.normalized_to_pixel_coordinates(pt2D)
then check if the pt2D_px is inside the camera frustum.
I only have one problem here is that the altitude of `pt3D` is NOT right, resulting in the wrong `pt2D_px `. But I don't know how to get the right altitude since the reference altitude is set to 0 in function `invent_reference_from_gps_and_gcp` of `dataset.py`, and the height of ground control point ususally near 0, so we always get ~0 altitude of pt3D.
I checked the point altitude of reconstruted point cloud using Meshlab. The point altitude has a value of -90 ~ -70 m。If we use this altitude to project gcp to image, we can get the right coordinates.
So how can I get the right altitude when transform the gcp to topocentric?
Thank you for your time.