view scripts/performance-lcss.py @ 811:429bb43e8278 opencv3

switching the branches to correct names (opencv3.1 is old code previously updated to OpenCV3 and default is now updated to OpenCV 2.4.13
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 10 Jun 2016 15:44:37 -0400
parents a850a4f92735
children 933670761a57
line wrap: on
line source

#! /usr/bin/env python

import timeit

vectorLength = 10
number = 10

print('Default Python implementation with lambda')
print timeit.timeit('lcss.compute(random_sample(({},2)), random_sample(({}, 2)))'.format(vectorLength, vectorLength*2), setup = 'from utils import LCSS; from numpy.random import random_sample; lcss = LCSS(similarityFunc = lambda x,y: (abs(x[0]-y[0]) <= 0.1) and (abs(x[1]-y[1]) <= 0.1));', number = number)

print('Using scipy distance.cdist')
print timeit.timeit('lcss.compute(random_sample(({},2)), random_sample(({}, 2)))'.format(vectorLength, vectorLength*2), setup = 'from utils import LCSS; from numpy.random import random_sample; lcss = LCSS(metric = "cityblock", epsilon = 0.1);', number = number)