def grab_images(cam, num_images_to_grab):
    prev_ts = None
    for i in range(num_images_to_grab):
        try:
            image = cam.retrieveBuffer()
        except PyCapture2.Fc2error as fc2Err:
            print(('Error retrieving buffer : %s' % fc2Err))
            continue
        ts = image.getTimeStamp()
        if prev_ts:
            diff = (((ts.cycleSeconds - prev_ts.cycleSeconds) * 8000) + (ts.cycleCount - prev_ts.cycleCount))
            print(('Timestamp [ %d %d ] - %d' % (ts.cycleSeconds, ts.cycleCount, diff)))
        prev_ts = ts
    newimg = image.convert(PyCapture2.PIXEL_FORMAT.BGR)
    print('Saving the last image to fc2TestImage.png')
    newimg.save('fc2TestImage.png'.encode('utf-8'), PyCapture2.IMAGE_FILE_FORMAT.PNG)
def grab_images(cam, num_images_to_grab):
    prev_ts = None
    for i in range(num_images_to_grab):
        try:
            image = cam.retrieveBuffer()
        except PyCapture2.Fc2error as fc2Err:
            print(('Error retrieving buffer : %s' % fc2Err))
            continue
        ts = image.getTimeStamp()
        if prev_ts:
            diff = (((ts.cycleSeconds - prev_ts.cycleSeconds) * 8000) + (ts.cycleCount - prev_ts.cycleCount))
            print(('Timestamp [ %d %d ] - %d' % (ts.cycleSeconds, ts.cycleCount, diff)))
        prev_ts = ts
    newimg = image.convert(PyCapture2.PIXEL_FORMAT.BGR)
    print('Saving the last image to fc2TestImage.png')
    newimg.save('fc2TestImage.png'.encode('utf-8'), PyCapture2.IMAGE_FILE_FORMAT.PNG)