Skip to content

Commit

Permalink
before testing flir
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodjd committed Feb 12, 2021
1 parent c1adf85 commit 0d51db1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion flir_repo/flir/aqctl_flir.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def main():
truthcounter=1
finally:
print("Closing server...")
# dev.reset()
dev.close()

if __name__ == "__main__":
main()
73 changes: 38 additions & 35 deletions flir_repo/flir/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,46 @@ def __init__(self):
# Get camera list
self.cam_list = self.system.GetCameras()


# Get cameras by serial
cam_1 = self.cam_list.GetBySerial(serial_1)
cam = self.cam_list.GetBySerial(serial_1)

Initial_EXPOSURE_TIME=1000 #in microseconds
# Initialize cameras
cam_1.Init()
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_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(Initial_EXPOSURE_TIME)
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)
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(100) #us
cam.GainAuto.SetValue(PySpin.GainAuto_Off)
cam.Gain.SetValue(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(1288)
cam.Height.SetValue(964)
# 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_1.TriggerMode.SetValue(PySpin.TriggerMode_Off)
cam_1.BeginAcquisition()
cam_1.EndAcquisition()
#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_1.TriggerSource.SetValue(PySpin.TriggerSource_Line0)
cam_1.TriggerSelector.SetValue(PySpin.TriggerSelector_FrameStart)
cam_1.TriggerActivation.SetValue(PySpin.TriggerActivation_RisingEdge)
cam.TriggerSelector.SetValue(1) #0,1 PySpin.TriggerSelector_FrameStart
cam.TriggerActivation.SetValue(PySpin.TriggerActivation_RisingEdge)

self.cam_1=cam_1

self.cam_1=cam

print("FLIR driver initialization successful...")
# except:
Expand All @@ -104,8 +110,6 @@ def __init__(self):
def await_trigger(self, EXPOSURE_TIME):
try:
self.cam_1.ExposureTime.SetValue(int(EXPOSURE_TIME))
self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_Off)
self.cam_1.TriggerMode.SetValue(PySpin.TriggerMode_On)
self.cam_1.BeginAcquisition()

# This is a trigger test
Expand All @@ -129,7 +133,7 @@ def await_trigger(self, EXPOSURE_TIME):



def convert_image(self,num_of_im):
def get_image(self,num_of_im):
# try:
# Acquire images. Output is python list of images as numpy arrays
images=[]
Expand All @@ -139,7 +143,6 @@ def convert_image(self,num_of_im):
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()
time.sleep(0.01)

self.cam_1.EndAcquisition()
return images
Expand All @@ -148,7 +151,7 @@ def convert_image(self,num_of_im):
# self.cam_1.EndAcquisition()
# except:
# pass
# print("Error in convert_image(), try restarting artiq")
# print("Error in get_image(), try restarting artiq")


def save_image(self, imagearray):#,image_1, image_2):
Expand Down Expand Up @@ -194,11 +197,11 @@ def save_image(self, imagearray):#,image_1, image_2):
pass
print("Error in save_image(), try restarting artiq")

def reset(self):
cam_1.EndAcquisition()
cam_1.DeInit()
del cam_1
cam_list.Clear()
def close(self):
self.cam_1.EndAcquisition()
self.cam_1.DeInit()
del self.cam_1
self.cam_list.Clear()


#####################################################################
Expand Down

0 comments on commit 0d51db1

Please sign in to comment.