plt.subplots(figsize=(12,4))
plt.imshow(cam.dc.data[:,1,:],cmap="gray",aspect=0.3)
This module can be imported using from openhsi.cameras import *
Wrapper class and example code for getting images from the OpenHSI.
To use the camera, you will need some calibration files. You can also generate these files following this guide which uses the calibrate module.
To add a custom camera, five methods need to be defined in a class to: 1. Initialise camera __init__, and 2. Open camera start_cam, and 3. Close camera stop_cam, and 4. Capture a picture as a numpy array get_img, and 5. Update the exposure settings set_exposure, and 6. [Optional] Poll the camera temperature get_temp.
By inheriting from the OpenHSI class, all the methods to load settings/calibration files, collect datacube, saving data to NetCDF, and viewing as RGB are integrated. Furthermore, the custom camera class can be passed to a SettingsBuilder class for calibration.
For example, we implement a webcamera camera below.
This uses the OpenCV library to interface with a webcam including the one in your laptop. Mainly for testing but maybe this could be useful.
WebCamera (mode:str=None, n_lines:int=16, processing_lvl:int=-1, warn_mem_use:bool=True, json_path:str=None, cal_path:str=None, print_settings:bool=False)
Interface for webcam to test OpenHSI functionality
You can see a picture I held up to the webcam.
This function is designed to be used using the Multiprocessing library to initiate camera recording when desired inside a script. When the switch is closed, this function then finishes releasing memory back to the system.
switched_camera (cam_class:str=None, n_lines:int=128, processing_lvl:int=0, json_path:str='/media/pi/fastssd/c als/flir_settings.json', cal_path:str='/media/pi/fastssd /cals/flir_calibration.pkl', preconfig_meta:str='/media/ pi/fastssd/cals/preconfig_metadata.json', ssd_dir:str='/media/pi/fastssd', toggle_interface=None)
If toggle_interface.status is True, collect with the camera until switched is False.
| Type | Default | Details | |
|---|---|---|---|
| cam_class | str | None | Camera Class Name from openhsi.cameras |
| n_lines | int | 128 | how many along-track pixels |
| processing_lvl | int | 0 | desired processing done in real time |
| json_path | str | /media/pi/fastssd/cals/flir_settings.json | path to settings file |
| cal_path | str | /media/pi/fastssd/cals/flir_calibration.pkl | path to calibration file |
| preconfig_meta | str | /media/pi/fastssd/cals/preconfig_metadata.json | path to metadata file |
| ssd_dir | str | /media/pi/fastssd | path to SSD |
| toggle_interface | NoneType | None | toggle_interface that controls collection |