.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/live_imaging/taking_an_image_every_minute.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_live_imaging_taking_an_image_every_minute.py: Taking an Image every 10 seconds ================================ This example shows how to take an image every minute. The results are saved to disk as: - Individual frames (Movies) - The final summed image (Final Image) In this case we can set the "Autosave Movie Sum Count" to 10. This will sum 10 frames together before saving the final image. .. GENERATED FROM PYTHON SOURCE LINES 13-54 .. code-block:: Python from cgitb import enable import deapi import matplotlib.pyplot as plt import time import sys c = deapi.Client() if not sys.platform.startswith("win"): c.usingMmf = False # True if on same machine as DE Server and a Windows machine c.connect() # Set the autosave directory loc_time = time.localtime() c["Autosave Directory"] = ( f"D:\\Service\\{loc_time.tm_year}-{loc_time.tm_mon}-{loc_time.tm_mday}" ) c["Autosave Movie"] = "On" # Save the individual frames c["Autosave Final Image"] = "On" # Save the final summed image c["Exposure Time (seconds)"] = ( 1 # The total number of frames summed for one call to `c.start_acquisition`. ) c.scan(enable="Off") # Make Sure we disable the scan, we are just taking images results = [] # store the results in a list for i in range(5): # increase this for more images print(f"Taking image {i + 1} of 10") c.start_acquisition( 1 ) # Acquire one image (This is non-blocking and should run very fast) time.sleep(5) # sleep for 5 seconds # this might take a half a second? # You can also just skip this and load directly from the saved files. This gets only the summed image. results.append(c.get_result()) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/deapi/deapi/examples/live_imaging/taking_an_image_every_minute.py:14: DeprecationWarning: 'cgitb' is deprecated and slated for removal in Python 3.13 from cgitb import enable Command Version: 13 Taking image 1 of 10 Response: 1808 Taking image 2 of 10 Response: 1808 Taking image 3 of 10 Response: 1808 Taking image 4 of 10 Response: 1808 Taking image 5 of 10 Response: 1808 .. GENERATED FROM PYTHON SOURCE LINES 55-59 Load the final summed image ============================ This will load the final summed image from the first result in the list and then plots both the histogram and the image. .. GENERATED FROM PYTHON SOURCE LINES 59-66 .. code-block:: Python image, dtype, attributes, histogram = results[0] # get the first result plt.imshow(image) c.disconnect() .. image-sg:: /examples/live_imaging/images/sphx_glr_taking_an_image_every_minute_001.png :alt: taking an image every minute :srcset: /examples/live_imaging/images/sphx_glr_taking_an_image_every_minute_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 25.347 seconds) .. _sphx_glr_download_examples_live_imaging_taking_an_image_every_minute.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: taking_an_image_every_minute.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: taking_an_image_every_minute.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: taking_an_image_every_minute.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_