-
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
19 changed files
with
306 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
Metadata-Version: 1.0 | ||
Metadata-Version: 2.1 | ||
Name: andor | ||
Version: 0.0.0 | ||
Summary: UNKNOWN | ||
Home-page: UNKNOWN | ||
Author: UNKNOWN | ||
Author-email: UNKNOWN | ||
License: UNKNOWN | ||
Description: UNKNOWN | ||
Platform: UNKNOWN | ||
|
||
UNKNOWN | ||
|
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,234 @@ | ||
|
||
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 | ||
import os | ||
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" | ||
|
||
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 = 964 #964 #OFFSET #964 pixels default | ||
IMAGE_WIDTH = 1288 #1288 #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 | ||
|
||
CHOSEN_TRIGGER = 2 | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class UnexpectedResponse(Exception): | ||
pass | ||
|
||
# Set camera serial numbers | ||
serial_1 = '20343286' | ||
|
||
# Get system | ||
system = PySpin.System.GetInstance() | ||
|
||
# Get camera list | ||
cam_list = system.GetCameras() | ||
|
||
# Get cameras by serial | ||
cam_1 = cam_list.GetBySerial(serial_1) | ||
|
||
###################### init ################################# | ||
|
||
# Initialize cameras | ||
cam_1.Init() | ||
|
||
# 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_1.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous) | ||
cam_1.ExposureAuto.SetValue(PySpin.ExposureAuto_Off) | ||
cam_1.ExposureMode.SetValue(PySpin.ExposureMode_Timed) #Timed or TriggerWidth (must comment out trigger parameters other that Line) | ||
cam_1.ExposureTime.SetValue(1000) | ||
cam_1.GainAuto.SetValue(PySpin.GainAuto_Off) | ||
cam_1.Gain.SetValue(GAIN_VALUE) | ||
|
||
#cam_1.Gamma.SetValue(GAMMA_VALUE) #always fails? | ||
#cam_1.AdcBitDepth.SetValue(PySpin.AdcBitDepth_Bit16) #always fails? | ||
|
||
cam_1.PixelFormat.SetValue(PySpin.PixelFormat_Mono16) | ||
cam_1.Width.SetValue(IMAGE_WIDTH) | ||
cam_1.Height.SetValue(IMAGE_HEIGHT) | ||
# cam_1.OffsetX.SetValue(WIDTH_OFFSET) | ||
# cam_1.OffsetY.SetValue(HEIGHT_OFFSET) | ||
|
||
#This takes an image quickly. The first image is always corrupt for whatever reason. This picture is not saved. | ||
cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) | ||
cam_1.BeginAcquisition() | ||
cam_1.EndAcquisition() | ||
|
||
cam_1.TriggerSource.SetValue(PySpin.TriggerSource_Line0) | ||
cam_1.TriggerSelector.SetValue(PySpin.TriggerSelector_FrameStart) | ||
cam_1.TriggerActivation.SetValue(PySpin.TriggerActivation_RisingEdge) | ||
|
||
cam_1=cam_1 | ||
|
||
print("FLIR driver initialization successful...") | ||
|
||
#################### await_trigger ################################### | ||
|
||
cam_1.ExposureTime.SetValue(int(4000)) # microseconds | ||
cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off) | ||
cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On) | ||
cam_1.BeginAcquisition() | ||
|
||
#################### convert_images ################################### | ||
images=[] | ||
|
||
image = cam_1.GetNextImage() | ||
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() | ||
|
||
cam_1.EndAcquisition() | ||
|
||
#################### save_image ################################### | ||
|
||
image = Image.fromarray(images[0]) | ||
|
||
# Save images | ||
msec = str(time.time())[11:14] | ||
filename = 'H%s_M%d_S%g_MS' % (int(time.strftime("%H", time.localtime())), int(time.strftime("%M", time.localtime())),int(time.strftime("%S", time.localtime()))) | ||
filename = filename+msec | ||
##########################Save locally############################################ | ||
pre1 = time.time() | ||
if os.path.isfile(r"S:\flir_images\Image_"+filename+".png") == True: | ||
image.save(r"S:\flir_images\Image_"+filename+"(2).png") | ||
post1=time.time()-pre1 | ||
print("Saved image "+filename+"(2).png locally in",post1*1000, "millisecond") | ||
else: | ||
image.save(r"S:\flir_images\Image_"+filename+".png") | ||
post1=time.time()-pre1 | ||
print("Saved image "+filename+".png locally in",post1*1000, "millisecond") | ||
##########################Save locally############################################ | ||
|
||
#########################Save to datadepot############################################ | ||
# pre2 = time.time() | ||
# if os.path.isfile(r"N:\data\flir_images\Image_"+filename+".png") == True: | ||
# image.save(r"N:\data\flir_images\Image_"+filename+"(2).png") | ||
# post2=time.time()-pre2 | ||
# print("Saved image "+filename+"(2).png to datadepot in",post2*1000, "millisecond") | ||
# else: | ||
# image.save(r"N:\data\flir_images\Image_"+filename+".png") | ||
# post2=time.time()-pre2 | ||
# print("Saved image "+filename+".png to datadepot in",post2*1000, "millisecond") | ||
#########################Save to datadepot############################################ | ||
|
||
# print((post2-post1)*1000, "millisecond lag between datadepot and local saves") | ||
|
||
|
||
# def reset(): | ||
# cam_1.DeInit() | ||
# cam_1.EndAcquisition() | ||
# del cam | ||
# cam_list.Clear() | ||
# PySpin.System.CloseInstance() | ||
|
||
|
||
|
||
##################################################################### | ||
# async def _ser_readline(): | ||
# c = await port.read(1) | ||
# print(c) | ||
# r = c | ||
# while c != b"\n": | ||
# c = await port.read(1) | ||
# r += c | ||
# return r | ||
|
||
# async def _ser_send( cmd, get_response=True): | ||
# """Send a string to the serial port.""" | ||
|
||
# Low-level routine for sending serial commands to device. It sends | ||
# strings and listens for a response terminated by a carriage return. | ||
# example: | ||
# ser_send("F0 1.0") # sets the freq of channel 0 to 1.0 MHz | ||
|
||
# if simulation: | ||
# logger.info("simulation _ser_send(\"%s\")", cmd) | ||
# else: | ||
# logger.debug("_ser_send(\"%s\")", cmd) | ||
# port.ser.reset_input_buffer() | ||
# await port.write((cmd + "\r\n").encode()) | ||
# if get_response: | ||
# result = (await _ser_readline()).rstrip().decode() | ||
# logger.debug("got response from device: %s", result) | ||
# if result != "OK": | ||
# errstr = error_codes.get(result, "Unrecognized reply") | ||
# s = "Erroneous reply from device: {ec}, {ecs}".format( | ||
# ec=result, ecs=errstr) | ||
# raise ValueError(s) | ||
# else: | ||
# pass | ||
|
||
# async def setup(): | ||
# """Initial setup of FLIR.""" | ||
# await _ser_send("E d", get_response=False) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# 1. Get image | ||
# 2. Convert to array immediately | ||
# 3. Bin it (roi) (trash most of array) | ||
# 4. (For abs imaging: background ) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
Metadata-Version: 1.0 | ||
Metadata-Version: 2.1 | ||
Name: flir | ||
Version: 0.0.0 | ||
Summary: UNKNOWN | ||
Home-page: UNKNOWN | ||
Author: UNKNOWN | ||
Author-email: UNKNOWN | ||
License: UNKNOWN | ||
Description: UNKNOWN | ||
Platform: UNKNOWN | ||
|
||
UNKNOWN | ||
|
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
[console_scripts] | ||
aqctl_flir = flir.aqctl_flir:main | ||
|
Binary file not shown.
Binary file not shown.
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
Oops, something went wrong.