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)
Exemplo n.º 2
0
    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)
import time
import matplotlib.pyplot as plt
from labvision import camera, images
import numpy as np
from scipy import ndimage
from labequipment import shaker

data_save = "/media/data/Data/Orderphobic/TwoIntruders/Logging/301120_liquid_ramps_x.txt"

cam_num = camera.guess_camera_number()
cam = camera.Camera(cam_num)

frame = cam.get_frame()
frame = ndimage.rotate(frame, -120, reshape=False)
crop_result = images.crop_polygon(frame)
crop = crop_result.bbox

s = shaker.Shaker()
s.ramp(670, 630, 1)


def get_frame():
    frame = cam.get_frame()
    frame = ndimage.rotate(frame, -120, reshape=False)
    frame = images.crop(frame, crop)
    return frame


def get_circles(frame):
    frame_blurred = images.gaussian_blur(frame, (15, 15))
    red = frame_blurred[:, :, 2] - frame_blurred[:, :, 0]
Exemplo n.º 4
0
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, '-')
    time.sleep(90)