Beispiel #1
0
 def __init__(self):
     pvc.init_pvcam()
     name = pvc.get_cam_name(0)
     VCamera.__init__(self, name)
     Camera.__init__(self)
     self.open()
     self.exp_time = 1
Beispiel #2
0
def main():
    # Initialize PVCAM and find the first available camera.
    pvc.init_pvcam()

    cam = [cam for cam in Camera.detect_camera()][0]
    cam.open()
    cam.speed_table_index = 0
    cam.exp_mode = 'Software Trigger Edge'

    # Start a thread for executing the trigger
    t1 = TriggerThreadRun(cam)
    t1.start()

    # Collect frames in live mode
    cam.start_live()
    framesReceived = collectFrames(cam)
    cam.finish()
    print('Received live frames: ' + str(framesReceived) + '\n')

    # Collect frames in sequence mode
    cam.start_seq(num_frames=NUM_FRAMES)
    framesReceived = collectFrames(cam)
    cam.finish()
    print('Received seq frames: ' + str(framesReceived) + '\n')

    t1.stop()
    cam.close()
    pvc.uninit_pvcam()

    print('Done')
Beispiel #3
0
def main():
    # Initialize PVCAM and find the first available camera.
    pvc.init_pvcam()

    cam = [cam for cam in Camera.detect_camera()][0]
    cam.open()

    cam.start_seq(exp_time=EXPOSE_TIME_ms, num_frames=NUM_FRAMES)

    # Wait for 3 frames to be captured. Frames take a slightly longer than expose time, so wait a little extra time
    time.sleep(3 * EXPOSE_TIME_ms * 1e-3 + 0.1)

    cnt = 0
    while cnt < NUM_FRAMES:
        frame, fps, frame_count = cam.poll_frame(oldestFrame=False)
        printFrameDetails(frame, fps, frame_count, 'newest')

        frame, fps, frame_count = cam.poll_frame()
        printFrameDetails(frame, fps, frame_count, 'oldest')

        cnt += 1

    cam.finish()
    cam.close()
    pvc.uninit_pvcam()

    print('\nTotal frames: {}'.format(cnt))
Beispiel #4
0
    def __init__(self, cam_num=0, readout_port=0):
        """Constructor method.

        readout_port is camera mode:
            - readout_port = 0 ("Sensitivity") 12 bits, max fps = 88
            - readout_port = 1 ("Speed") 8 bits, max fps = 500
            - readout_port = 2 ("Dynamic Range") 16 bits, max fps = 83
        """
        global pvc_initialized

        if not pvc_initialized:
            print("pvc.init_pvcam")
            pvc.init_pvcam()
            pvc_initialized = True

        for num, cam in enumerate(PVCamera.detect_camera()):
            if num == cam_num:
                break
        else:
            raise (f"Unable to find camera num {cam_num:}.")
        self.cam = cam
        self.cam.open()
        self.cam.readout_port = readout_port

        self.cam.meta_data_enabled = True
        print(self.cam.name)
Beispiel #5
0
def main():
    pvc.init_pvcam()
    cam = next(Camera.detect_camera())
    cam.open()
    cam.meta_data_enabled = True
    cam.roi = (0, 1000, 0, 1000)

    num_frames = 1
    cnt = 0

    cam.start_seq(exp_time=20, num_frames=num_frames)
    while cnt < num_frames:
        frame, fps, frame_count = cam.poll_frame()

        low = np.amin(frame['pixel_data'])
        high = np.amax(frame['pixel_data'])
        average = np.average(frame['pixel_data'])

        print(
            'Min:{}\tMax:{}\tAverage:{:.0f}\tFrame Rate: {:.1f}\tFrame Count: {:.0f}\n'
            .format(low, high, average, fps, frame_count))
        cnt += 1

        time.sleep(0.05)

    cam.finish()
    cam.close()
    pvc.uninit_pvcam()

    print('Total frames: {}\n'.format(cnt))
Beispiel #6
0
    def init_camera(self):
        print("initializing camera")

        pvc.init_pvcam()
        self.cam = [cam for cam in Camera.detect_camera()][0]
        self.cam.open()
        self.cam.gain = self.cam_gain
        self.cam.binning = self.cam_binning
        self.cam.exp_mode = "Timed"
        self.cam.exp_out_mode = 0
def main():
    pvc.init_pvcam()
    cam = next(Camera.detect_camera())
    cam.open()

    frame = cam.get_frame(exp_time=20).reshape(cam.sensor_size[::-1])
    plt.imshow(frame, cmap="gray")
    plt.show()
    cam.close()
    pvc.uninit_pvcam()
Beispiel #8
0
def main():
    # Initialize PVCAM and find the first available camera.
    pvc.init_pvcam()
    cam = [cam for cam in Camera.detect_camera()][0]
    cam.open()
    cam.speed_table_index = 0
    for i in range(5):
        frame = cam.get_frame(exp_time=20)
        print("First five pixels of frame: {}, {}, {}, {}, {}".format(
            *frame[:5]))
    cam.close()
    pvc.uninit_pvcam()
Beispiel #9
0
def main():
    pvc.init_pvcam()
    cam = next(Camera.detect_camera())
    cam.open()

    NUM_FRAMES = 10
    cnt = 0

    cam.start_seq(exp_time=20, num_frames=NUM_FRAMES)
    while cnt < NUM_FRAMES:
        frame, fps, frame_count = cam.poll_frame()

        low = np.amin(frame['pixel_data'])
        high = np.amax(frame['pixel_data'])
        average = np.average(frame['pixel_data'])

        print(
            'Min:{}\tMax:{}\tAverage:{:.0f}\tFrame Rate: {:.1f}\tFrame Count: {:.0f}\n'
            .format(low, high, average, fps, frame_count))
        cnt += 1

        time.sleep(0.05)

    cam.finish()

    # Test basic sequence methods
    frames = cam.get_sequence(NUM_FRAMES)
    for frame in frames:
        low = np.amin(frame)
        high = np.amax(frame)
        average = np.average(frame)

        print('Min:{}\tMax:{}\tAverage:{:.0f}\tFrame Count: {:.0f}\n'.format(
            low, high, average, cnt))
        cnt += 1

    time_list = [i * 10 for i in range(1, NUM_FRAMES + 1)]
    frames = cam.get_vtm_sequence(time_list, constants.EXP_RES_ONE_MILLISEC,
                                  NUM_FRAMES)
    for frame in frames:
        low = np.amin(frame)
        high = np.amax(frame)
        average = np.average(frame)

        print('Min:{}\tMax:{}\tAverage:{:.0f}\tFrame Count: {:.0f}\n'.format(
            low, high, average, cnt))
        cnt += 1

    cam.close()
    pvc.uninit_pvcam()

    print('Total frames: {}\n'.format(cnt))
Beispiel #10
0
 def on_activate(self):
     """ Initialisation performed during activation of the module.
     """
     self.const = const
     pvc.init_pvcam()
     # Generator function to detect a connected camera
     self.cam = next(Camera.detect_camera())
     self.cam.open()
     self.cam.exp_mode = "Ext Trig Internal"
     self.cam.exp_res = 0
     self.exp_time = self.cam.exp_time = 1
     nx_px, ny_px = self._get_detector()
     self._width, self._height = nx_px, ny_px
     self._live = False
Beispiel #11
0
def main():
    pvc.init_pvcam()
    cam = next(Camera.detect_camera())
    cam.open()

    cam.meta_data_enabled = True

    cam.set_roi(0, 0, 250, 250)
    cam.set_roi(300, 100, 400, 900)
    cam.set_roi(750, 300, 200, 200)

    NUM_FRAMES = 1

    cnt = 0

    cam.start_seq(exp_time=20, num_frames=NUM_FRAMES)
    while cnt < NUM_FRAMES:
        frame, fps, frame_count = cam.poll_frame()

        num_rois = len(frame['pixel_data'])
        for roi_index in range(num_rois):
            low = np.amin(frame['pixel_data'][roi_index])
            high = np.amax(frame['pixel_data'][roi_index])
            average = np.average(frame['pixel_data'][roi_index])

            s1 = frame['meta_data']['roi_headers'][roi_index]['roi']['s1']
            s2 = frame['meta_data']['roi_headers'][roi_index]['roi']['s2']
            p1 = frame['meta_data']['roi_headers'][roi_index]['roi']['p1']
            p2 = frame['meta_data']['roi_headers'][roi_index]['roi']['p2']
            print('ROI:{:2} ({:4}, {:4}) ({:4}, {:4})\tMin:{}\tMax:{}\tAverage:{:.0f}\tFrame Rate: {:.1f}\tFrame Count: {:.0f}'.format(roi_index, s1, p1, s2, p2, low, high, average, fps, frame_count))

            alpha = 2.0  # Contrast control (1.0-3.0)
            beta = 10  # Brightness control (0-100)
            img = cv2.convertScaleAbs(frame['pixel_data'][roi_index], alpha=alpha, beta=beta)

            window_name = 'Region: {}'.format(roi_index)
            cv2.imshow(window_name, img)
            cv2.moveWindow(window_name, s1, p1)

        cnt += 1

        cv2.waitKey(0)

    cam.finish()
    cam.close()
    pvc.uninit_pvcam()

    print('Total frames: {}\n'.format(cnt))
Beispiel #12
0
def main():
    # Initialize PVCAM and find the first available camera.
    pvc.init_pvcam()

    cam = [cam for cam in Camera.detect_camera()][0]
    cam.open()
    cam.gain = 1
    cam.exp_mode = "Timed"
    cam.binning = 2  #Binning to set camera to collect at
    #cam.update_mode()
    cam.exp_out_mode = 0
    #cam.speed_table_index = 0
    #With the CoolLED pE-300 Ultra in sequence mode, this will cycle through the 3 lamps.
    t0 = time.time()
    frame1 = cam.get_frame(exp_time=50)  #Exposure channel 1
    frame2 = cam.get_frame(exp_time=10)  #Exposure channel 2
    frame3 = cam.get_frame(exp_time=300)  #Exposure channel 3
    im_stk = np.zeros((3, frame1.shape[0], frame2.shape[1]))
    im_stk[0, :, :] = frame1
    im_stk[1, :, :] = frame2
    im_stk[2, :, :] = frame3

    out_file_path = "../../../Desktop/2020_11_13_training_imgs/"
    from os import listdir
    from os.path import isfile, join
    onlyfiles = [
        f for f in listdir(out_file_path) if isfile(join(out_file_path, f))
    ]
    leng = onlyfiles.__len__()
    lenstr = str(leng + 1).zfill(5)

    tifffile.imsave(out_file_path + 'pos' + lenstr + '.tif',
                    im_stk.astype(np.uint16),
                    imagej=True)

    t1 = time.time()
    print(np.round(t1 - t0, 3), "s to acquire")
    cam.close()
    pvc.uninit_pvcam()
    f, axes = plt.subplots(3, 2)
    axes[0, 0].imshow(frame1, cmap=plt.get_cmap('Blue1'))
    axes[0, 1].hist(frame1.flatten(), bins=np.arange(0, 65535, 1000))
    axes[1, 0].imshow(frame2, cmap=plt.get_cmap('Green1'))
    axes[1, 1].hist(frame2.flatten(), bins=np.arange(0, 65535, 1000))
    axes[2, 0].imshow(frame3, cmap=plt.get_cmap('Red1'))
    axes[2, 1].hist(frame3.flatten(), bins=np.arange(0, 65535, 1000))
    plt.show()
Beispiel #13
0
def InitializeInstruments():
    """
    Initializes the camera and rotators to the desired names.
    TODO: Figure out how to set the camera to 'quantview' mode.

    Parameters
    ----------

    Returns
    -------
    cam : object
        Named pyvcam camera object.
    A : object
        Named Instrumental instrument object.
    B : object
        Named Instrumental instrument object.
    C : object
        Named Instrumental instrument object.

    """

    pvc.init_pvcam()  # Initialize PVCAM
    try:
        cam = next(Camera.detect_camera())  # Use generator to find first camera
        cam.open()  # Open the camera.
        if cam.is_open:
            print("Camera open")
    except:
        raise Exception("Error: camera not found")
    Rotational = "K10CR1"
    if Rotational == "K10CR1":
        l = ["55001000", "55114554","55114654"]
        L = [K10CR1(i) for i in l]   # There is no serial number
        for i in L:
            print(f'Homing stage {i}')
            i.home()
    elif Rotational == "thorlabs_apt":
        l = apt.list_available_devices()
        L = [apt.Motor(i[1]) for i in l]
        for i in L:
            i.set_move_home_parameters(2, 1, 10, 0)
            i.set_velocity_parameters(0, 10, 10)
            i.move_home()
    elif Rotational == "thorpy":
        pass

    return cam, *L
Beispiel #14
0
def start_cam():
    ''' Initilizes the PVCAM

    returns: cam instance
    '''
    try:
        pvc.init_pvcam()
        cam = next(Camera.detect_camera())
        cam.open()
        cam.clear_mode = 'Never'
        cam.exp_mode = "Ext Trig Trig First"
        cam.readout_port = 0
        cam.speed_table_index = 0
        cam.gain = 1
    except:
        raise RuntimeError('Could not start Camera')
    return cam
def InitializeInstruments():
    """
    Initializes the camera and rotators to the desired names.
    TODO: Figure out how to set the camera to 'quantview' mode.

    Parameters
    ----------
    none
    
    Returns
    -------
    cam : object
        Named pyvcam camera object.
    A : object
        Named Instrumental instrument object.
    B : object
        Named Instrumental instrument object.
    C : object
        Named Instrumental instrument object.

    """
    pvc.init_pvcam()  # Initialize PVCAM
    cam = next(Camera.detect_camera())  # Use generator to find first camera
    cam.open()  # Open the camera.
    if cam.is_open == True:
        print("Camera open")
    else:
        print("Error: camera not found")
    try:
        A = instrument('A')  # try/except is used here to handle
    except:  # a bug in instrumental that requires
        A = instrument('A')  # this line to be run twice
    print("A.serial = " + A.serial)
    try:
        B = instrument('B')
    except:
        B = instrument('B')
    print("B.serial = " + B.serial)
    try:
        C = instrument('C')
    except:
        C = instrument('C')
    print("C.serial = " + C.serial)

    return cam, A, B, C
Beispiel #16
0
def main():
    pvc.init_pvcam()
    cam = next(Camera.detect_camera())
    cam.open()
    cam.start_live(exp_time=20)
    cnt = 0
    tot = 0
    t1 = time.time()
    start = time.time()
    width = 800
    height = int(cam.sensor_size[1] * width / cam.sensor_size[0])
    dim = (width, height)
    fps = 0

    while True:
        frame, fps, frame_count = cam.poll_frame()
        frame['pixel_data'] = cv2.resize(frame['pixel_data'],
                                         dim,
                                         interpolation=cv2.INTER_AREA)
        cv2.imshow('Live Mode', frame['pixel_data'])

        low = np.amin(frame['pixel_data'])
        high = np.amax(frame['pixel_data'])
        average = np.average(frame['pixel_data'])

        if cnt == 10:
            t1 = time.time() - t1
            fps = 10 / t1
            t1 = time.time()
            cnt = 0
        if cv2.waitKey(10) == 27:
            break
        print('Min:{}\tMax:{}\tAverage:{:.0f}\tFrame Rate: {:.1f}\n'.format(
            low, high, average, fps))
        cnt += 1
        tot += 1

    cam.finish()
    cam.close()
    pvc.uninit_pvcam()

    print('Total frames: {}\nAverage fps: {}\n'.format(
        tot, (tot / (time.time() - start))))
Beispiel #17
0
 def on_activate(self):
     """ Initialisation performed during activation of the module.
     """
     self.const = const
     pvc.init_pvcam()
     # Generator function to detect a connected camera
     self.cam = next(Camera.detect_camera())
     self.cam.open()
     self.set_fan_speed(0)
     self.cam.exp_mode = "Internal Trigger"
     self.cam.exp_res = 0
     self.exp_time = self.cam.exp_time = 1
     nx_px, ny_px = self._get_detector()
     self._width, self._height = nx_px, ny_px
     self._live = False
     self.cam.speed_table_index = 1  #16 bit mode
     self.cam.exp_out_mode = 2  #Any row expose out mode
     self.cam.clear_mode = 'Pre-Sequence'
     #For pulsed
     self._number_of_gates = int(0)
     self._bin_width = 1
     self._record_length = int(1)
     self.pulsed_frames = None
Beispiel #18
0
 def __init__(self, timeout=500):
     pvc.init_pvcam()
     self.cam = [cam for cam in Camera.detect_camera()][0]
     self.cam.open()
     self.cam.speed_table_index = 0
# openshamdor
shamdor = Shamdor()
shamdor.HSSpeed = HSSpeed  # includes readout rate 2: 50kHz


shamdor.Shutter = (1, 5, 30, 30)
shamdor.SetTemperature = -90
#shamdor.CoolerON()
shamdor.ImageFlip = (1, 0)

# aligner
aligner = SpectrometerAligner(spectrometer, stage)

# pyvcam
pvc.init_pvcam()
pcam = next(Camera.detect_camera())
pcam.open()

# create equipment dict
equipment_dict = {'spectrometer': spectrometer,
                  'laser_shutter': shutter,
                  'white_shutter': whiteShutter,
                  'andor': shamdor,
                  'shamrock': shamdor.shamrock,
                  'aligner': aligner}
wizard = TrackingWizard(CWL, equipment_dict, )
shamdor.show_gui(blocking=False)
wizard.data_file.show_gui(blocking=False, )
wizard.show()
wizard.tile_edge = tile_edge_width_to_ignore
Beispiel #20
0
from pyvcam import pvc
from pyvcam.camera import Camera
from pyvcam import constants as const
import time
import numpy as np

# Initialize test variables
test_exp_time = 10
test_num_frames = 10
test_ld_sw_value = 10

pvc.init_pvcam()  # Initialize PVCAM
cam = next(Camera.detect_camera())  # Use generator to find first camera.
cam.open()  # Open the camera.

# Check that PSM is available in the camera
if (cam.check_param(const.PARAM_SCAN_MODE)):
    # Get Auto Mode values

    # Set camera to HDR Gain 1
    print("Setting camera to HDR Gain 1")
    cam.speed_table_index = 0
    cam.gain = 1

    ###############################################################################################################
    # Set to Auto Mode
    ###############################################################################################################
    if (cam.prog_scan_mode is not const.prog_scan_modes["Auto"]):
        print("\nSetting PSM to Auto")
        cam.prog_scan_mode = "Auto"
Beispiel #21
0
def initPVCAM():
    """
    Initialize the library.
    """
    pvc.init_pvcam()
Beispiel #22
0
def main():
    pvc.init_pvcam()
    cam = next(Camera.detect_camera())
    cam.open()
    cam.meta_data_enabled = True
    cam.set_roi(0, 0, WIDTH, HEIGHT)
    cam.start_live(exp_time=100,
                   buffer_frame_count=BUFFER_FRAME_COUNT,
                   stream_to_disk_path=FRAME_DATA_PATH)

    # Data is streamed to disk in a C++ call-back function invoked directly by PVCAM. To not overburden the system,
    # only poll for frames in python at a slow rate, then exit when the frame count indicates all frames have been
    # written to disk
    while True:
        frame, fps, frame_count = cam.poll_frame()

        if frame_count >= NUM_FRAMES:
            low = np.amin(frame['pixel_data'])
            high = np.amax(frame['pixel_data'])
            average = np.average(frame['pixel_data'])
            print(
                'Min:{}\tMax:{}\tAverage:{:.0f}\tFrame Count:{:.0f} Frame Rate: {:.1f}'
                .format(low, high, average, frame_count, fps))
            break

        time.sleep(1)

    cam.finish()

    imageFormat = cam.get_param(const.PARAM_IMAGE_FORMAT)
    if imageFormat == const.PL_IMAGE_FORMAT_MONO8:
        BYTES_PER_PIXEL = 1
    else:
        BYTES_PER_PIXEL = 2

    cam.close()
    pvc.uninit_pvcam()

    # Read out meta data from stored frames
    FRAME_ALIGNMENT = 0  # Typically 0. 32 for Kinetix PCIe
    FRAME_BUFFER_ALIGNMENT = 4096
    META_DATA_FRAME_HEADER_SIZE = 48
    META_DATA_ROI_SIZE = 32
    META_DATA_SIZE = META_DATA_FRAME_HEADER_SIZE + META_DATA_ROI_SIZE
    pixelsPerFrame = WIDTH * HEIGHT
    bytesPerFrameUnpadded = pixelsPerFrame * BYTES_PER_PIXEL + META_DATA_SIZE
    framePad = 0 if FRAME_ALIGNMENT == 0 else FRAME_ALIGNMENT - (
        bytesPerFrameUnpadded % FRAME_ALIGNMENT)
    bytesPerFrame = bytesPerFrameUnpadded + framePad
    frameBufferAlignmentPad = FRAME_BUFFER_ALIGNMENT - (
        (BUFFER_FRAME_COUNT * bytesPerFrame) % FRAME_BUFFER_ALIGNMENT)

    with open(FRAME_DATA_PATH, "rb") as f:

        badMetaDataCount = 0
        for frame_index in range(NUM_FRAMES):
            frame_number = frame_index + 1

            # Read frame number from meta data header
            # Every time the circular buffer wraps around, bytes are padded into the file. This is a result of needing to
            # write data in chunks that are multiples of the alignment boundary.
            frameBufferPad = int(
                frame_index / BUFFER_FRAME_COUNT) * frameBufferAlignmentPad

            FRAME_NUMBER_OFFSET = 5
            filePos = frame_index * bytesPerFrame + FRAME_NUMBER_OFFSET + frameBufferPad
            f.seek(filePos, 0)
            frameNumberBytes = f.read(4)

            frame_number_meta_data = int.from_bytes(frameNumberBytes, 'little')

            if frame_number != frame_number_meta_data:
                badMetaDataCount += 1
                print('Expected: ' + str(frame_number) + ' Observed: ' +
                      str(frame_number_meta_data))

    print('Verified ' + str(NUM_FRAMES) + ' frames:')
    print('  Meta data errors: ' + str(badMetaDataCount))

    if badMetaDataCount > 0:
        print('\nMeta data error troubleshooting:')
        print('  1. Verify FRAME_ALIGNMENT for camera and interface')
        print('  2. Increase exposure time')
Beispiel #23
0
 def setUp(self):
     pvc.init_pvcam()
     try:
         self.test_cam = next(camera.Camera.detect_camera())
     except:
         raise unittest.SkipTest('No available camera found')
Beispiel #24
0
def main():
    pvc.init_pvcam()
    cam = next(Camera.detect_camera())
    cam.open()

    cnt = 0

    # Check status from sequence collect
    cam.start_seq(exp_time=1000, num_frames=2)

    acquisitionInProgress = True
    while acquisitionInProgress:

        frameStatus = cam.check_frame_status()
        print('Seq frame status: ' + frameStatus)

        if frameStatus == 'READOUT_NOT_ACTIVE' or frameStatus == 'FRAME_AVAILABLE' or frameStatus == 'READOUT_COMPLETE' or frameStatus == 'READOUT_FAILED':
            acquisitionInProgress = False

        if acquisitionInProgress:
            time.sleep(0.05)

    if frameStatus != 'READOUT_FAILED':
        frame, fps, frame_count = cam.poll_frame()

        low = np.amin(frame['pixel_data'])
        high = np.amax(frame['pixel_data'])
        average = np.average(frame['pixel_data'])

        print(
            'Min:{}\tMax:{}\tAverage:{:.0f}\tFrame Rate: {:.1f}\tFrame Count: {:.0f}'
            .format(low, high, average, fps, frame_count))

    cam.finish()

    frameStatus = cam.check_frame_status()
    print('Seq post-acquisition frame status: ' + frameStatus + '\n')

    # Check status from live collect. Status will only report FRAME_AVAILABLE between acquisitions, so an indeterminate number of frames are needed
    # before we catch the FRAME_AVAILABLE status
    cam.start_live(exp_time=10)

    acquisitionInProgress = True
    while acquisitionInProgress:

        frameStatus = cam.check_frame_status()
        print('Live frame status: ' + frameStatus)

        if frameStatus == 'READOUT_NOT_ACTIVE' or frameStatus == 'FRAME_AVAILABLE' or frameStatus == 'READOUT_FAILED':
            acquisitionInProgress = False

        if acquisitionInProgress:
            time.sleep(0.05)

    if frameStatus != 'READOUT_FAILED':
        frame, fps, frame_count = cam.poll_frame()

        low = np.amin(frame['pixel_data'])
        high = np.amax(frame['pixel_data'])
        average = np.average(frame['pixel_data'])

        print(
            'Min:{}\tMax:{}\tAverage:{:.0f}\tFrame Rate: {:.1f}\tFrame Count: {:.0f}'
            .format(low, high, average, fps, frame_count))

    cam.finish()

    frameStatus = cam.check_frame_status()
    print('Live post-acquisition frame status: ' + frameStatus)

    cam.close()

    pvc.uninit_pvcam()
    def open_camera(self):
        from pyvcam import pvc
        from pyvcam import constants as const
        from pyvcam.camera import Camera

        self.const = const
        self.pvc = pvc

        pvc.init_pvcam()
        self.pvcam = [cam for cam in Camera.detect_camera()][0]

        self.pvcam.open()
        self.pvcam.speed_table_index = self.cfg.camera_parameters[
            'speed_table_index']
        self.pvcam.exp_mode = self.cfg.camera_parameters['exp_mode']

        logger.info(
            'Camera Vendor Name: ' +
            str(self.pvcam.get_param(param_id=self.const.PARAM_VENDOR_NAME)))
        logger.info(
            'Camera Product Name: ' +
            str(self.pvcam.get_param(param_id=self.const.PARAM_PRODUCT_NAME)))
        logger.info(
            'Camera Chip Name: ' +
            str(self.pvcam.get_param(param_id=self.const.PARAM_CHIP_NAME)))
        logger.info(
            'Camera System Name: ' +
            str(self.pvcam.get_param(param_id=self.const.PARAM_SYSTEM_NAME)))

        # Exposure mode options: {'Internal Trigger': 1792, 'Edge Trigger': 2304, 'Trigger first': 2048}
        # self.pvcam.set_param(param_id = self.const.PARAM_EXPOSURE_MODE, value = 2304)

        # Exposure out mode options: {'First Row': 0, 'All Rows': 1, 'Any Row': 2, 'Rolling Shutter': 3, 'Line Output': 4}
        # self.pvcam.set_param(param_id = self.const.PARAM_EXPOSE_OUT_MODE, value = 3)
        ''' Setting ASLM parameters '''
        # Scan mode options: {'Auto': 0, 'Line Delay': 1, 'Scan Width': 2}
        self.pvcam.set_param(param_id=self.const.PARAM_SCAN_MODE,
                             value=self.cfg.camera_parameters['scan_mode'])
        # Scan direction options: {'Down': 0, 'Up': 1, 'Down/Up Alternate': 2}
        self.pvcam.set_param(
            param_id=self.const.PARAM_SCAN_DIRECTION,
            value=self.cfg.camera_parameters['scan_direction'])
        # 10.26 us x factor
        # factor = 6 equals 71.82 us
        self.pvcam.set_param(
            param_id=self.const.PARAM_SCAN_LINE_DELAY,
            value=self.cfg.camera_parameters['scan_line_delay'])
        self.pvcam.set_param(param_id=self.const.PARAM_READOUT_PORT, value=1)
        ''' Setting Binning parameters: '''
        '''
        self.binning_string = self.cfg.camera_parameters['binning'] # Should return a string in the form '2x4'
        self.x_binning = int(self.binning_string[0])
        self.y_binning = int(self.binning_string[2])
        '''
        self.pvcam.binning = (self.x_binning, self.y_binning)

        #self.pvcam.set_param(param_id = self.const.PARAM_BINNING_PAR, value = self.y_binning)
        #self.pvcam.set_param(param_id = self.const.PARAM_BINNING_SER, value = self.x_binning)

        # print('Readout port: ', self.pvcam.readout_port)
        """