add parameter to control range and extended range for annotations

pull/322/head
marina.kolpakova 12 years ago
parent decb137185
commit e9232a4b67
  1. 14
      apps/sft/misc/roc_test.py
  2. 11
      apps/sft/misc/sft.py

@ -14,6 +14,13 @@ bgr = { "red" : ( 0, 0, 255),
"green" : ( 0, 255, 0), "green" : ( 0, 255, 0),
"blue" : (255, 0 , 0)} "blue" : (255, 0 , 0)}
def range(s):
try:
lb, rb = map(int, s.split(','))
return lb, rb
except:
raise argparse.ArgumentTypeError("Must be lb, rb")
def call_parser(f, a): def call_parser(f, a):
return eval( "sft.parse_" + f + "('" + a + "')") return eval( "sft.parse_" + f + "('" + a + "')")
@ -31,11 +38,16 @@ if __name__ == "__main__":
parser.add_argument("-o", "--output", dest = "output", type = str, metavar= "path", help = "Path to store resultiong image.", default = "./roc.png") parser.add_argument("-o", "--output", dest = "output", type = str, metavar= "path", help = "Path to store resultiong image.", default = "./roc.png")
parser.add_argument("-n", "--nscales", dest = "nscales", type = int, metavar= "n", help = "Prefered count of scales from min to max.", default = 55) parser.add_argument("-n", "--nscales", dest = "nscales", type = int, metavar= "n", help = "Prefered count of scales from min to max.", default = 55)
parser.add_argument("-r", "--scale-range", dest = "scale_range", type = range, default = (128 * 0.4, 128 * 2.4))
parser.add_argument("-e", "--extended-range-ratio", dest = "ext_ratio", type = float, default = 1.25)
# required # required
parser.add_argument("-f", "--anttn-format", dest = "anttn_format", choices = ['inria', 'caltech', "idl"], help = "Annotation file for test sequence.", required = True) parser.add_argument("-f", "--anttn-format", dest = "anttn_format", choices = ['inria', 'caltech', "idl"], help = "Annotation file for test sequence.", required = True)
args = parser.parse_args() args = parser.parse_args()
print args.scale_range
print args.cascade print args.cascade
# # parse annotations # # parse annotations
sft.initPlot() sft.initPlot()
@ -64,6 +76,8 @@ if __name__ == "__main__":
boxes = samples[tail] boxes = samples[tail]
boxes = sft.norm_acpect_ratio(boxes, 0.5) boxes = sft.norm_acpect_ratio(boxes, 0.5)
boxes = [b for b in boxes if (b[3] - b[1]) > args.scale_range[0] / args.ext_ratio]
boxes = [b for b in boxes if (b[3] - b[1]) < args.scale_range[1] * args.ext_ratio]
nannotated = nannotated + len(boxes) nannotated = nannotated + len(boxes)
nframes = nframes + 1 nframes = nframes + 1

@ -75,19 +75,22 @@ def initPlot(name = "ROC curve Bahnhof"):
"""Show resulted plot""" """Show resulted plot"""
def showPlot(file_name): def showPlot(file_name):
# plt.savefig(file_name) plt.savefig(file_name)
plt.axis((pow(10, -3), pow(10, 1), 0.0, 1)) plt.axis((pow(10, -3), pow(10, 1), 0.0, 1))
plt.yticks( [0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.64, 0.8, 1], ['.05', '.10', '.20', '.30', '.40', '.50', '.64', '.80', '1'] ) plt.yticks( [0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.64, 0.8, 1], ['.05', '.10', '.20', '.30', '.40', '.50', '.64', '.80', '1'] )
plt.show() plt.show()
def match(gts, dts): def match(gts, dts):
# Cartesian product for each detection BB_dt with each BB_gt
overlaps = [[dt.overlap(gt) for gt in gts]for dt in dts]
matches_gt = [0]*len(gts) matches_gt = [0]*len(gts)
matches_dt = [0]*len(dts) matches_dt = [0]*len(dts)
matches_ignore = [0]*len(dts) matches_ignore = [0]*len(dts)
if len(gts) == 0:
return matches_dt, matches_ignore
# Cartesian product for each detection BB_dt with each BB_gt
overlaps = [[dt.overlap(gt) for gt in gts]for dt in dts]
for idx, row in enumerate(overlaps): for idx, row in enumerate(overlaps):
imax = row.index(max(row)) imax = row.index(max(row))

Loading…
Cancel
Save