Camera acquisition
Python Script
Example script showing different types of camera acquisition.
Preview
''' Example script showing different types of camara acquisition. ''' import DigitalMicrograph as DM import numpy as np # Get the current camera and ensure it is ready for acquisition cam = DM.GetActiveCamera() cam.PrepareForAcquire() # Simpe single read-out acquisition DM.OkDialog( 'Showing simple single acquire.' ) exposure = 0.1 bin = 1 kUnproc = DM.GetCameraUnprocessedEnum() cam.AcquireImage( exposure, bin, bin, kUnproc ).ShowImage() # In-place single read-out acquisition DM.OkDialog( 'Showing single in-place acquire.' ) preImg = cam.CreateImageForAcquire( bin, bin, kUnproc ) preImg.SetName( "Pre-created image container" ) preImg.ShowImage() DM.OkDialog( 'Image created, now acquire...' ) cam.AcquireInPlace( preImg, exposure, bin, bin, kUnproc ) del preImg # Always delete Py_Image variables again # Continuous acquistion example DM.OkDialog( 'Showing continuous acquisition. 20 frames' ) dstImage = cam.CreateImageForAcquire( bin, bin, kUnproc ) dstImage.SetName( "Container" ) dstImage.ShowImage() cam.StartContinuousAcquisition( exposure, bin, bin, kUnproc ) nFrames = 20 # Number of readouts until script stops max_wait_s = 5 # time out after 5 sec. for i in range(0,nFrames): if ( cam.GetFrameInContinuousMode( dstImage, max_wait_s ) ): print( 'Got frame #', i ) dstImage.UpdateImage() # Force display update else: print( 'Time-out' ) cam.StopContinuousAcquisition( ) del dstImage # Always delete Py_Image variables again print( 'All done now.' )