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.cam = camera.Camera(0)
     self.shaker = shaker.Shaker()
     self.shaker.change_duty(600)
     self.crop, self.mask = self.get_crop()
     frame = self.get_frame()
     self.window = DisplayWindow(frame)
     self.x = []
     self.y = []
     self.contours = []
     self.run()
    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)
Example #4
0
# EXP_CAM = "/dev/snd/by-id/usb-046d_HD_Pro_Webcam_C920_167C9A7F-02"

R = 60
D = 600
date = '090221'
n = 3
data_save = f"/media/data/Data/Orderphobic/TwoIntruders/OneIntruder/Logging/{date}_{D}_{n}.txt"
im_save = os.path.splitext(data_save)[0]
if not os.path.exists(im_save):
    os.mkdir(im_save)



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

frame = cam.get_frame()
if R != 0:
    frame = ndimage.rotate(frame, R, reshape=False)
crop_result = images.crop_polygon(frame)
crop = crop_result.bbox

s = shaker.Shaker()
# s.ramp(650, D, 1)
s.change_duty(D)

def get_frame():
    frame = cam.get_frame()
    if R != 0:
        frame = ndimage.rotate(frame, R, reshape=False)
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]
 def initialise_devices(self):
     self.cam = camera.Camera(0)
     self.s = shaker.Shaker()
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)