'**SUMMARY**
This function finds the latest file in a directory
with a given extension.
**PARAMETERS**
directory - The directory you want to load images from (defaults to current directory)
extension - The image extension you want to use (defaults to .png)
**RETURNS**
The filename of the latest image
**USAGE**
>>> cam = VirtualCamera(\'imgs/\', \'png\') #find all .png files in \'img\' directory
>>> cam.getImage() # Grab the latest image from that directory'

def findLastestImage(self, directory='.', extension='png'):

    max_mtime = 0
    max_dir = None
    max_file = None
    max_full_path = None
    for (dirname, subdirs, files) in os.walk(directory):
        for fname in files:
            if (fname.split('.')[(-1)] == extension):
                full_path = os.path.join(dirname, fname)
                mtime = os.stat(full_path).st_mtime
                if (mtime > max_mtime):
                    max_mtime = mtime
                    max_dir = dirname
                    max_file = fname
                    self.lastmtime = mtime
                    max_full_path = os.path.abspath(os.path.join(dirname, fname))
    while ((time.mktime(time.localtime()) - os.stat(max_full_path).st_mtime) < 0.1):
        time.sleep(0)
    return max_full_path
