def normalise2(self, annot, objs) : area = float(annot.width * annot.height) for o in objs : a = AnnotationFeature() a.name = o.name a.parent = annot a.value = o.area / area a.save()
def normalise1(self, annot, objs) : total = {} labels = list(set(map(lambda x : x.name, objs))) #labels = ['aeroplane','bicycle','bird','boat','bottle','bus','car','cat','chair','cow','diningtable','dog','food','hand','head','horse','motorbike','person','pottedplant','sheep','sofa','train','tvmonitor'] : for i in labels : total[i] = 0 for o in objs : total[o.name] += o.area fac = math.sqrt(float(sum(map(lambda x : x ** 2, total.values())))) for k,v in total.iteritems() : if v != 0 : a = AnnotationFeature() a.name = k a.value = v / fac a.parent = annot a.save()