sensors.GUIclasses
Contains the classes to create the various tabs within the Bokeh application.
Class InfoTab
- class sensors.GUIclasses.info.InfoTab(config)[source]
Bases:
objectClass to create a Bokeh tab that displays information about the system and the peripherical devices.
- Parameters:
init_dev (object) – picamera and audio device object initialized in
sensors.app_hookswithsensors.Utilities.initdevices.InitDevices
- get_audio_info()[source]
Creates audio system information.
- Returns:
html code for corresponding information
- Return type:
string
- get_camera_info()[source]
Creates PiCamera information.
- Returns:
html code for corresponding information
- Return type:
string
- get_sensors_info()[source]
Creates information about available sensors for measurement of meta data.
- Returns:
html code for corresponding information
- Return type:
string
- get_system_info()[source]
Creates general system information.
- Returns:
html code for corresponding information
- Return type:
string
- property tab
Creates and arranges the elements of the corresponding Bokeh tab.
- Returns:
Bokeh panel for visualization of general information on system and devices
- Return type:
Bokeh object
Class CamStreamTab
- class sensors.GUIclasses.picam_stream.CamStreamTab(config)[source]
Bases:
objectClass to create a Bokeh tab that displays a life stream from a picamera. Pictures can be taken manually or are triggered with a light barrier.
- Parameters:
config (object) – configuration including config.yaml dictionary and current Bokeh document
camera (object) – picamera object initialized in
sensors.app_hookswithsensors.Utilities.initdevices.InitDevices
- LED_on_off()[source]
Gets called on button click. Activates respectively deactivates LED corresponding to button label.
- MouseLeave(event: PointEvent)[source]
Returns relative coordinates of position where mouse left image figure of picamera preview. Updates ROI.
- MouseMove(event: PointEvent)[source]
Returns relative coordinates of mouse position in image figure of picamera preview. Updates ROI.
- barrier_on_off()[source]
Gets called on button click. Activates respectively deactivates light barrier corresponding to button label. The barrier status gets checked in
periodic_callback().
- calculate_image_ROI()[source]
Calculate coordinates of ROI for histogram data from mouse positions and handle possible cases.
- camera_capture()[source]
Targeted by ThreadPoolExecutor from
camera_future(). Method to capture a single image with picamera video port.- Returns:
False flag for image capture in progress (capture done)
- Return type:
bool
- camera_future()[source]
Targeted by next tick callback from
periodic_callback(). The method creates a future picamera image capture in a parallel thread that is not blocking the main Bokeh visualization thread.- Returns:
future
- Return type:
object
- change_camera_settings(attr, old, new)[source]
Gets called on value change of gains respectively white balance. Changes camera settings accordingly
- check_light_barrier_interruption()[source]
The method checks if any GPIO pin that is connected to a light barrier is HIGH which corresponds to an interruption.
- Returns:
Status flag of light barrier interruption
- Return type:
boolean
- decode_frames_write_data(h264_decoder)[source]
Gets called by
save_h264_video().FrameDecoderconverts h264 video to mp4 and decodes frames from h264 video andWriteMetaDatawrites meta data measured with sensors into data.json dictionary.- Parameters:
h264_decoder (object) – object to decode frames from mp4 video
- do_preview()[source]
Gets called on button click. Starts respectively ends the preview and changes the text status corresponding to button label.
- finish_decodes()[source]
Periodic callback targeted from
do_preview(). Finishes plots of decoded frames in preview if picamera stream gets stopped before all plots were done.
- init_circular_stream()[source]
Initializes a circular buffer for recording a h264 video. Parameters can be tuned via Picamera widget.
- make_tab()[source]
Creates and arranges the elements of the corresponding Bokeh tab.
- Returns:
Bokeh panel for picamera stream visualization
- Return type:
Bokeh object
- manual_image_save()[source]
Gets called on button click. Raises flag to capture an image sequence in
periodic_callback()to callsave_h264_video().
- on_PanEnd(event: PointEvent)[source]
Returns relative coordinates of mouse position in image figure of picamera preview on end of panning. Updates ROI.
- on_PanStart(event: PointEvent)[source]
Returns relative coordinates of mouse position in image figure of picamera preview on start of panning. Updates ROI.
- periodic_callback()[source]
Targeted by a Bokeh periodic callback from
do_preview(). Checks if the light barrier got interrupted and sets the corresponding flag. If the current Bokeh document update is done a new camera capture for the preview withcamera_future()gets initiated. If one of the save sequence flags is raised thesave_h264_video()gets called before a new preview image is taken.
- plot_decoded_frame(plot_png_filename)[source]
Gets called by
periodic_callback(). Plots a decoded frame.
- save_h264_video()[source]
Gets called on button click or when triggered by an interruption of the light barrier. Saves a h264 video and decodes n images at the relative path p, where n is defined by number_frames and p by img_path in config.yaml.
- property tab
Calls method
make_tab().
- update_Bokeh()[source]
Targeted by next tick callback from
camera_future(). Updates the picamera preview.
Class AudioStreamTab
- class sensors.GUIclasses.audio_stream.AudioStreamTab(config)[source]
Bases:
objectClass to create a Bokeh tab that displays a life wingbeat stream of the latest audio chunk and a ringbuffer whose length can be specified with the timeframe parameter in the config.yaml file. The ringbuffer can be saved on button click.
- Parameters:
config (object) – configuration including config.yaml dictionary and current Bokeh document
- do_update()[source]
Gets called on button click. Starts respectively ends the preview of the chunk signal, the ringbuffer and changes the text status corresponding to the button label.
- make_tab()[source]
Creates and arranges the elements of the corresponding Bokeh tab.
- Returns:
Bokeh panel for ringbuffer audio stream visualization
- Return type:
Bokeh object
- save_ringbuffer()[source]
Gets called on button click. Saves the ringbuffer by setting a save flag that gets passed to
sensors.Utilities.pyaudiohandler.PyAudioHandler.update_audio_data()callingsensors.Utilities.pyaudiohandler.PyAudioHandler.save_all()if true.
- signal_update(data)[source]
Updates the chunk and the ringbuffer figures. Targeted by next tick callback from
sensors.Utilities.pyaudiohandler.PyAudioHandler.update_audio_data().- Parameters:
data – resampled chunk signal, PDS of chunk signal, resampled ringbuffer, raw triggered signal and filename provided by
PyAudioHandler.update_audio_data():type data: 1D float array, 1D float array, 1D float array, 1D int16 array and string
- property tab
Calls method
make_tab().
Class TriggeredSaveTab
- class sensors.GUIclasses.triggered_save.TriggeredSaveTab(config)[source]
Bases:
objectClass to create a Bokeh tab that displays a life wingbeat stream of the latest audio chunk, the last four triggered signals and their PSD. The duration of the triggered signal can be indirectly specified with the number_of_saved_chunks, chunk_size and sampling_rate parameters in the config.yaml file. To trigger a signal the user can adjust a threshold and a gain.
- Parameters:
config (object) – configuration including config.yaml dictionary and current Bokeh document
- create_single_png(png_filename)[source]
Gets called by
rename_signal()and creates apngof the triggered signal and its PSD at user specified path without blocking the visualization.- Returns:
future
- Return type:
object
- do_update()[source]
Gets called on button click. Starts respectively ends the preview of chunk signal and changes the text status corresponding to the button label. Triggered signals only get saved when preview is active.
- make_tab()[source]
Creates and arranges the elements of the corresponding Bokeh tab.
- Returns:
Bokeh panel for the visualization of four triggered signals
- Return type:
Bokeh object
- rename_signal()[source]
Gets called by
signal_update()when save of wingbeat was triggered.
- signal_update(data)[source]
Updates the chunk and the triggered signal figures. Targeted by next tick callback from
sensors.Utilities.pyaudiohandler.Pyaudiohandler.update_audio_data(). The PSD of the triggered signals get computed and plotted in the corresponding figures.- Parameters:
data (1D float array, 1D float array, 1D float array, 1D int16 array and string) – resampled chunk signal, PSD of chunk signal, resampled ringbuffer, raw triggered signal and filename provided by
Pyaudiohandler.update_audio_data()
- property tab
Calls method
make_tab().
Class SingleSaveTab
- class sensors.GUIclasses.single_save.SingleSaveTab(config)[source]
Bases:
objectClass to create a Bokeh tab that displays a life wingbeat stream of the latest audio chunk and the last triggered signal and its PSD. The duration of the triggered signal can be indirectly specified with the number_of_saved_chunks, chunk_size and sampling_rate parameters in the config.yaml file. To trigger a signal the user can adjust a threshold and a gain. The signal
wavfile can be saved to a user specified path together with a png of the signal and its PSD.- Parameters:
config (object) – configuration including config.yaml dictionary and current Bokeh document
- create_new_datetime(attr, new, old)[source]
Gets called on
signal_update()after a new signal has been triggered. Creates a datetime folder in import/export format to store the triggered signal and corresponding PSD png.
- create_new_filename(attr, new, old)[source]
Gets called on change of value of customized folder name text input widget and on
do_update(). Creates a user specified path to save the triggered signal.
- create_single_png(png_filename)[source]
Gets called by
rename_signal()and creates apngof the triggered signal and its PSD at user specified path without blocking the visualization.- Returns:
future
- Return type:
object
- do_update()[source]
Gets called on button click. Starts respectively ends the preview of chunk signal and changes the text status corresponding to the button label. Triggered signal only gets saved when preview is active.
- make_tab()[source]
Creates and arranges the elements of the corresponding Bokeh tab.
- Returns:
Bokeh panel for the visualization of a single triggered signal and customization of file location
- Return type:
Bokeh object
- rename_signal()[source]
Gets called on button click. Renames file to the one created by
create_new_filename()
- signal_update(data)[source]
Updates the chunk and the triggered signal. Targeted by next tick callback from
sensors.Utilities.pyaudiohandler.Pyaudiohandler.update_audio_data(). A PSD of the triggered signal gets computed and plotted in the corresponding figure.- Parameters:
data (1D float array, 1D float array, 1D float array, 1D int16 array and string) – resampled chunk signal, PSD of chunk signal, resampled ringbuffer, raw triggered signal and filename provided by
Pyaudiohandler.update_audio_data()
- property tab
Calls method
make_tab().
Class ExportTab
- class sensors.GUIclasses.export.ExportTab(config)[source]
Bases:
objectClass to create a Bokeh widget to export
- Parameters:
config (object) – configuration including current Bokeh document and paths to data
- create_new_filename(attr, new, old)[source]
Gets called on change of value of customized folder name text input widget. Creates a user specified path to save export zips.
- create_single_zip()[source]
Targeted by next tick callback from
periodic_callback(). The method creates one zip in a parallel thread that is not blocking the main Bokeh visualization thread.- Returns:
future
- Return type:
object
- get_list_of_lists_folders()[source]
Method creates a list of folder lists from the selected starting path, whereby each folder list’s memory size is smaller than the specified max_size in bytes. To check that folder lists only contain data paths in import/export format, each folder is checked for the existence of a
data.jsonfile and no existing subdirectories.
- init_create_zips()[source]
Gets called on button click to show/hide camera setting sliders and numeric inputs.
- make_tab()[source]
Creates the Export widget, including text inputs to specify paths to saved zip files.
- Returns:
Bokeh widget for export zips
- Return type:
Bokeh object
- periodic_callback()[source]
Targeted by periodic callback from
init_create_zips(). Method checks if zip is in progress and initiate the creation of a new archive if false.
- property tab
Calls method
make_widget().
- update_progression()[source]
Targeted by next tick callback from
create_single_zip(). Method checks if all zips are done and exits if true or updates the progression if false.
Class DataViewerTab
- class sensors.GUIclasses.data_viewer.DataViewerTab(config)[source]
Bases:
objectClass to create a Bokeh tab that enables the display of measured images and wingbeat signals. Additional ViewerTabs can be created on button click that calls
sensors.main.add_viewer_tab().- Parameters:
config (object) – configuration including config.yaml dictionary and current Bokeh document
- change_classification()[source]
Gets called on button click. The specified autocomplete value is looked up in
species_template.jsonand the corresponding taxonomy information and GBIF IDs is used to overwrite the dictionary entries indata.jsonof the selected data folder.
- enable_disable_change_class_button(attr, old, new)[source]
Callback method to enable respectively disable the button to change classification data. Depending on the confidence value being zero or nonzero.
- load_img()[source]
Gets called on button click. Filedialog opens and asks to select a
pngfile from drive (X11 forwarding has to be enabled if the server is controlled via SSH tunnel). The image gets loaded into a div container.
- load_signal()[source]
Gets called on button click. Filedialog opens and asks to select a
wavfile from drive (X11 forwarding has to be enabled if the server is controlled via SSH tunnel). The signal, its spectrogram and PSD get plotted in corresponding figures.
- make_tab()[source]
Creates and arranges the elements of the corresponding Bokeh tab.
- Returns:
Bokeh panel for the visualization of measured data
- Return type:
Bokeh object
- show_classification(data_type)[source]
Gets called by
load_image()orload_signal()and outputs corresponding taxonomy data in div container.- Parameters:
data_type (string) – “Image”, “WB” or “New Classification”
- property tab
Calls method
make_tab().
Class AutocompleteTaxonomy
- class sensors.GUIclasses.taxonomy_autocomplete_widget.AutocompleteTaxonomy(config)[source]
Bases:
objectClass to create a Bokeh widget to autocomplete species names. Corresponding GBIF data from
species_template.jsonis used to fill in correct information intodata.jsonfor each measurement. The user has to specify a confidence greater zero in his insect classification to activate the autocomplete and select widgets. Then a species, genus or family can be set via autocomplete input and only then taxonomy data is written todata.json.- Parameters:
config (object) – configuration including data format dictionary, species template dictionary and current Bokeh document
- autocomp_list(tax_name)[source]
Creates the autocomplete list of all species, genera or families from the
species_template.jsontemplate depending on the parameter tax_name for Bokeh’s AutocompletInput object. The second list contains the corresponding indices within thespecies_template.jsonlist to look up the needed GBIF information for a chosen, autocompleted species, genus or family within Bokeh.- Parameters:
tax_name (string) – “species”, “genus” or “family”
- Returns:
Tuple[list of all species/genera/families, list of corresponding indices in
species_template.json, list of species synonym flags]- Return type:
Tuple[string, integer, boolean]
- change_tax_list(wttr, old, new)[source]
Gets called on change of value in Select object if other taxonomy level gets chosen. Updates corresponding lists for Bokeh’s AutocompletionInput and the text within the div container to output chosen species, genus, family.
- make_widget()[source]
Creates the autocomplete widget for species selection.
- Returns:
Bokeh widget for species selection from static dictionary exported from GBIF database
- Return type:
Bokeh object
- update_any_change(wttr, old, new)[source]
Gets called on any change of value input in AutocompleteInput object.
- update_selected(wttr, old, new)[source]
Gets called on change of value in AutocompleteInput object. Due to
update_any_change()will always be updated on any change.
- update_spinner(wttr, old, new)[source]
Gets called on change of value in Spinner object. Activates Autocomplete and Select widgets if value is greater zero.
- property widget
Calls method
make_widget().
Class CameraSettings
- class sensors.GUIclasses.camera_settings_widget.CameraSettings(config)[source]
Bases:
objectClass to create a Bokeh widget to change Picamera settings, including analog gain, digital gain, automatic white balance (awb) for red and blue channels, sharpness, contrast and video denoise.
- Parameters:
config (object) – configuration including presettings for Picamera and current Bokeh document
- make_widget()[source]
Creates the Picamera settings widget, including sliders and numeric inputs to change camera parameters.
- Returns:
Bokeh widget for Picamera settings
- Return type:
Bokeh object
- set_select_values(attr, new, old)[source]
Gets called on change of select widget’s value and loads predefined values for the camera parameters.
- show_settings()[source]
Gets called on button click to show/hide camera setting sliders and numeric inputs.
- property widget
Calls method
make_widget().