def __init__(self, serial_port, camera): """Initializes the class with serial interface/camera names, algorithm control parameters. Arguments: serial_port -- String of name for the serial interface for the microscope Arduino - e.g. 'dev/tty.usb' camera -- Integer for the V4L2 video device name e.g. 0 from '/dev/video0' """ self.create_gui() #Setup camera and video recording self.camera = cv2.VideoCapture(camera) self.width = int(self.camera.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) self.height = int(self.camera.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)) self.camera.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, self.width) self.camera.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, self.height) #Kernel for morphological opening/closing operation self.kernel = np.ones((3, 3), np.uint8) #Variables for controlling stage self.microscope = Microscope(serial_port) self.microscope.set_ring_colour('FF0000') self.last_step_time = datetime.now() #Use for FPS calculation self.last_frame = cv2.getTickCount() #Skeltonisation self.worm_spline = np.zeros((1001, 1, 2), dtype=np.int) self.tail = np.zeros((2, ), dtype=np.int) self.head = np.zeros((2, ), dtype=np.int)
def __init__(self, serial_port, camera, margin=10, threshold=127, step_size=10): """Initializes the class with serial interface/camera names, algorithm control parameters. Arguments: serial_port -- String of name for the serial interface for the microscope Arduino - e.g. 'dev/tty.usb' camera -- String of name for the V4L2 video device name e.g. '/dev/video0' margin -- Integer of pixel width of margin to keep worm centroid in - default 10 threshold -- Integer of threshold value for thresholding operation between 0 and 255 - default 127. step_size -- Integer of size of step for XY stage to take when re-centering worm """ cv2.namedWindow('Preview') self.microscope = Microscope(serial_port) self.camera = cv2.VideoCapture(camera) self.margin = margin self.threshold = threshold self.step_size = step_size
def __init__(self, serial_port, allowNone=False, useDateTime=False): """Initializes the class with serial port name of Arduino""" xmlrpc.XMLRPC.__init__(self, allowNone, useDateTime) self.microscope = Microscope(serial_port)