DataPack function to Retrieve overlapped ImageAnnotation using data structure grid #888
Open
Description
Is your feature request related to a problem? Please describe.
One of the main reasons for creating grid is to searching overlapped ImageAnnotation
efficiently. However, the current code supports compute iou but not search overlapped ImageAnnotation
.
Describe the solution you'd like
- store a grid in the DataPack
- store two dictionaries in the DataPack based on the grid
- dictionary 1: key is grid cell position and value is a collection of image annotation presented at the grid cell
- dictionary 2: key is the image annotation and value is a list of grid cell positions it's on
- implement a function that search overlapped
ImageAnnnotation
given aImageAnnnotation
using the two dictionaries
grid_cells = dict2[query_ia]
image_anns = set()
for gc in grid_cells:
for ia in dict1[gc]:
image_anns.add(ia)
out = []
for ia in image_anns:
if ia.overlap(query_ia):
out.append(ia)
return ia
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
This is a follow-up issue on #876 (comment)