<jupyter_start><jupyter_text>Lab 0: Getting familiar with the camera The main purpose of Lab 0 is to familiarize yourselves with the camera. You should be able to capture an image, establish a basic understanding of camera parameters and adjust them in live image display to obatin the best image possible  Import basic Python modules<jupyter_code>import os
import sys
# Add the path which contains wrappers for II harwares
sys.path.append(r'.\Hardware_src') # Make the change according to your path

# Python modules for figure visualization
import numpy as np
import matplotlib.pyplot as plt
from helper import check_minmax
from IPython.display import clear_output
from IPython.display import display, HTML<jupyter_output><empty_output><jupyter_text>Camera object instantiation<jupyter_code>from camera import Camera
# Instantiate Camera object
c = Camera()
c.open()
c.initialize_memory()<jupyter_output><empty_output><jupyter_text>Check camera properties<jupyter_code>c.get_properties()<jupyter_output><empty_output><jupyter_text>Capture your first image<jupyter_code>img = c.capture().copy() # Note: it's always a good habit to use np.copy() when assigning values to another variables
                         # to avoid they share the same address
# Visualize your captured image

#########################
######## YOUR CODE#######<jupyter_output><empty_output><jupyter_text>Think about the following questions:+ How does your image look like? In-focus or out-of-focus? Is there any saturation in image readout?+ Based on what we have discussed, what causes saturation? How do you control the detector pixel readout?  Change the imaging settings<jupyter_code># Set the frame rate
c.set_framerate(5)

# Check the framerate
c.get_framerate()
# Set the pixel clock
c.set_pixel_clock(7)

# Check the pixel clock
c.get_pixel_clock()
# Set exposure
c.set_exposure(50)

# Check current exposure
c.get_exposure()<jupyter_output><empty_output><jupyter_text>Live image display Feel free to customize the example code for live image display<jupyter_code># Live image display for fine-tuning the camera parameters
fig, ax = plt.subplots(figsize=(7, 7))
plt.close(fig) 
# live image display with exception handling
try:
    while True: 
        ax.imshow(c.capture().copy(), clim=[0, 1023], cmap='gray')
        clear_output(wait=True)
        display(fig)
except KeyboardInterrupt: # interrupt python kernel (press i twice in command mode) to stop image capture
    print('Live image display has stopped')
finally:
    print('Statement here will be executed even if an exception occurs in the try block')<jupyter_output><empty_output><jupyter_text>Seting up the imaging Region-of-Interest (ROI) You don't always have to capture the full-field image, feel free to narow down to a specific ROI and focus on your target of interest **Attention**: Keep in mind that raw measurement is **the transpose of your camera view** due to different memory order in camera and in Python. It's a little bit confusing, but always remember it when setting up ROI<jupyter_code># Set the imaging ROI (in raw measurement view)
roi_shape = [120,120] # ROI size MUST BE MULTIPLE OF 4
roi_pos = [1000,500] # The location of top-left corner of AOI on axis 0 and 1;
                     # Full size is (1280,1024)
c.set_roi(roi_shape, roi_pos)<jupyter_output><empty_output><jupyter_text>Always visualize the captured image to check if the ROI is what you desired<jupyter_code>########################################
############ YOUR CODE #################<jupyter_output><empty_output><jupyter_text>Close the camera<jupyter_code># Close the camera
c.close()<jupyter_output><empty_output>