def run(self): while (self.running): self.mutex.lock() if self.acquire.amActive() and self.got_camera: # Fake data from camera1 cam1_frame = frame.Frame(self.camera1_fake_frame, self.frame_number, self.camera1_frame_size[0], self.camera1_frame_size[1], "camera1", True) # Fake data from camera2 cam2_frame = frame.Frame(self.camera2_fake_frame, self.frame_number, self.camera2_frame_size[0], self.camera2_frame_size[1], "camera2", False) self.frame_number += 1 if self.filming: if self.daxfile: if (self.acq_mode == "fixed_length"): if (self.frame_number <= self.frames_to_take): self.daxfile.saveFrame(cam1_frame) self.daxfile.saveFrame(cam2_frame) else: self.daxfile.saveFrame(cam1_frame) self.daxfile.saveFrame(cam2_frame) if (self.acq_mode == "fixed_length") and (self.frame_number == self.frames_to_take): self.reached_max_frames = True # Emit new data signal. self.newData.emit([cam1_frame, cam2_frame], self.key) # Emit max frames signal. # # The signal is emitted here because if it is emitted before # newData then you never see that last frame in the movie, which # is particularly problematic for single frame movies. # if self.reached_max_frames: self.max_frames_sig.emit() else: self.acquire.idle() self.mutex.unlock() self.msleep(self.sleep_time)
def run(self): while (self.running): self.mutex.lock() if self.acquire.amActive() and self.got_camera: # Get data from camera and create frame objects. [frames, frame_size] = self.camera.getFrames() # Check if we got new frame data. if (len(frames) > 0): # Create frame objects. frame_data = [] for cam_frame in frames: aframe = frame.Frame(cam_frame.getData(), self.frame_number, frame_size[0], frame_size[1], "camera1", True) frame_data.append(aframe) self.frame_number += 1 # Emit new data signal. self.newData.emit(frame_data, self.key) else: self.acquire.idle() self.mutex.unlock() self.msleep(5)
def newFrame(self, new_frame): sliced_data = self.sliceFrame(new_frame) if sliced_data is not None: return [ frame.Frame(sliced_data, new_frame.number, self.x_pixels, self.y_pixels, self.feed_name, False) ] else: return []
def run(self): while (self.running): self.mutex.lock() if self.acquire.amActive() and self.got_camera: for i in range(2): # Get data from camera and create frame objects. [frames, frame_size, state] = self.cameras[i].getImages16() # Check if we got new frame data. if (len(frames) > 0): # Create frame objects. # The first camera is considered to be the master camera. if (i == 0): master = True else: master = False frame_data = [] for raw_frame in frames: aframe = frame.Frame( numpy.fromstring(raw_frame, dtype=numpy.uint16), self.frame_number[i], frame_size[0], frame_size[1], "camera" + str(i + 1), master) frame_data.append(aframe) self.frame_number[i] += 1 if self.filming: if self.daxfile: if (self.acq_mode == "fixed_length"): if (self.frame_number[i] <= self.frames_to_take): self.daxfile.saveFrame(aframe) else: self.daxfile.saveFrame(aframe) if (self.acq_mode == "fixed_length") and ( self.frame_number[0] == self.frames_to_take): self.reached_max_frames = True break # Emit new data signal. self.newData.emit(frame_data, self.key) # Emit max frames signal. if self.reached_max_frames: self.max_frames_sig.emit() else: self.acquire.idle() self.mutex.unlock() self.msleep(5)
def run(self): while (self.running): self.mutex.lock() if self.acquire.amActive() and self.got_camera: # Get data from camera and create frame objects. [frames, frame_size, state] = self.camera.getImages16() # Check if we got new frame data. if (len(frames) > 0): # Create frame objects. frame_data = [] for raw_frame in frames: aframe = frame.Frame( numpy.fromstring(raw_frame, dtype=numpy.uint16), self.frame_number, frame_size[0], frame_size[1], "camera1", True) frame_data.append(aframe) self.frame_number += 1 if self.filming: if self.daxfile: if (self.acq_mode == "fixed_length"): if (self.frame_number <= self.frames_to_take): self.daxfile.saveFrame(aframe) else: self.daxfile.saveFrame(aframe) if (self.acq_mode == "fixed_length") and ( self.frame_number == self.frames_to_take): self.reached_max_frames = True break # Emit new data signal. self.newData.emit(frame_data, self.key) # Emit max frames signal. # # The signal is emitted here because if it is emitted before # newData then you never see that last frame in the movie, which # is particularly problematic for single frame movies. # if self.reached_max_frames: self.max_frames_sig.emit() else: self.acquire.idle() self.mutex.unlock() self.msleep(5)
def newFrame(self, new_frame): sliced_data = self.sliceFrame(new_frame) if sliced_data is not None: if (new_frame.number % self.cycle_length) in self.capture_frames: self.frame_number += 1 return [ frame.Frame(sliced_data, self.frame_number, self.x_pixels, self.y_pixels, self.feed_name, False) ] else: return [] else: return []
def newFrame(self, new_frame): sliced_data = self.sliceFrame(new_frame) if sliced_data is not None and (new_frame.number == self.which_frame): FeedLastFilm.cur_film_frame = frame.Frame(sliced_data, new_frame.number, self.x_pixels, self.y_pixels, self.feed_name, False) if self.update and FeedLastFilm.last_film_frame is not None: if (FeedLastFilm.last_film_frame.image_x == self.x_pixels) and (FeedLastFilm.last_film_frame.image_y == self.y_pixels): self.update = False return [FeedLastFilm.last_film_frame] return []
def run(self): while (self.running): self.mutex.lock() if self.acquire.amActive() and self.got_camera: aframe = frame.Frame( numpy.roll(self.fake_frame, int(self.frame_number * self.roll)), self.frame_number, self.fake_frame_size[0], self.fake_frame_size[1], "camera1", True) self.frame_number += 1 # Emit new data signal. self.newData.emit([aframe], self.key) else: self.acquire.idle() self.mutex.unlock() self.msleep(self.sleep_time)
def newFrame(self, new_frame): sliced_data = self.sliceFrame(new_frame) if sliced_data is not None: if self.average_frame is None: self.average_frame = sliced_data.astype(numpy.uint32) else: self.average_frame += sliced_data self.counts += 1 if (self.counts == self.frames_to_average): average_frame = self.average_frame / self.frames_to_average self.average_frame = None self.counts = 0 self.frame_number += 1 return [ frame.Frame(average_frame.astype(numpy.uint16), self.frame_number, self.x_pixels, self.y_pixels, self.feed_name, False) ] else: return []
c_int(frame.image_y)) # # Testing # if __name__ == "__main__": import camera.frame as frame import numpy import time image_x = 512 image_y = 512 aframe = frame.Frame(numpy.ones((image_x, image_y), dtype=numpy.uint16), 0, image_x, image_y, "camera1", True) repeats = 200 start = time.time() for i in range(repeats): imageGradient(aframe) end = time.time() print "Time to process an image: ", ((end - start) / repeats), " seconds" # # The MIT License # # Copyright (c) 2013 Zhuang Lab, Harvard University # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal