-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
197 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import math | ||
import logging | ||
import asyncio | ||
import asyncserial | ||
import os | ||
import matplotlib.pyplot as plt | ||
import keyboard | ||
import time | ||
import PySpin | ||
import sys | ||
import time | ||
import numpy as np | ||
from PIL import Image | ||
|
||
GAIN_VALUE = 23.8 #in dB, 0-40; | ||
#GAMMA_VALUE = 0.5 #0.25-1 | ||
|
||
# MOT_OFFSET_HEIGHT = 0 #These corrections are for a MOT that is not at the center of the frame | ||
# MOT_OFFSET_WIDTH = 0 | ||
#OFFSET = 964 #52 #652 #This will be the pixel width and height of the roi | ||
IMAGE_HEIGHT = 960 #964 is max #OFFSET #964 pixels default | ||
IMAGE_WIDTH = 1280 #1288 is max #OFFSET #1288 pixels default | ||
# HEIGHT_OFFSET = round((964+1-IMAGE_HEIGHT-MOT_OFFSET_HEIGHT)/2)#(964-IMAGE_HEIGHT)/2) # Y, to keep in middle of sensor | ||
# WIDTH_OFFSET = round((1288+1-IMAGE_WIDTH-MOT_OFFSET_WIDTH)/2)#(1288-IMAGE_WIDTH)/2) # X, to keep in middle of sensor | ||
|
||
global continue_recording | ||
continue_recording = True | ||
|
||
global trigtype | ||
SOFTWARE = 1 | ||
HARDWARE = 2 | ||
trigtype=HARDWARE | ||
class TriggerType(): | ||
def __init__(self, softtrig): | ||
global trigtype | ||
if softtrig is True: | ||
trigtype=SOFTWARE | ||
else: | ||
trigtype=HARDWARE | ||
|
||
CHOSEN_TRIGGER = trigtype | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# try: | ||
|
||
# Set camera serial numbers | ||
serial_1 = '20343286' # Back objective camera | ||
# serial_1 = '20409335' # Diagonal fluorescence (on stage carriage) | ||
|
||
# Get system | ||
system = PySpin.System.GetInstance() | ||
|
||
# Get camera list | ||
cam_list = system.GetCameras() | ||
|
||
|
||
# Get cameras by serial | ||
cam = cam_list.GetBySerial(serial_1) | ||
|
||
# Initialize cameras | ||
cam.Init() | ||
|
||
#cam.FactoryReset() | ||
|
||
# Set acquisition mode to acquire a single frame, this ensures acquired images are sync'd since camera 2 and 3 are setup to be triggered | ||
cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) | ||
cam.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) | ||
cam.ExposureMode.SetValue(PySpin.ExposureMode_Timed) #Timed or TriggerWidth (must comment out trigger parameters other that Line) | ||
cam.ExposureTime.SetValue(50) #us | ||
cam.GainAuto.SetValue(PySpin.GainAuto_Off) | ||
cam.Gain.SetValue(23.8)# Previously 23.8 | ||
|
||
#cam.Gamma.SetValue(GAMMA_VALUE) #always fails? | ||
#cam.AdcBitDepth.SetValue(PySpin.AdcBitDepth_Bit16) #always fails? | ||
|
||
cam.PixelFormat.SetValue(PySpin.PixelFormat_Mono16) | ||
cam.Width.SetValue(1280) | ||
cam.Height.SetValue(960) | ||
# cam.OffsetX.SetValue(WIDTH_OFFSET) | ||
# cam.OffsetY.SetValue(HEIGHT_OFFSET) | ||
|
||
#This takes an image quickly. The first image is always corrupt for whatever reason. This picture is not saved. | ||
#cam.BeginAcquisition() | ||
#cam.EndAcquisition() | ||
|
||
cam.V3_3Enable.SetValue(True) | ||
cam.TriggerMode.SetValue(PySpin.TriggerMode_Off) | ||
cam.TriggerSource.SetValue(PySpin.TriggerSource_Line0) | ||
cam.TriggerMode.SetValue(PySpin.TriggerMode_On) | ||
|
||
cam.TriggerSelector.SetValue(1) #0,1 PySpin.TriggerSelector_FrameStart | ||
cam.TriggerActivation.SetValue(PySpin.TriggerActivation_RisingEdge) | ||
|
||
|
||
cam_1=cam | ||
|
||
print("FLIR driver initialization successful...") | ||
# except: | ||
# print("Error in __init__(), try restarting artiq") | ||
|
||
# Await Trigger | ||
|
||
cam_1.ExposureTime.SetValue(int(50)) | ||
cam_1.BeginAcquisition() | ||
|
||
print("Awaiting trigger...") | ||
|
||
# cam_1.EndAcquisition() | ||
|
||
#%% Get Image | ||
|
||
num_of_im = 5 | ||
images=[] | ||
try: | ||
for i in range(num_of_im): | ||
print("Before GetNextImage") | ||
image = cam_1.GetNextImage(1000) #timeout (ms) 20000 | ||
print("Picture Successfully taken at: ",time.strftime("%d %b %Y %H:%M:%S", time.localtime())) | ||
images.append(np.array(image.GetData(),dtype="uint16").reshape((image.GetHeight(),image.GetWidth()))) #convert PySpin ImagePtr into numpy array | ||
image.Release() | ||
|
||
except: | ||
cam_1.EndAcquisition() | ||
print("failed...ending acquisition") | ||
|
||
#%% Plot image | ||
for i in range(num_of_im): | ||
img = images[i] | ||
print( np.amax(img) , np.amin(img) ) | ||
plt.imshow(img) | ||
plt.colorbar() | ||
plt.show() | ||
|
||
|
Binary file modified
BIN
+0 Bytes
(100%)
picomotor_repo/picomotor/__pycache__/aqctl_picomotor.cpython-38.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters