geo2raw.get_img_coords_dict
sometimes returns wrong coordinates
#14
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It is an existing bug with pix4d pmatrix calculation, it sometimes tends to project plot on another unrelated images very far away. The solution I currently used to deal with it, is adding pix2d_dict = geo2raw.get_img_coords_dict(p4d, points, method='pmat')
pix2d_dict_filter = geo2raw.filter_cloest_img(p4d, pix2d_dict, points, num=3, dist_thresh=5) You can either use num or dist_thresh to filter wrong images
I guess in your case, you prefer not missing any tree labels in each image, so the num filter is not applicable. But even using the distance filter, please be very careful about your flight height and camera FOV, the dist_thresh (geo_dist) need changes on different conditions. (Please check the document Package Usage | Transformer and use PS: This function has been posted into the latest EasyIDP version, you need to download again. Or def filter_closest_img(p4d, img_dict, plot_geo, dist_thresh=None, num=None):
"""[summary]
Parameters
----------
img_dict : dict
The outputs dict of geo2raw.get_img_coords_dict()
plot_geo : nx3 ndarray
The plot boundary polygon vertex coordinates
num : None or int
Keep the closest {x} images
dist_thresh : None or float
If given, filter the images smaller than this distance first
Returns
-------
dict
the same structure as output of geo2raw.get_img_coords_dict()
"""
dist_geo = []
dist_name = []
img_dict_sort = {}
for img_name, img_coord in img_dict.items():
xmin_geo, ymin_geo = plot_geo[:,0:2].min(axis=0)
xmax_geo, ymax_geo = plot_geo[:,0:2].max(axis=0)
xctr_geo = (xmax_geo + xmin_geo) / 2
yctr_geo = (ymax_geo + ymin_geo) / 2
ximg_geo, yimg_geo, _ = p4d.img[img_name].cam_pos
image_plot_dist = np.sqrt((ximg_geo-xctr_geo) ** 2 + (yimg_geo - yctr_geo) ** 2)
if dist_thresh is not None and image_plot_dist > dist_thresh:
# skip those image-plot geo distance greater than threshold
continue
else:
# if not given dist_thresh, record all
dist_geo.append(image_plot_dist)
dist_name.append(img_name)
if num is None:
# not specify num, use all
num = len(dist_name)
else:
num = min(len(dist_name, num))
dist_geo_idx = np.asarray(dist_geo).argsort()[:num]
img_dict_sort = {dist_name[idx]:img_dict[dist_name[idx]] for idx in dist_geo_idx}
return img_dict_sort |
Beta Was this translation helpful? Give feedback.
It is an existing bug with pix4d pmatrix calculation, it sometimes tends to project plot on another unrelated images very far away.
The solution I currently used to deal with it, is adding
geo2raw.filter_cloest_img()
function to judge whether the camera geo position is just above plot geo position.You can either use num or dist_thresh to filter wrong images
num
: Only keep 3 closest images. (If not given, using the following distance filter)dist_thresh
: filter image-plot geo distance < 5mI guess in your case, you prefer not m…