Skip to content

Commit

Permalink
load sift features from mat instead of txt files, another 1.5s faster
Browse files Browse the repository at this point in the history
  • Loading branch information
nico committed Jun 30, 2013
1 parent 349b236 commit 31a56c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sift.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PIL import Image
import numpy
import os
import scipy.io as sio

def process_image(imagename, resultname,
params='--edge-thresh 10 --peak-thresh 5'):
Expand All @@ -13,10 +14,14 @@ def process_image(imagename, resultname,
cmd = ' '.join(['sift', imagename, '--output=' + resultname, params])
os.system(cmd)

# Re-write as .mat file, which loads faster.
f = numpy.loadtxt(resultname)
sio.savemat(resultname + '.mat', {'f':f}, oned_as='row')


def read_features_from_file(filename):
'''Returns feature locations, descriptors.'''
f = numpy.loadtxt(filename)
f = sio.loadmat(filename + '.mat')['f']
return f[:, :4], f[:, 4:]


Expand Down

0 comments on commit 31a56c3

Please sign in to comment.