I am writing a code on extracting the bounding boxes from an image and then compute IoU with ground truth annotations. My bounding box co-ordinates for both predicted and ground truth are in the form of a list [xmin,ymin,xmax,ymax]. I have written a for loop which extract the bounding information from a dictionary and then stores it in a list.
box = v7wpoint.boxidtobox[answer_boxid]
for key in box:
# print key
xmin_gt = box.get('x')
ymin_gt = box.get('y')
height = box.get('height')
width = box.get('width')
final_bb = []
xmax_gt = xmin_gt+width
ymax_gt = ymin_gt+height
bb_gt = [xmin_gt,ymin_gt,xmax_gt,ymax_gt]
final_bb.append(bb_gt)
rect_gt = np.array([[xmin_gt,ymin_gt],[xmin_gt,ymax_gt],[xmax_gt,ymax_gt],[xmax_gt,ymin_gt],[xmin_gt,ymin_gt]])
plt.plot(rect_gt[:,0],rect_gt[:,1],'g',markersize=4)
print (box.get('x'),box.get('y'),box.get('height'),box.get('width'),box.get('name'))
At the end of this for loop I am getting only one bounding box information - final_bb([xmin,ymin,xmax,ymax]). I need a list which contains a list of all bounding box co-ordinates. Something like this
1. [xmin,ymin,xmax,ymax]
2. [xmin,ymin,xmax,ymax]
3. [xmin,ymin,xmax,ymax]
.
.
.
N. [xmin,ymin,xmax,ymax]
I know this is a very trivial question but I am new to python and facing difficulty in manipulating data structures in python.
box, over and over, as many times as there are keys. The loop suite doesn't depend on the value ofkey, so what does doing the operations repeatedly accomplish? - mwchasebox, that makes no reference tokey, so why does it need to happen a bunch of times? - mwchase