def server_record(N=10, camera_name='MicroscopeCamera'): camera = Camera(camera_name) camera.acquiring = True # Offload the image saving to the camera server for performance filenames = [template % i for i in range(N)] frame_counts = [camera.frame_count + 1 + i for i in range(len(filenames))] camera.send("camera.acquire_sequence(%r,%r)" % (frame_counts, filenames))
def save_images(buffer, t=10): sys.path.append( 'z:\\all projects\\aps\\instrumentation\\software\\lauecollect\\') from GigE_camera_client import Camera camera = Camera('MicrofluidicsCamera') camera.exposure_time = 0.001 camera.stream_bytes_per_second = 1392640 from ubcs_auxiliary.threading import new_thread new_thread(save_image_loop, t, buffer, camera)
def record1(camera_name='MicroscopeCamera'): template_NIH= "//femto/C/All Projects/Crystallization/2019/Lysozyme3/"\ "%s_%r.tiff" camera1 = Camera('LabMicroscope') camera1.acquiring = True i = 0 while True: filename = template % (time(), i) print("%s" % basename(filename)) camera1.save_image(filename) i += 1
def get_background(): from numpy import array sys.path.append( 'z:\\all projects\\aps\\instrumentation\\software\\lauecollect\\') from GigE_camera_client import Camera camera = Camera('MicrofluidicsCamera') data = camera.RGB_array return array(data[:, :, 720:840])
def record(camera_name='MicroscopeCamera'): camera1 = Camera('MicroscopeCamera') camera1.acquiring = True camera2 = Camera('WideFieldCamera') #camera2.ip_address = '164.54.161.34:2001' camera2.acquiring = True try: i = 0 while True: ins = 0 filename = template % ("Microscope/", time(), i, int(ins), temperature.value) print("%s" % basename(filename)) camera1.save_image(filename) filename = template % ("WideField/", time(), i, int(ins), temperature.value) print("%s" % basename(filename)) camera2.save_image(filename) i += 1 sleep(delay) except KeyboardInterrupt: pass
logging.basicConfig(filename=gettempdir() + '/scripts.log', level=logging.DEBUG, format="%(asctime)s %(levelname)s: %(message)s") from sys import platform if platform == "linux" or platform == "linux2": pass elif platform == "darwin": sys.path.append( '/net/femto/C/All Projects/APS/Instrumentation/Software/Lauecollect/' ) elif platform == "win32": sys.path.append( 'z:\\all projects\\aps\\instrumentation\\software\\lauecollect\\') from GigE_camera_client import Camera camera = Camera('MicrofluidicsCamera') data = camera.RGB_array from matplotlib import pyplot as plt anchors = [(0, 730), (1360, 830)] import matplotlib.patches as patches # Create figure and axes fig, ax = plt.subplots(1) # Display the image ax.imshow(data[0].T) # Create a Rectangle patch rect = patches.Rectangle(anchors[0], 1360, 100, linewidth=1, edgecolor='r', facecolor='none')
return (motorX.value, motorY.value, motorZ.value) def get_DVH_position(): from numpy import sin, cos, pi V = round(motorY.value * sin(pi / 6.0), 3) H = motorZ.value D = round(motorY.value * cos(pi / 6.0), 3) return (D, V, H) template = template_APS_MAC delay = 0.0025 #in seconds i = 0 camere_Microscope = Camera("MicroscopeCamera") camere_Microscope.acquiring = True camera_WideField = Camera('WideFieldCamera') camera_WideField.acquiring = True g_res = [] def analyze(g_res): from PIL import Image import numpy as np import traceback from time import time list_of_files = os.listdir(template_APS_MAC_folder) res = [] t1 = time() for i in range(len(list_of_files)):
numpy.save(self.logFolder + filename, data, allow_pickle=True) """plotting functions""" def plot_array(self, arr): from numpy import float32 if arr.min() < 0: #for difference image to be plotted properly plt.imshow(arr[:, :, 0:3] - arr.min()) else: plt.imshow(arr[:, :, 0:3]) plt.colorbar() plt.show() from GigE_camera_client import Camera camera = Camera("MicroscopeCamera") laue_image_analyser = Camera_image_analyser( name='LAUE_image_analyser', camera_name='MicroscopeCamera') #for LAUE crystalography if __name__ == "__main__": import logging from tempfile import gettempdir import logging logfile = gettempdir() + "/logging/camera_image_analyser.log" logger = logging.getLogger('camera_image_analyser') hdlr = logging.FileHandler(logfile) formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) logger.addHandler(hdlr)
"%s_%00d_%r_%r_%r.tiff" template = template_NIH delay = 0.0025 #in seconds i = 0 from EPICS_motor import motor from instrumentation import temperature from sample_frozen_optical import sample_frozen_optical as sfo motorX = motor("NIH:SAMPLEX") motorY = motor("NIH:SAMPLEY") motorZ = motor("NIH:SAMPLEZ") #camera = Camera("Microscope") camera1 = Camera('MicroscopeCamera') camera1.acquiring = True #camera = Camera("MicroscopeCamera") def record_T_once(l): from numpy import zeros, flip from SAXS_WAXS_control import SAXS_WAXS_control ins = 0 #str(SAXS_WAXS_control.inserted) filename = template % ("Microscope/", time(), l, int(ins), temperature.value) print("%s" % basename(filename)) img = camera1.RGB_array gray = sum(img, 2) arr = zeros((4, 1024, 1360)) for i in range(3):
def camera(self): from GigE_camera_client import Camera camera = Camera("MicroscopeCamera") return camera