def __init__(self, start, end, rate, step_size=50): self.start = start self.end = end self.rate = rate now = datetime.datetime.now() self.log_direc = "/media/data/Data/Logs/{}_{}_{}_{}_{}/".format( now.year, now.month, now.day, now.hour, now.minute) try: os.mkdir(self.log_direc) except FileExistsError as e: print(e) self.i = 0 self.shaker = shaker.Shaker() self.shaker.change_duty(self.start) self.step_size = step_size cam_num = camera.guess_camera_number() port = STEPPER_CONTROL self.ard = arduino.Arduino(port) self.motors = stepper.Stepper(self.ard) self.motors.move_motor(1, 100, '+') self.motors.move_motor(2, 100, '+') self.motors.move_motor(1, 100, '-') self.motors.move_motor(2, 100, '-') self.cam = camera.Camera(cam_num=cam_num) im = self.cam.get_frame() self.hex, self.center, self.crop, self.mask = self.find_hexagon(im) im = images.crop_and_mask(im, self.crop, self.mask) self.im_shape = im.shape im = images.draw_polygon(im, self.hex) im = images.draw_circle(im, self.center[0], self.center[1], 3) images.display(im)
def __init__(self): self.shaker = shaker.Shaker() self.shaker.change_duty(600) port = STEPPER_CONTROL self.ard = arduino.Arduino(port) self.motors = stepper.Stepper(self.ard) cam_num = camera.guess_camera_number() self.cam = camera.Camera(cam_num=cam_num) im = self.cam.get_frame() self.hex, self.center, self.crop, self.mask = self.find_hexagon(im) im = images.crop_and_mask(im, self.crop, self.mask) self.im_shape = im.shape im = images.draw_polygon(im, self.hex) im = images.draw_circle(im, self.center[0], self.center[1], 3) images.display(im)
from labequipment import shaker, arduino, stepper from labvision import camera, images import numpy as np import matplotlib.pyplot as plt import time data_dir = "/media/data/Data/Orderphobic/TwoIntruders/LevelSampling" ard = arduino.Arduino( "/dev/serial/by-id/usb-Arduino__www.arduino.cc__0043_5573532393535190E022-if00" ) my_stepper = stepper.Stepper(ard) my_shaker = shaker.Shaker() my_shaker.change_duty(600) cam = camera.Camera(camera.guess_camera_number()) frame = cam.get_frame() crop_result = images.crop_polygon(frame) frame = images.crop_and_mask(frame, crop_result.bbox, crop_result.mask) bins = np.linspace(0, frame.shape[1], 100) np.savetxt(f"{data_dir}/bins.txt", bins) def run(): pos1 = -360 pos2 = -360 my_stepper.move_motor(1, 360 * 15, '-') time.sleep(90) my_stepper.move_motor(2, 360 * 15, '-')