You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am confused about how to access keypoints through an ID. I could not find any info on that. Is it even possible?
My plan is to get the matches of an image pair and for each match get the referenced keypoints positions on the images.
Here is my method for extracting the matches:
# Get matches for image pair
def get_matches(cursor, img1_id, img2_id):
pair_id = image_ids_to_pair_id(img1_id, img2_id)
cursor.execute(f"SELECT pair_id, rows, cols, data FROM matches WHERE pair_id={pair_id}")
result = cursor.fetchone()
if not result: return None
_, rows, cols, data = result
if not data: return None
dtype=np.uint32
shape=(-1, cols)
image_matches = np.frombuffer(data, dtype=dtype).reshape(*shape)
return {
"pair_id": int(pair_id),
"image1_id": int(img1_id),
"image2_id": int(img2_id),
"image_matches": image_matches
}
My assumption is that the array is the index of the keypoints in each image (index 0 for image1 and 1 for image2)
But this feels very unsafe in my eyes. When I extract the keypoints, I only get x and y coordinates but not the ID. Here is how I get the coordinates of the referenced keypoints in the matches:
# get coordinates of matches
def get_matches_coords(cursor, matches):
ret = []
skipped_kps = []
img1_kps = get_keypoints(cursor, matches["image1_id"])
img2_kps = get_keypoints(cursor, matches["image2_id"])
new_matches = dict(matches) # copy instance
new_matches["image_matches"] = [] # clear old matches to be replaced by coords
for im_m in matches["image_matches"]:
img1_kp_index = im_m[0]
img2_kp_index = im_m[1]
img1_kp_coords = img1_kps["coordinates"]
img2_kp_coords = img2_kps["coordinates"]
img1_kp_coords_len = img1_kp_coords.shape[0]
img2_kp_coords_len = img2_kp_coords.shape[0]
# filter out matches that cannot be accessed
# TODO: how do I properly get them?? This cannot be the way??
if img1_kp_index >= img1_kp_coords_len or img2_kp_index >= img2_kp_coords_len:
skipped_kps.append((img1_kp_index, img2_kp_index))
continue
im_m_coords = [
img1_kp_coords[img1_kp_index],
img2_kp_coords[img2_kp_index]
]
new_matches["image_matches"].append(im_m_coords)
if len(skipped_kps) != 0: print(f"skipped keypoints: {len(skipped_kps)}")
return new_matches
And here is how I get the keypoints:
def get_keypoints(cursor, img_id):
cursor.execute(f"SELECT image_id, rows, cols, data FROM keypoints WHERE image_id={img_id}")
result = cursor.fetchone()
if not result: return None
image_id, rows, cols, data = result
if not data:
return None
dtype=np.float32
shape=(-1, cols)
coordinates = np.frombuffer(data, dtype=dtype).reshape(*shape)
return {
"image_id": int(image_id),
"coordinates": coordinates
}
And here is how the output of get_keypoints would look like:
The results look like they could be true, but I am not sure how to verify it.
So now my question again: Does anybody know how to access a keypoint specifically by the information the matches table offers? And is the information stored in "data" column the reference to the index or ID of the matched keypoints?
Thanks :)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I am confused about how to access keypoints through an ID. I could not find any info on that. Is it even possible?
My plan is to get the matches of an image pair and for each match get the referenced keypoints positions on the images.
Here is my method for extracting the matches:
The output looks like this:
My assumption is that the array is the index of the keypoints in each image (index 0 for image1 and 1 for image2)
But this feels very unsafe in my eyes. When I extract the keypoints, I only get x and y coordinates but not the ID. Here is how I get the coordinates of the referenced keypoints in the matches:
And here is how I get the keypoints:
And here is how the output of get_keypoints would look like:
The results look like they could be true, but I am not sure how to verify it.
So now my question again: Does anybody know how to access a keypoint specifically by the information the matches table offers? And is the information stored in "data" column the reference to the index or ID of the matched keypoints?
Thanks :)
Beta Was this translation helpful? Give feedback.
All reactions