Exemplo n.º 1
0
dev = u3.U3()  # Open LJU3
dev.getCalibrationData()
dt = 100
dev.configIO(EnableCounter1=True, TimerCounterPinOffset=6)

fps = 15.3
top = 10
bottom = 0
steps = 2

n_planes = int(
    (top - bottom) / steps) + 1  # total number of planes for each volume
volumes_per_s = fps / n_planes  # total number of volume acquisition per volume
pulse_count = 0
with Opto(port='COM6') as etl:
    while True:
        etl.current(bottom)
        pulse_count = int(np.array(dev.getFeedback(u3.Counter(counter=1))))
        #print('Reset',pulse_count)
        if pulse_count > 0:  # for initial trigger (first TTL pulse/first plane of the volume)
            print('ETL', etl.current())
            print('ini', pulse_count)
            #pulse_count -= 1 # reset it to zero so you can image the first plane, if it is one it will immediately increment the focal_plane
            old_pulse_count = 0  # to store the previous focal plane
            while pulse_count <= n_planes:
                if pulse_count > old_pulse_count:  # for initial trigger (first TTL pulse/first plane of the volume)
                    focal_plane = float(bottom + ((pulse_count - 1) * steps))
                    #time.sleep(0.064)
                    print('Focal plane', focal_plane)
                    etl.current(focal_plane)
Exemplo n.º 2
0
from picamera import PiCamera
from opto import Opto
import time
import cv2
import numpy as np

fileDir = "./imgs/"

# Initialize Camera
camera = PiCamera(sensor_mode=7)
camera.color_effects = (128, 128)
camera.resolution = (640, 480)
camera.framerate = 30

# Initialize Tunable Lens
o = Opto(port='/dev/ttyACM0')
o.connect()
o.current(0)

# Allow Camera to warmup
time.sleep(0.5)

# Loop Across all settings
for i in range(-290, 291, 1):
    o.current(i)
    time.sleep(0.5)  # Allow for settling time of the tunable lens
    fileName = fileDir + str(i) + ".png"
    fileNameAvr = fileDir + str(i) + "_avr.png"
    image_avr = np.zeros((480, 640, 3))
    for j in range(0, 30):
        rawCapture = PiRGBArray(camera, size=(640, 480))
Exemplo n.º 3
0
# Script used to tune lens using the CMD

from opto import Opto
import time

o = Opto(port='/dev/ttyACM0')
o.connect()
print('Successfully Connected')

current_low = -285
current_high = 285
current_delta = current_high - current_low
print('Upper: ', current_high)
print('Lower: ', current_low)
print('Input \'q\' to exit')

while True:
    key = input("Current:")
    try:
        key = float(key)
        if key > current_low and key < current_high:
            o.current(key)
        elif key < current_low:
            o.current(current_low)
        elif key > current_high:
            o.current(current_high)
    except ValueError:
        if key == "q" or key == "Q" or key == "Quit" or key == "quit" or key == "QUIT":
            o.current(0)
            break
        elif key == "scan":
Exemplo n.º 4
0
# "a/d" => +/- 10 mA
# "-/=" => +/- 1 mA
# "0"   => 0 mA
# "s"   => Scan [-290:10:290]
# "q"   => Quit

# import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2

# New Lines
from opto import Opto

o = Opto(port='/dev/ttyACM0')
o.connect()
scan = False
current = 0
o.current(current)

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera(sensor_mode=7)
camera.resolution = (640, 480)
camera.framerate = 30
camera.color_effects = (128, 128)
rawCapture = PiRGBArray(camera, size=(640, 480))

# cv2 text overlay
font = cv2.FONT_HERSHEY_SIMPLEX
location1 = (10, 20)
Exemplo n.º 5
0
top = 10
bottom = 0
steps = 2

n_planes = 2 * (int(
    (top - bottom) / steps) + 1)  # total number of planes for each volume
volumes_per_s = fps / n_planes  # total number of volume acquisition per volume
pulse_count = 0
delay = 0.075
listdata = []
listtime = []
freq = 15.0
bottom = 0
top = 5
step = 5
with Opto(port='COM6') as o:
    o.current(0)
    old = 0
    while True:
        pulse_count = int(np.array(dev.getFeedback(u3.Counter(counter=1))))
        if pulse_count > old:
            print('pulse count')
            current_low = 0
            current_high = step
            current_delta = current_high - current_low
            t0 = time.time()
            for i in np.linspace(0, 2 * np.pi, 1000):
                listtime.append(time.time() - t0)
                listdata.append(
                    (np.sin(i * 0.25) * current_delta + current_low))
                o.current(bottom + np.sin(i * 0.25) * current_delta +
Exemplo n.º 6
0
# Script2 to test the functionality of the Opto library from https://github.com/OrganicIrratiation/opto

from opto import Opto
import time
import numpy as np

o = Opto(port='/dev/ttyACM0')
o.connect()
print('Successfully Connected')
current_low = o.current_lower()
current_high = o.current_upper()
current_delta = current_high - current_low
print('Upper: ', current_high)
print('Lower: ', current_low)
o.close(soft_close=True)
Exemplo n.º 7
0
                help="Optotune Lens setting")
ap.add_argument("-d",
                "--display",
                type=int,
                default=-1,
                help="Whether or not frames should be displayed")
args = vars(ap.parse_args())

# Initialize Camera
camera = PiCamera(sensor_mode=7)
camera.color_effects = (128, 128)
camera.resolution = (640, 480)
camera.framerate = 30

# Initialize Tunable Lens
o = Opto(port='/dev/ttyACM0')
o.connect()
o.current(args['lens'])

# Allow Camera to warmup
time.sleep(0.5)

# Set up RGB and YUV Capture
rgbCapture = PiRGBArray(camera, size=(640, 480))
yuvCapture = PiYUVArray(camera, size=(640, 480))

t1 = time.time()
camera.capture(rgbCapture, format="bgr")
t2 = time.time()
camera.capture(yuvCapture, format="yuv")
t3 = time.time()
Exemplo n.º 8
0
# Script to test the functionality of the Opto library from https://github.com/OrganicIrratiation/opto

from opto import Opto
import numpy as np
import time

with Opto(port='/dev/ttyACM0') as o:
    current_low = o.current_lower()
    current_high = o.current_upper()
    current_delta = current_high - current_low
    for i in np.linspace(0, 2 * np.pi, 1000):
        o.current(np.sin(i) * current_delta + current_low)
        time.sleep(0.01)