batch generator.py
import os
featuresbat = open("extractfeatures.bat", 'w')
matchesbat = open("computematches.bat", 'w')
matchesfile = open("matlabinputfile.txt",'w')
file = 0
image = 0
# How many frames do we skip between the images?
frames_to_skip = 15
if (os.path.isdir('images')!= 1):
print("Image file directory not found")
exit()
if (os.path.isdir('FEATURES')!= 1):
os.mkdir('FEATURES')
if (os.path.isdir('MATCHES')!= 1):
os.mkdir('MATCHES')
for dirpath, dirnames, files in os.walk('images'):
for filename in files:
featuresbat.write("\"EXE/features.exe\" 0 images/%s.pgm FEATURES/%s.key\n" %(filename[:-4], filename[:-4]))
if (file > 0):
if (image + frames_to_skip > 99):
if (image + frames_to_skip > 999):
matchesbat.write("\"EXE/match.exe\" FEATURES/%s.key FEATURES/%s%s.key MATCHES/frames_%s-%s.txt\n" %(oldfile[:-4], filename[:-8], image+frames_to_skip, image, image+frames_to_skip))
else:
matchesbat.write("\"EXE/match.exe\" FEATURES/%s.key FEATURES/%s%s.key MATCHES/frames_%s-%s.txt\n" %(oldfile[:-4], filename[:-7], image+frames_to_skip, image, image+frames_to_skip))
elif (image + frames_to_skip < 99):
matchesbat.write("\"EXE/match.exe\" FEATURES/%s.key FEATURES/%s0%s.key MATCHES/frames_%s-%s.txt\n" %(oldfile[:-4], filename[:-7], image+frames_to_skip, image, image+frames_to_skip))
matchesfile.write("frames_%s-%s.txt\n" %(image, image+frames_to_skip))
file = file + 1
image = image + 1
oldfile = filename
featuresbat.close()
matchesbat.close()
matchesfile.close()
documentation/batch_generator.py.txt · Last modified: 2009/01/05 21:13 (external edit)