### Install pyvcam Library using setup.py Source: https://github.com/photometrics/pyvcam/blob/master/docs/CheetSheet.txt Installs the pyvcam library from source using the standard Python setup.py script. This command should be executed in the root directory of the pyvcam source code. ```Shell python setup.py install ``` -------------------------------- ### Create Camera Example - Python Source: https://github.com/photometrics/pyvcam/blob/master/README.md This example demonstrates how to initialize PVCAM, detect the first available camera, and open it using the PyVCAM wrapper. This creates a camera object that can be used for subsequent interactions. ```Python from pyvcam import pvc from pyvcam.camera import Camera pvc.init_pvcam() # Initialize PVCAM cam = next(Camera.detect_camera()) # Use generator to find first camera. cam.open() # Open the camera. ``` -------------------------------- ### Installing PyVCAM Package - Shell Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md This command uses the setup.py script to install the PyVCAM package onto the system. It compiles necessary components and places the package in the appropriate site-packages directory for the current Python environment. Navigate to the directory containing setup.py before running. ```Shell python setup.py install ``` -------------------------------- ### Get Available Camera Names - pyvcam - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md Returns a list of names of cameras connected to the system. This method is intended to be used in conjunction with `select_camera`. Refer to `multi_camera.py` for a usage example. -------------------------------- ### Creating PyVCAM Wheel Package - Shell Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md This command uses the setup.py script to build a Python Wheel (.whl) distribution package for PyVCAM. Wheels are a standard format for Python distributions, allowing for easier installation. Navigate to the directory containing setup.py before running. ```Shell python setup.py dist bdist_wheel ``` -------------------------------- ### Changing Camera Settings - Python Source: https://github.com/photometrics/pyvcam/blob/master/README.md This example illustrates how to modify various camera settings using the 'cam' object. It demonstrates setting the clear mode, exposure mode, readout port, speed table index, and gain. ```Python # A camera object named cam has already been created cam.clear_mode = "Never" cam.exp_mode = "Ext Trig Trig First" cam.readout_port = 0 cam.speed_table_index = 0 cam.gain = 1 ``` -------------------------------- ### Parsing Python Arguments in C using PyArg_ParseTuple Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md This snippet demonstrates how to define a C function (`example`) that accepts Python arguments (`args`). It uses `PyArg_ParseTuple` with the format string "is" to parse an integer and a string from the `args` tuple into C variables `myNum` and `myString`. It then prints these values and returns `Py_RETURN_NONE`. ```C static PyObject *example(PyObject *self, PyObject *args) { int myNum; char *myString; PyArg_ParseTuple(args, "is", &myNum, &myString); printf("myNum: %d\n", myNum); // Prints "myNum: 1" printf("myString: %s\n", myString); // Prints "myString: test" Py_RETURN_NONE; } ``` -------------------------------- ### Select Camera by Name - pyvcam - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md A class method that acts as a generator, yielding a `Camera` object for the camera that matches the provided name. This method should be used in conjunction with `get_available_camera_names`. Refer to `multi_camera.py` for a usage example. -------------------------------- ### Detect Connected Cameras - pyvcam - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md A class method that acts as a generator, yielding a `Camera` object for each camera connected to the system. Refer to the code sample for creating a camera for an example of how to call this method. -------------------------------- ### Initializing PyVCAM and Creating Camera - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md This snippet demonstrates how to initialize the PVCAM library, detect the first available camera using the Camera.detect_camera() generator, and open the connection to the camera object for subsequent operations. ```Python from pyvcam import pvc from pyvcam.camera import Camera pvc.init_pvcam() # Initialize PVCAM cam = next(Camera.detect_camera()) # Use generator to find first camera. cam.open() # Open the camera. ``` -------------------------------- ### Running PyVCAM Unit Tests - Shell Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md This command executes all unit tests defined in the test_camera.py file using Python's built-in unittest module discovery feature. It should be run from the command line in the project's root directory. ```Shell python -m unittest discover ``` -------------------------------- ### Creating PyVCAM Extension Module in C Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md This C function, PyInit_pvc, serves as the entry point for initializing the PyVCAM Python extension module. It calls PyModule_Create with the module definition structure (pvcmodule) and returns the resulting module object, making it available to the Python interpreter. ```C PyMODINIT_FUNC PyInit_pvc(void) } return PyModule_Create(&pvcmodule); } ``` -------------------------------- ### Single Image Capture - Python Source: https://github.com/photometrics/pyvcam/blob/master/README.md Assuming a camera object named 'cam' has already been created and opened, this snippet shows how to capture a single image with a specified exposure time (20 ms) and print the values of the first five pixels from the resulting frame. ```Python # A camera object named cam has already been created frame = cam.get_frame(exp_time=20) print("First five pixels of frame: {}, {}, {}, {}, {}".format(*frame[:5])) ``` -------------------------------- ### Open Camera Connection - pyvcam - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md Opens a connection to the camera. If successful, it sets the internal `__handle` and `__is_open` attributes. A `RuntimeError` is raised if the underlying PVCAM function call fails. For details on Python-PVCAM interaction, see the `pvcmodule.cpp` notes. -------------------------------- ### Accessing Camera Gain (Getter) in Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md This snippet demonstrates how to retrieve a camera parameter, specifically the gain, by accessing it as an attribute of the camera object. This attribute access triggers an underlying getter method implemented using Python's property decorator, which in turn calls the PVCAM library to fetch the current value. It assumes 'cam' is a pre-initialized camera instance. ```python # Assume cam is an already constructed camera. curr_gain = cam.gain # To call getter, simply access it by attribute from the camera. ``` -------------------------------- ### Acquire Frame Sequence - pyvcam - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md Calls the `pvcmodule`'s `get_frame` function repeatedly to acquire a sequence of frames in rapid succession. Returns a 3D NumPy array of pixel data. Multiple ROIs are not supported. Requires `num_frames` (int) for the number of frames. Optional parameters include `exp_time` (int) and `timeout_ms` (int). ```Python # Given that the camera is already opened as openCam stack = openCam.get_sequence(8) # Getting a sequence of 8 frames firstFrame = stack[0] # Accessing 2D frames from 3D stack lastFrame = stack[7] ``` -------------------------------- ### Returning C String as Python String using PyUnicode_FromString Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md This snippet shows how to convert a C string (`myString`) into a Python Unicode string using the `PyUnicode_FromString` function. The resulting Python string object is then returned from the C function, making it available in the calling Python script. ```C { char *myString = "ika"; return PyUnicode_FromString(myString); // Returns a Python string back to the calling function. } ``` -------------------------------- ### Acquire Single Frame - pyvcam - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md Calls the `pvcmodule`'s `get_frame` function to acquire a single snap image. Returns a 2D NumPy array of pixel data. It can optionally take an `exp_time` (int) for exposure time and `timeout_ms` (int) for the wait duration (default is `WAIT_FOREVER`). If `exp_time` is not provided, it uses the camera's internal `exp_time` attribute. -------------------------------- ### Acquire Variable Timed Sequence - pyvcam - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md A modified version of `get_sequence` specifically for Variable Timed Mode (VTM). The camera's exposure mode must be set to "Variable Timed" before calling this method. The timings provided in `time_list` will loop until `num_frames` are captured. Multiple ROIs are not supported. Requires `time_list` (list of integers), `exp_res` (int - exposure time resolution), and `num_frames` (int). Optional parameters include `timeout_ms` (int) and `interval` (int). Refer to the PVCAM User Manual for `EXP_RES` and `EXP_RES_INDEX`. -------------------------------- ### Close Camera Connection - pyvcam - Python Source: https://github.com/photometrics/pyvcam/blob/master/docs/PyVCAM Wrapper.md Closes the connection to the camera. If successful, it resets the internal `__handle` to -1 and sets `__is_open` to `False`. A `RuntimeError` is raised if the underlying PVCAM function call fails. For details on Python-PVCAM interaction, see the `pvcmodule.cpp` notes. === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.