Determines and returns the next sequence number to use when saving an image in the specified directory.
set checkAtEnd to True if the sequence is at the end of the filename
The sequence starts at 0.
"""
result=-1
ifbasename!='':
basename=basename+"-"
prefix_length=len(basename)
forpinos.listdir(path):
l=os.path.splitext(p)[0].split('-')
try:
ifcheckAtEnd:
result=max(int(l[-1]),result)
else:
ifp.startswith(basename):
l=os.path.splitext(p[prefix_length:])[0].split('-')#splits the filename (removing the basename first if one is defined, so the sequence number is always the first element)