Exemple #1
0
def take_image(filename):
    """take_image: The function will create a Operating System timestamp variable (OS_time), configure
                the 2 IRCSP cameras to take an image (image1 & image2) and store the FPA temperatures
                (temp1 & temp2) into an HDF5 File format with a unique naming convention.

    Parameters:
                filename - the filename of the HDF5 file.


    Returns: HDF5 file with 2 FLIR Boson Images, 2 FPA Temperatures & OS_time string.
    """

    # Time/Speed Test - Start
    start = datetime.datetime.now()

    #Create Timestamp for File Creation Tracking
    now = datetime.datetime.now()
    OS_time = now.strftime("%H:%M")

    camera1 = Boson(port='/dev/ttyACM0')
    camera2 = Boson(port='/dev/ttyACM1')

    #set FFC to manual
    camera1.set_ffc_manual()
    camera2.set_ffc_manual()

    #get FPA temperature
    temp1 = camera1.get_fpa_temperature()
    temp2 = camera2.get_fpa_temperature()

    #Take Image
    image1 = camera1.grab(device_id = 1)
    image2 = camera2.grab(device_id = 2)


    #Close Camera
    camera1.close()
    camera2.close()

    # Open as Read-Write ("a" - creates file if doesn't exist)
    with h5py.File(filename, "a") as h5:
        h5.attrs["OS_time"] = OS_time
        h5["image1"] = image1
        h5["image2"] = image2
        h5["temp1"] = temp1
        h5["temp2"] = temp2


    #Time/Speed Test - Finish
    finish = datetime.datetime.now()
    print("Image Capture File: ", filename," created in " , finish - start)

    #Adjust Sleep Value for File Creation Rate - (File/Seconds)
    time.sleep(10)
class ThreadedBoson(ThreadedCamera):
    def __init__(self,
                 device=None,
                 port=None,
                 baudrate=921600,
                 loglevel=logging.WARNING):
        super(ThreadedBoson, self).__init__()
        self.temperature = None
        self._connect(device, port, baudrate, loglevel)

    def _connect(self, device, port, baudrate, loglevel):
        try:
            self.camera = Boson(port, baudrate, loglevel)
            self.camera.setup_video(device)
            self.camera.grab()

            if not self.camera.cap.isOpened():
                warnings.warn("Failed to open camera")
                self.camera = None

        except IOError:
            warnings.warn("Failed to find camera")
            self.camera = None

    def height(self):
        return self.camera.cap.get(cv2.CAP_PROP_FRAME_HEIGHT)

    def width(self):
        return self.camera.cap.get(cv2.CAP_PROP_FRAME_WIDTH)

    def channels(self):
        return 1

    def dtype(self):
        return np.uint16

    def _grab(self):
        image = np.expand_dims(self.camera.grab(), -1)
        self.min_count = image.min()
        self.max_count = image.max()
        return image

    def close(self):
        self.camera.close()

    def get_target_fps(self):
        return self.camera.cap.get(cv2.CAP_PROP_FPS)
Exemple #3
0
And a single polarization state (unpol, H,V, ect)
Output will be saved as a hdf5 file 
Uses flirpy, make sure enviroment is open
uses python-usbtmc

@author: khart
"""
from flirpy.camera.boson import Boson
import matplotlib.pyplot as plt
import numpy as np
import h5py
import time

#choose the ROI
ymin = 100
ymax = 250
xmin = 100
xmax = 200

camera1 = Boson()
print(camera1.find_serial_device())
image1 = camera1.grab()
t1 = camera1.get_fpa_temperature()
camera1.close()

print('cam temp is ' + str(t1) + ' C')

plt.matshow(image1[xmin:xmax, ymin:ymax])
plt.colorbar()
plt.show()
Exemple #4
0
path = input('What is the filepath? \n')
if os.path.exists(path):
    print('\n saving data to ', path)
else:
    print('path not found, closing camera')
    cam.close()

name = input('What is the file name? \n') + '.h5.'
user_notes = input('User Notes: \n')

#preallocate file size
images = np.zeros((num, 256, 320))
temps = np.zeros((num))

for i in range(num):
    images[i, :, :] = cam.grab(device_id=1)
    temps[i] = cam.get_fpa_temperature()
    print('on image ', str(i + 1), ' of ', str(num))
    time.sleep(wait)
cam.close()

plt.imshow(images[0])
plt.show()

#save
#create hdf5 file
hf = h5py.File(path + name, 'w')
hf.create_dataset('imgs', data=images)
hf.create_dataset('temps', data=temps)
hf.attrs['user_notes'] = user_notes
hf.attrs['ffc'] = ffc
Exemple #5
0
ymax = 250;
xmin = 0;
xmax = 320;


#choose wavelengths
samps    = 5;
temp1 = np.zeros(samps);temp2 = np.zeros(samps)
avgs1 = np.zeros(samps);avgs2 = np.zeros(samps)
images1   = [];images2   = []

i =0;
while i <samps:
    camera1     = Boson(port = "COM5")
    print(camera1.find_serial_device())
    image1       = camera1.grab();
    t1           = camera1.get_fpa_temperature()
    camera1.close()
    
    camera2 = Boson(port = "COM6")
    image2       = camera2.grab();
    print(camera2.find_serial_device())
    t2           = camera2.get_fpa_temperature()
    camera2.close()
   
    print('sample #'+str(i)+' temp1 is '+str(t1)+' C,  '+'temp2 is '+str(t2)+' C')
    images1.append(image1)
    temp1[i]        = t1
    avgs1[i]        = np.mean(image1)
    images2.append(image2)
   
Exemple #6
0
from flirpy.camera.boson import Boson

c = Boson(port="COM14")
c.grab()
c2 = Boson(port="COM17")
c2.grab()
c.close()
shutter(instr,1)

#initialize camera
camera = Boson()

#choose wavelengths
samps    = 80;
waves    = np.linspace(6,14,samps);
response = np.zeros(samps);
err      = np.zeros(samps);
images   = [];

i =0;
while i <samps:
    changeWavelength(instr,waves[i]);
    image       = camera.grab();
    images.append(image)
    response[i] = np.mean(image[ymin:ymax,xmin:xmax]);
    err[i]      = np.std(image[ymin:ymax,xmin:xmax]);
    i = i+1;
    
#close camera
camera.close()

plt.plot(waves,response,'.')
plt.xlabel('Wavelength [um]')
plt.ylabel('response')
plt.show()

#create hdf5 file
hf = h5py.File(save_path + name + '.h5', 'w')
import matplotlib.pyplot as plt
from flirpy.camera.boson import Boson

camera1 = Boson(port='COM5')
camera2 = Boson(port='COM6')

print(camera1.find_video_device())
print(camera2.find_video_device())

# set FFC to manual
camera1.set_ffc_manual()
camera2.set_ffc_manual()

# get FPA temperature
temp1 = camera1.get_fpa_temperature()
temp2 = camera2.get_fpa_temperature()

# take image
im1 = camera1.grab(device_id=1)
im2 = camera2.grab(device_id=2)
camera1.close()
camera2.close()

plt.imshow(im1)
plt.title('camera 1 ' + str(temp1))
plt.show()

plt.imshow(im2)
plt.title('camera 2 ' + str(temp2))
plt.show()