Models Package

Apps Models

This module defines the ModelApps class, which serves as a central control unit for managing various functionalities within an application. The ModelApps class integrates several utility classes and modules for tasks such as image processing, camera streaming, configuration management, and more.

class models.model_apps.ModelApps(*args: Any, **kwargs: Any)[source]

Bases: MoilUtils

ModelApps class serves as the central control unit for managing various functionalities within an application.

_theme

The current theme of the application, either ‘light’ or ‘dark’.

Type:

str

_mode_view

The current mode of view in the application.

Type:

str

_recenter_mode_view

Flag indicating whether recenter mode is active.

Type:

bool

_activity_logger

Logger for logging activities within the application.

_thread_screen_capture

Thread for capturing screen images.

_debug_mode

Flag indicating whether debug mode is active.

Type:

bool

_main_config

Main configuration settings for the application.

Type:

dict

_recent_project_config

Configuration settings for recent projects.

Type:

dict

_recent_project_list

List of recent projects.

Type:

list

_image_ori_resize

Resized version of the original image.

_image_ori_used

The version of the original image currently being used.

_image_original

The original image.

_image_recenter

Recentered image.

_source_usable

Flag indicating whether the image source is usable.

Type:

bool

- __init__

Initializes the ModelApps class.

- open_streaming_camera

Opens a streaming camera with the specified media source.

- load_video_source

Loads a video source.

- load_image_source

Loads an image source.

- check_if_the_source_is_usable

Checks if the source is usable for processing.

- process_image_ori

Processes the original image based on the rotation angle specified in the main configuration.

- change_resolution_image

Changes the resolution of the image.

- save_main_config_update

Saves the updated main configuration.

property theme_mode

Get the current theme mode. Can be ‘light’ or ‘dark’

property mode_view

Get the current mode view from the main configuration.

property recenter_mode_view

Get the state of the recenter mode view.

property active_view_mode

Get the current active view mode from the main configuration.

property open_directory_path

Get the open directory path from the main configuration.

property style_light_mode

Get the style configuration for light mode.

property style_dark_mode

Get the style configuration for dark mode.

property activity_logger

Get the current activity logger.

property debug_mode

Get the current state of debug mode.

property image_original

Get the original image.

property image_ori_used

Get the currently used original image. If none, set it to the original image.

property image_recenter

Get the current state of image recentering.

property image_result

Get the current result image.

property set_image_resize
property main_config

Get the main configuration.

property recent_project_list

Get the list of recent projects.

property source_usable

Get the current state of source usability.

save_main_config_update()[source]

Save the updated main configuration. :returns: None

open_streaming_camera(media_source)[source]

Open a streaming camera with the specified media source. The media source can be a camera URL or an integer representing the camera index.

Arg:

media_source (str or int): The media source for opening the camera.

Returns:

The capture object for the streaming camera.

Return type:

cv2.VideoCapture

load_video_source(media_source)[source]

Load a video source.

Open a video capture from the specified media source. The media source can be a file path, URL, or an integer representing the camera index.

Arg:

media_source (str or int): The media source for opening the video capture.

Returns:

The capture object for the video source.

Return type:

cv2.VideoCapture

load_image_source(media_source)[source]

Load an image source.

Reads an image from the specified media source. The media source should be a file path to the image.

Arg:

media_source (str): The file path of the image to load.

Returns:

The loaded image.

Return type:

numpy.ndarray

check_if_the_source_is_usable(source)[source]

Check if the source is usable.

Checks if the provided source (either a cv2.VideoCapture object or a numpy array) is usable for processing. If the width or height is less than or equal to 640x480, the source is considered not usable.

Arg:

source (cv2.VideoCapture or numpy.ndarray): The source to check.

Returns:

None

process_image_ori()[source]

Process the original image.

Processes the original image based on the rotation angle specified in the main configuration. If the image has been resized, the resized version is used; otherwise, the original image is used.

Returns:

The processed original image.

Return type:

numpy.ndarray

change_resolution_image()[source]

Change the resolution of the image.

Resizes the original image to the resolution specified in the main configuration. Updates the resized image attribute (_image_ori_resize) and checks if the MoilDev instance needs to be recreated.

Returns:

None

resize_image_resolution()[source]

Config Models

This module contains the ModelConfigApps class, which handles the management of configuration files used by MoilApp. It includes methods for loading, saving, resetting, and updating configuration settings, as well as managing recent project configurations.

class models.model_config.ModelConfigApps(model)[source]

Bases: object

The ModelConfigApps class manages configuration files for MoilApp.

_model

The ModelApps instance for accessing application data and functionalities.

_path_file

The path to the directory containing configuration files.

Type:

str

_config_file

The path to the main configuration file.

Type:

str

_config_project_file

The path to the recent project configuration file.

Type:

str

_recent_config_dir

The path to the directory containing recent project configuration files.

Type:

str

- get_config_file

Manages the main configuration file for MoilApp.

- save_update_main_config

Saves updated configuration data to the main configuration file.

- reset_value_main_config

Resets the configuration view to its default values.

- read_recent_config_path

Reads recent project configuration files from the specified directory.

- get_timestamp

Extracts the timestamp from a filename to sort recent project configurations.

- load_json_file

Loads a JSON file from the specified path and returns its content.

- load_json_file_project

Loads a ‘recent__.json’ file from the specified directory and returns its content.

- remove_json_file_project

Removes a specific ‘recent__.json’ file from the recent configuration directory.

- create_config_recent

Creates a new recent configuration file with a unique name based on the current timestamp.

- create_new_data_recent

Creates a new ‘recent__.json’ file for the recent open project.

- update_main_config_from_recent

Updates the main configuration from the recent configuration.

get_config_file()[source]

Manages the main configuration file for MoilApp.

This method checks if the main configuration file exists. If the file exists, it loads its content. If the file doesn’t exist or encounters an error during loading, it resets the configuration to default values.

Returns:

The path to the main configuration file.

Return type:

str

save_update_main_config(data)[source]

Save updated configuration data to the main configuration file for MoilApp.

This method writes the provided configuration data to the main configuration file. The configuration file is formatted with an indentation of 5 spaces for better readability.

Arg:

data (dict): The updated configuration data to be saved.

Returns:

None

reset_value_main_config()[source]

Reset the configuration view to its default values.

This function sets all the fields of the configuration view to their default values, and saves the new configuration to the config file.

read_recent_config_path()[source]

Read the recent project configuration files from the specified directory.

This method scans the directory for files with names starting with ‘recent_’ and ending with ‘.json’. It reads each file and checks if it contains a valid ‘Media_path’ key. If valid, the file name is added to the list of recent project configurations; otherwise, the file is removed.

Returns:

None

get_timestamp(filename)[source]

Extract the timestamp from a filename to sort recent project configurations.

This method parses the given filename to extract the timestamp embedded in the format ‘recent_[timestamp].json’. The extracted timestamp is returned for sorting the recent project configurations by their creation time.

Arg:

filename (str): The name of the recent project configuration file.

Returns:

The extracted timestamp from the filename.

Return type:

str

load_json_file(path)[source]

Load a JSON file from the specified path and returns its content.

This method reads the JSON file located at the given path and parses its content into a Python dictionary. The parsed content is then returned to the caller.

Arg:

path (str): The path to the JSON file to be loaded.

Returns:

The parsed content of the JSON file as a dictionary.

Return type:

dict

load_json_file_project(path)[source]

Load a ‘recent__.json’ file from the specified directory and returns its content.

This method constructs the full path to the ‘recent__.json’ file using the provided path and the directory where recent configuration files are stored. It then calls the load_json_file method to read and parse the JSON content.

Arg:

path (str): The filename of the ‘recent__.json’ file to be loaded.

Returns:

The parsed content of the ‘recent__.json’ file as a dictionary.

Return type:

dict

remove_json_file_project(path)[source]

Remove a specific ‘recent__.json’ file from the recent configuration directory.

This method constructs the full path to the ‘recent__.json’ file using the provided filename and the directory where recent configuration files are stored. It then deletes the file from the file system.

Arg:

path (str): The filename of the ‘recent__.json’ file to be removed.

Returns:

None

create_config_recent()[source]

Create a new recent configuration file with a unique name based on the current timestamp.

This method generates a unique filename for the new recent configuration file using the current date and time. It then checks the existing recent configuration files to ensure that there are no duplicates or overlaps with the current project’s media path. If a duplicate is found, it removes the old recent configuration file and creates a new one.

Arg:

None

Returns:

None

create_new_data_recent(filename)[source]

Create a new ‘recent__.json’ file for the recent open project.

This method constructs a new recent configuration data based on the main configuration data of the current project. It gathers essential parameters such as source type, camera type, media path, and various mode settings from the main configuration. This data is then saved into a new ‘recent__.json’ file with the specified filename.

Arg:

filename (str): The filename for the new recent configuration file.

Returns:

None

update_main_config_from_recent(config, load=True)[source]

Update the main configuration from the recent configuration.

Updates the main configuration attributes based on the values provided in the recent configuration. Optionally, saves the updated main configuration to the configuration file.

Parameters:
  • config (dict) – The recent configuration dictionary.

  • load (bool, optional) – Whether to load the updated main configuration. Defaults to True.

Returns:

None

GitHub Models

This module contains the ModelGitConfig class, which facilitates operations related to Git configurations, such as fetching information about the GitHub repository, refreshing repository information, and changing configuration settings.

class models.model_github.ModelGitConfig(model)[source]

Bases: object

The ModelGitConfig class manages configurations related to Git repositories for MoilApp.

_model

The associated ModelApps instance.

_github_repository

The Git repository object.

Type:

git.Repo

_github_config

The GitHub configuration data.

Type:

dict

- __init__

Initializes the ModelGitConfig class.

- _init_github_information

Fetches information about the GitHub repository.

- refresh_github_information

Refreshes the GitHub repository information.

- change_config_github

Changes the configuration for the GitHub repository.

property github_repository

Get the GitHub repository associated with the instance.

Returns:

The name of the GitHub repository.

Return type:

str

refresh_github_information()[source]

Refresh the GitHub repository information and emits the updated configuration.

Reads the cached GitHub configuration from the file system and updates it with the latest information from the remote repository. The list of branches is obtained from the repository, and the list_branch property in the cached configuration is updated. If a token is present in the configuration, the remote repository is fetched using the token. Finally, the updated configuration is emitted using the git_repository_info signal.

Returns:

None

change_config_github(token=None, branch=None)[source]

Change the configuration for the GitHub repository.

The function loads the current configuration for the GitHub repository from a YAML file, updates it with the provided token and/or branch name, and writes it back to the file. If a token is provided and the current repository URL does not include the token, the function updates the repository URL with the new token. Finally, the function emits a signal with the updated configuration.

Parameters:
  • token (str, optional) – The access token to use when connecting to the GitHub repository. If provided, the function will update the configuration file with the new token. Defaults to None.

  • branch (str, optional) – The name of the active branch to use. If provided, the function will update the configuration file with the new branch name. Defaults to None.

Returns:

None

Raises:

None

Icon and Pixmap Models

The model_icon_and_pixmap module manages the retrieval of icons used in the application.

class models.model_icon_and_pixmap.GetResourcesIcon[source]

Bases: object

The GetResourcesIcon class manages the retrieval of icons used in the application.

- __init__

Initializes the GetResourcesIcon class.

- get_icon_moilapp

Retrieves the MoilApp icon.

- get_icon_user

Retrieves the user icon.

- get_icon_fisheye_24px

Retrieves the fisheye icon with a size of 24 pixels.

- get_icon_fisheye_200px

Retrieves the fisheye icon with a size of 200 pixels.

- etc
get_icon_moilapp()[source]

Return a QIcon object representing the Moil application icon.

Returns:

Icon representing the Moil application.

Return type:

QtGui.QIcon

get_icon_user()[source]

Returns a QIcon object representing the user icon.

Returns:

Icon representing the user.

Return type:

QtGui.QIcon

get_icon_fisheye_24px()[source]

Return a QIcon object representing the fisheye icon in 24px size.

Returns:

Fisheye icon in 24px size.

Return type:

QtGui.QIcon

get_icon_fisheye_200px()[source]

Return a QIcon object representing the fisheye icon in 200px size.

Returns:

Fisheye icon in 200px size.

Return type:

QtGui.QIcon

get_icon_anypoint_24px()[source]

Return a QIcon object representing the anypoint icon in 24px size.

Returns:

AnyPoint icon in 24px size.

Return type:

QtGui.QIcon

get_icon_anypoint_old_icon()[source]

Return a QIcon object representing an older version of the anypoint icon.

Returns:

Older version of the AnyPoint icon.

Return type:

QtGui.QIcon

get_icon_anypoint_128px()[source]

Return a QIcon object representing the anypoint icon in 128px size.

Returns:

AnyPoint icon in 128px size.

Return type:

QtGui.QIcon

get_icon_panorama_24px()[source]

Return a QIcon object representing the panorama icon in 24px size.

Returns:

Panorama icon in 24px size.

Return type:

QtGui.QIcon

get_icon_panorama_old_icon()[source]

Return a QIcon object representing an older version of the panorama icon.

Returns:

Older version of the panorama icon.

Return type:

QtGui.QIcon

get_icon_panorama_128px()[source]

Return a QIcon object representing the panorama icon in 128px size.

Returns:

Panorama icon in 128px size.

Return type:

QtGui.QIcon

get_icon_arrow_down()[source]

Return a QIcon object representing the arrow pointing downwards.

Returns:

Icon of an arrow pointing downwards.

Return type:

QtGui.QIcon

get_icon_arrow_left()[source]

Return a QIcon object representing the arrow pointing leftwards.

Returns:

Icon of an arrow pointing leftwards.

Return type:

QtGui.QIcon

get_icon_arrow_right()[source]

Return a QIcon object representing the arrow pointing rightwards.

Returns:

Icon of an arrow pointing rightwards.

Return type:

QtGui.QIcon

get_icon_arrow_up()[source]

Returns a QIcon object representing the arrow pointing upwards.

Returns:

Icon of an arrow pointing upwards.

Return type:

QtGui.QIcon

get_icon_up()[source]

Returns a QIcon object representing an upward direction.

Returns:

Icon representing an upward direction.

Return type:

QtGui.QIcon

get_icon_down()[source]

Returns a QIcon object representing a downward direction.

Returns:

Icon representing a downward direction.

Return type:

QtGui.QIcon

get_icon_left()[source]

Returns a QIcon object representing a leftward direction.

Returns:

Icon representing a leftward direction.

Return type:

QtGui.QIcon

get_icon_right()[source]

Returns a QIcon object representing a rightward direction.

Returns:

Icon representing a rightward direction.

Return type:

QtGui.QIcon

get_icon_center()[source]

Returns a QIcon object representing the center point.

Returns:

Icon representing the center point.

Return type:

QtGui.QIcon

get_icon_video()[source]

Returns a QIcon object representing a video.

Returns:

Icon representing a video.

Return type:

QtGui.QIcon

get_icon_square()[source]

Returns a QIcon object representing a square shape.

Returns:

Icon representing a square shape.

Return type:

QtGui.QIcon

get_icon_play_video()[source]

Returns a QIcon object representing the play button for a video.

Returns:

Icon representing the play button for a video.

Return type:

QtGui.QIcon

get_icon_pause_video()[source]

Returns a QIcon object representing the pause button for a video.

Returns:

Icon representing the pause button for a video.

Return type:

QtGui.QIcon

get_icon_resume_video()[source]

Returns a QIcon object representing the resume button for a video.

Returns:

Icon representing the resume button for a video.

Return type:

QtGui.QIcon

get_icon_rewind_video()[source]

Returns a QIcon object representing the rewind button for a video.

Returns:

Icon representing the rewind button for a video.

Return type:

QtGui.QIcon

get_icon_forward_video()[source]

Returns a QIcon object representing the forward button for a video.

Returns:

Icon representing the forward button for a video.

Return type:

QtGui.QIcon

get_icon_skip_rewind_video()[source]

Returns a QIcon object representing the skip backward button for a video.

Returns:

Icon representing the skip backward button for a video.

Return type:

QtGui.QIcon

get_icon_skip_forward_video()[source]

Returns a QIcon object representing the skip forward button for a video.

Returns:

Icon representing the skip forward button for a video.

Return type:

QtGui.QIcon

get_icon_zoom_in()[source]

Returns a QIcon object representing the zoom in button.

Returns:

Icon representing the zoom in button.

Return type:

QtGui.QIcon

get_icon_zoom_out()[source]

Returns a QIcon object representing the zoom out button.

Returns:

Icon representing the zoom out button.

Return type:

QtGui.QIcon

get_icon_rotate_ccw()[source]

Returns a QIcon object representing the rotate counterclockwise button.

Returns:

Icon representing the rotate counterclockwise button.

Return type:

QtGui.QIcon

get_icon_rotate_cw()[source]

Returns a QIcon object representing the rotate clockwise button.

Returns:

Icon representing the rotate clockwise button.

Return type:

QtGui.QIcon

get_icon_show()[source]

Returns a QIcon object representing the show button.

Returns:

Icon representing the show button.

Return type:

QtGui.QIcon

get_icon_mouse_pointer()[source]

Returns a QIcon object representing the mouse pointer icon.

Returns:

Icon representing the mouse pointer.

Return type:

QtGui.QIcon

get_icon_hide()[source]

Returns a QIcon object representing the hide button.

Returns:

Icon representing the hide button.

Return type:

QtGui.QIcon

get_icon_sun()[source]

Returns a QIcon object representing the sun icon.

Returns:

Icon representing the sun.

Return type:

QtGui.QIcon

get_icon_moon()[source]

Returns a QIcon object representing the moon icon.

Returns:

Icon representing the moon.

Return type:

QtGui.QIcon

get_icon_plus()[source]

Returns a QIcon object representing the plus icon.

Returns:

Icon representing the plus.

Return type:

QtGui.QIcon

get_icon_cross_x()[source]

Returns a QIcon object representing the cross or X icon.

Returns:

Icon representing the cross or X.

Return type:

QtGui.QIcon

get_icon_setting()[source]

Returns a QIcon object representing the settings icon.

Returns:

Icon representing the settings.

Return type:

QtGui.QIcon

get_icon_opened_folder()[source]

Returns a QIcon object representing an opened folder icon.

Returns:

Icon representing an opened folder.

Return type:

QtGui.QIcon

get_icon_trash()[source]

Returns a QIcon object representing the trash icon.

Returns:

Icon representing the trash.

Return type:

QtGui.QIcon

get_icon_text()[source]

Returns a QIcon object representing the text icon.

Returns:

Icon representing the text.

Return type:

QtGui.QIcon

get_icon_help()[source]

Returns a QIcon object representing the help icon.

Returns:

Icon representing the help.

Return type:

QtGui.QIcon

get_icon_info()[source]

Returns a QIcon object representing the info icon.

Returns:

Icon representing the info.

Return type:

QtGui.QIcon

get_icon_minus()[source]

Returns a QIcon object representing the minus icon.

Returns:

Icon representing the minus.

Return type:

QtGui.QIcon

Returns a QIcon object representing the link icon.

Returns:

Icon representing the link.

Return type:

QtGui.QIcon

get_icon_maximize_view()[source]

Returns a QIcon object representing the maximize view icon.

Returns:

Icon representing the maximize view.

Return type:

QtGui.QIcon

Returns a QIcon object representing the external link icon.

Returns:

Icon representing the external link.

Return type:

QtGui.QIcon

get_icon_default()[source]

Returns a QIcon object representing the default icon.

Returns:

Icon representing the default.

Return type:

QtGui.QIcon

get_icon_menu()[source]

Returns a QIcon object representing the menu icon.

Returns:

Icon representing the menu.

Return type:

QtGui.QIcon

get_icon_facebook()[source]

Returns a QIcon object representing the Facebook icon.

Returns:

Icon representing Facebook.

Return type:

QtGui.QIcon

get_icon_github()[source]

Returns a QIcon object representing the GitHub icon.

Returns:

Icon representing GitHub.

Return type:

QtGui.QIcon

get_icon_vlc()[source]

Returns a QIcon object representing the VLC icon.

Returns:

Icon representing VLC.

Return type:

QtGui.QIcon

get_pixmap_vlc()[source]

Returns a QPixmap object representing the VLC icon.

Returns:

Pixmap representing VLC.

Return type:

QtGui.QPixmap

get_icon_chevron_down_24px()[source]

Returns a QIcon object representing the chevron down icon in 24px size.

Returns:

Chevron down icon in 24px size.

Return type:

QtGui.QIcon

get_icon_chevron_down_12px()[source]

Returns a QIcon object representing the chevron down icon in 12px size.

Returns:

Chevron down icon in 12px size.

Return type:

QtGui.QIcon

get_icon_chevron_up_24px()[source]

Returns a QIcon object representing the chevron up icon in 24px size.

Returns:

Chevron up icon in 24px size.

Return type:

QtGui.QIcon

get_icon_chevron_up_12px()[source]

Returns a QIcon object representing the chevron up icon in 12px size.

Returns:

Chevron up icon in 12px size.

Return type:

QtGui.QIcon

get_icon_chevron_down_white_12px()[source]

Returns a QIcon object representing the white chevron down icon in 12px size.

Returns:

White chevron down icon in 12px size.

Return type:

QtGui.QIcon

get_icon_chevron_down_white_16px()[source]

Returns a QIcon object representing the white chevron down icon in 16px size.

Returns:

White chevron down icon in 16px size.

Return type:

QtGui.QIcon

get_icon_chevron_up_white()[source]

Returns a QIcon object representing the white chevron up icon.

Returns:

White chevron up icon.

Return type:

QtGui.QIcon

get_icon_camera_roll_white()[source]

Returns a QIcon object representing the white camera roll icon.

Returns:

White camera roll icon.

Return type:

QtGui.QIcon

get_icon_check_white()[source]

Return a QIcon object representing the white check icon.

Returns:

White check icon.

Return type:

QtGui.QIcon

get_icon_circle_white()[source]

Return a QIcon object representing the white circle icon.

Returns:

White circle icon.

Return type:

QtGui.QIcon

get_icon_opened_folder_white()[source]

Return a QIcon object representing the white opened folder icon.

Returns:

White opened folder icon.

Return type:

QtGui.QIcon

get_icon_loop_white()[source]

Return a QIcon object representing the white loop icon.

Returns:

White loop icon.

Return type:

QtGui.QIcon

get_icon_loop_circular_white()[source]

Return a QIcon object representing the white loop circular icon.

Returns:

White loop circular icon.

Return type:

QtGui.QIcon

get_icon_pause_video_white()[source]

Return a QIcon object representing the white pause video icon.

Returns:

White pause video icon.

Return type:

QtGui.QIcon

get_icon_play_video_white()[source]

Return a QIcon object representing the white play video icon.

Returns:

White play video icon.

Return type:

QtGui.QIcon

get_icon_rewind_video_white()[source]

Return a QIcon object representing the white rewind video icon.

Returns:

White rewind video icon.

Return type:

QtGui.QIcon

get_icon_forward_video_white()[source]

Return a QIcon object representing the white forward video icon.

Returns:

White forward video icon.

Return type:

QtGui.QIcon

get_icon_menu_white()[source]

Return a QIcon object representing the white menu icon.

Returns:

White menu icon.

Return type:

QtGui.QIcon

get_icon_cross_x_white()[source]

Return a QIcon object representing the white cross or X icon.

Returns:

White cross or X icon.

Return type:

QtGui.QIcon

Log Activity Models

The model_log_activity class is responsible for configuring logging settings and creating log files for the application

class models.model_log_activity.ModelLog(model)[source]

Bases: object

Class responsible for configuring logging settings and creating log files for the application.

Attribute:

_model (object): The main model instance of the application.

Method:

create_log_file(): Configures the logging settings and creates the log file.

create_log_file()[source]

Configures the logging settings and creates the log file.

This method sets up the format of log messages, the logging level, and the destination log file. If the application is reopening with an existing media source, it appends to the existing log file; otherwise, it creates a new log file. It also creates a logger instance for the application.

Moildev Models

This ModelMoildev module appears to be a part of an application responsible for managing connections to Moildev and handling image resolution options

class models.model_moildev.ModelMoildev(model)[source]

Bases: object

A class responsible for managing the Moildev connections and image resolution options.

_model

The main model instance of the application.

Type:

object

_main_config

The main configuration dictionary of the application.

Type:

dict

_moildev_main

The main Moildev connection object.

Type:

object

_moildev_pano_rec

The Moildev connection object for panorama reconstruction.

Type:

object

_moildev_recenter

The Moildev connection object for recentering.

Type:

object

_ratio_image_resize

List of predefined ratios for image resizing.

Type:

list

_resolution_option

List of available image resolution options.

Type:

list

_current_resolution_index

Index of the currently selected resolution option.

Type:

int

create_moildev()[source]

Creates a connection to Moildev based on the configuration view.

calculate_resolution_option()[source]

Calculates the image resolution options based on predefined ratios.

property moildev_main

Get the main Moildev instance.

Returns:

The main Moildev instance.

Return type:

Moildev

property moildev_pano_rt

Get the panorama rectification Moildev instance.

Returns:

The panorama rectification Moildev instance.

Return type:

Moildev

property moildev_recenter

Get the recenter Moildev instance.

Returns:

The recenter Moildev instance.

Return type:

Moildev

property resolution_option

Get the resolution options available.

Returns:

The list of resolution options.

Return type:

list

property current_resolution_index

Get the current resolution index.

Returns:

The current resolution index.

Return type:

int

create_moildev(resize_image_resolution=False)[source]

Creates a connection to Moildev based on the main configuration.

This function checks if there is a Parameter_name in self._main_config. If it exists, this function initializes the moildev objects using the method self._model.connect_to_moildev with the appropriate parameters. If resize_image_resolution is set to True, the image resolution will be adjusted using virtual_param_ratio.

The function also sets several main configuration attributes such as center_coord, Recenter_coordinate, pointer, width, and height based on the values obtained from the moildev object.

Parameters:

resize_image_resolution (bool) – Flag to determine whether to resize the image resolution.

Returns:

None

calculate_resolution_option()[source]

Calculates the image resolution options based on predefined ratios.

This method calculates the image resolution options by multiplying the main image width and height with predefined ratios. The resulting resolutions are stored in the _resolution_option attribute. This can be useful for providing users with various resolution choices for image resizing.

Note

The _ratio_image_resize attribute should contain the list of predefined ratios for resizing.

_ratio_image_resize

List of predefined ratios for image resizing.

Type:

list

Returns:

None

Save Image Models

This model_save_image module is responsible for managing the saving and handling of images in the MoilApp.

class models.model_save_image.ModelSave(model)[source]

Bases: object

Class responsible for saving images and managing saved image data.

_model

The main model instance of the application.

Type:

object

_pos_video_image_saved

A list to store the positions of frames saved from videos.

Type:

list

_load_saved_image

A flag indicating whether a saved image is being loaded.

Type:

bool

save_image_file()[source]

Save an image file to the specified directory and add metadata to the configuration view.

add_position_video_on_saved_image()[source]

Adds the current position of the video to the list of saved positions.

reopen_saved_image()[source]

Reopens a saved image file in the main application.

clear_saved_image()[source]

Clears the saved image data from the configuration view and updates the configuration file.

property pos_video_image_saved

Gets the position of the saved video image.

Returns:

The position of the saved video image.

property load_saved_image

Gets the status of whether a saved image is loaded.

Returns:

The status indicating if a saved image is loaded.

save_image_file(image, dst_directory, type_camera=None)[source]

Save an image file to the specified directory and add metadata to the configuration view.

Parameters:
  • image – A NumPy array containing the image data to be saved.

  • dst_directory – A string representing the destination directory to save the image file.

  • type_camera – An optional string representing the type of camera used to capture the image.

Returns:

A string representing the timestamp in the format “mmdd_HHMMSS” used in the saved image file name.

Raises:

None

add_position_video_on_saved_image()[source]

Adds the current position of the video to the list of positions.

If there is an active video, this method appends the current position of the video to the list of positions stored in the pos_video_image_saved attribute. This list can be used later to create a map of where images were saved in the video.

reopen_saved_image(parameter_name, file_name)[source]

Reopen saved image file

Parameters:
  • parameter_name

  • file_name

Returns:

clear_saved_image(config)[source]

Clear the saved image data from the configuration view and save the updated configuration to a file.

This method removes all saved image data from the configuration view and updates the configuration file with the modified view.

Parameters:
  • self – The object instance.

  • config

Returns:

None.

Raises:

IOError – An error occurred while writing the updated configuration to the file.

Stylesheet Models

This module defines the ModelStylesheet class, which is responsible for managing stylesheets for GUI components based on the theme mode.

class models.model_stylesheet.ModelStylesheet(model)[source]

Bases: object

A class responsible for managing stylesheets for GUI components based on the theme mode.

_model

The model instance associated with the stylesheet.

_theme

The theme mode of the model, which determines the stylesheets to be used.

Type:

str

__init__()[source]

Initializes the ModelStylesheet instance with a model instance and theme mode.

stylesheet_button_additional()[source]

Generates a stylesheet for additional QPushButton customization based on the provided state.

_stylesheet_pushbutton_light()[source]

Generates a light-themed stylesheet for QPushButton.

pushbutton_stylesheet()[source]

Generate a Qt stylesheet for QPushButton widgets based on the current theme.

Return a string representing the stylesheet to use for QPushButton widgets in the current theme. The style is different for “light” and “dark” themes. The returned string can be set as the style sheet of a QPushButton widget to apply the theme.

Returns:

A string representing the Qt stylesheet to use for QPushButton widgets in the current theme.

Return type:

str

pushbutton_play_pause_video_stylesheet()[source]

Generate a Qt stylesheet for QPushButton widgets based on the current theme.

Return a string representing the stylesheet to use for QPushButton widgets in the current theme. The style is different for “light” and “dark” themes. The returned string can be set as the style sheet of a QPushButton widget to apply the theme.

Returns:

A string representing the Qt stylesheet to use for QPushButton widgets in the current theme.

Return type:

str

label_stylesheet()[source]

Generate a Qt stylesheet for QLabel widgets based on the current theme.

Return a string representing the stylesheet to use for QLabel widgets in the current theme. The style is different for “light” and “dark” themes. The returned string can be set as the style sheet of a QLabel widget to apply the theme.

Returns:

A string representing the Qt stylesheet to use for QLabel widgets in the current theme.

Return type:

str

label_title_stylesheet()[source]

Generate a Qt stylesheet for QLabel widgets based on the current theme.

Return a string representing the stylesheet to use for QLabel widgets in the current theme. The style is different for “light” and “dark” themes. The returned string can be set as the style sheet of a QLabel widget to apply the theme.

Returns:

A string representing the Qt stylesheet to use for QLabel widgets in the current theme.

Return type:

str

transparent_label_stylesheet()[source]

Generate a Qt stylesheet for QLabel widgets based on the current theme.

Return a string representing the stylesheet to use for QLabel widgets in the current theme. The style is different for “light” and “dark” themes. The returned string can be set as the style sheet of a QLabel widget to apply the theme.

Returns:

A string representing the Qt stylesheet to use for QLabel widgets in the current theme.

Return type:

str

frame_main_stylesheet()[source]

Generate a Qt stylesheet for QLabel widgets based on the current theme.

Return a string representing the stylesheet to use for QLabel widgets in the current theme. The style is different for “light” and “dark” themes. The returned string can be set as the style sheet of a QLabel widget to apply the theme.

Returns:

A string representing the Qt stylesheet to use for QLabel widgets in the current theme.

Return type:

str

font_12_stylesheet()[source]

Generate a Qt stylesheet for QFont with 12pt size based on the current theme.

Returns:

A string representing the Qt stylesheet to use for QFont with 12pt size in the current theme.

Return type:

str

font_14_stylesheet()[source]

Generate a Qt stylesheet for QFont with 14pt size based on the current theme.

Returns:

A string representing the Qt stylesheet to use for QFont with 14pt size in the current theme.

Return type:

str

frame_object_stylesheet()[source]

Generate a Qt stylesheet for QLabel widgets based on the current theme.

Return a string representing the stylesheet to use for QLabel widgets in the current theme. The style is different for “light” and “dark” themes. The returned string can be set as the style sheet of a QLabel widget to apply the theme.

Returns:

A string representing the Qt stylesheet to use for QLabel widgets in the current theme.

Return type:

str

frame_transparent_stylesheet()[source]

Generate a Qt stylesheet for a transparent frame based on the current theme.

Returns:

A string representing the Qt stylesheet to use for a transparent frame in the current theme.

Return type:

str

line_stylesheet()[source]

Generate a Qt stylesheet for a line widget based on the current theme.

Returns:

A string representing the Qt stylesheet to use for a line widget in the current theme.

Return type:

str

combobox_stylesheet()[source]

Return the Qt stylesheet for a QComboBox widget, based on the current theme.

Arg:

self: The object that this method belongs to.

Returns:

A string containing the Qt stylesheet for the QComboBox widget, based on the current theme.

scroll_area_stylesheet()[source]

Generate a Qt stylesheet for a scroll area widget based on the current theme.

Returns:

A string representing the Qt stylesheet to use for a scroll area widget in the current theme.

Return type:

str

radio_button_stylesheet()[source]

Generate a Qt stylesheet for a radio button widget based on the current theme.

Returns:

A string representing the Qt stylesheet to use for a radio button widget in the current theme.

Return type:

str

slider_stylesheet()[source]

Generate a Qt stylesheet for a slider widget based on the current theme.

Returns:

A string representing the Qt stylesheet to use for a slider widget in the current theme.

Return type:

str

checkbox_stylesheet()[source]

Generate a Qt stylesheet for a checkbox widget based on the current theme.

Returns:

A string representing the Qt stylesheet to use for a checkbox widget in the current theme.

Return type:

str

spinbox_stylesheet()[source]

Generate a Qt stylesheet for a spin box widget based on the current theme.

Returns:

A string representing the Qt stylesheet to use for a spin box widget in the current theme.

Return type:

str

double_spinbox_stylesheet()[source]

Generate a Qt stylesheet for a double spin box widget based on the current theme.

Returns:

A string representing the Qt stylesheet to use for a double spin box widget in the current theme.

Return type:

str

line_edit_stylesheet()[source]

Generate a Qt stylesheet for a line edit widget based on the current theme.

Return:

str: A string representing the Qt stylesheet to use for a line edit widget in the current theme.

classmethod stylesheet_button_additional(state='install')[source]

Generate a stylesheet for additional QPushButton customization based on the provided state.

Parameters:
  • cls – The class itself.

  • state (str) – The state of the QPushButton. Possible values are “install”, “None”, or any other state.

Returns:

The generated stylesheet for the specified state.

Return type:

str

Raises:

ValueError – If the provided state is not one of the supported values.

Video Control Models

This model_video_control module manages the configuration and settings related to video processing in the MoilApp

class models.model_video_control.ModelVideoConfig(model)[source]

Bases: object

Class responsible for configuring and managing video settings.

_model

The main model instance of the application.

Type:

object

_fps_video

Frames per second of the video.

Type:

float

_image

The current frame of the video.

Type:

numpy.ndarray

_total_frame_video

Total number of frames in the video.

Type:

float

_pos_frame_video

Current position of the frame in the video.

Type:

float

_video_time

List containing total and recent time information of the video.

Type:

list

record_video_pressed()[source]

Configures video recording settings based on user input.

calculate_frame_video()[source]

Calculates video frame information such as FPS, total frames, and current position.

property fps_video

Getter for the FPS (frames per second) of the video.

Returns:

The FPS of the video.

Return type:

float

property total_frame_video

Getter for the total number of frames in the video.

Returns:

The total number of frames in the video.

Return type:

int

property pos_frame_video

Getter for the position of the current frame in the video.

Returns:

The position of the current frame in the video.

Return type:

int

property video_time

Getter for the total time duration of the video.

Returns:

The total time duration of the video.

Return type:

float

record_video_pressed(record_option)[source]

Configure video recording settings based on user input.

Arg:

record_option (str): The record option selected by the user.

Returns:

The video writer object for recording.

Return type:

cv2.VideoWriter

calculate_frame_video(video_source)[source]

Calculate video frame information such as FPS, total frames, and current position.

Arg:

video_source: The video source.

View Anypoint Models

This model_view_anypoint module manages the Anypoint view settings and operations within the MoilApp

class models.model_view_anypoint.ModelViewAnypoint(model)[source]

Bases: object

Class responsible for managing Anypoint view settings and operations.

_model

The main model instance of the application.

Type:

object

_map_x_anypoint

Map for the x-coordinate transformation in Anypoint view.

Type:

numpy.ndarray

_map_y_anypoint

Map for the y-coordinate transformation in Anypoint view.

Type:

numpy.ndarray

_anypoint_mode

Current Anypoint mode.

Type:

str

anypoint_mode.setter()

Setter method for the current Anypoint mode.

maps_anypoint()

Getter method for the Anypoint maps.

image_anypoint(image)[source]

Transforms the image using the Anypoint maps.

create_maps_anypoint_mode_1()[source]

Creates Anypoint maps for mode 1 based on the configuration file.

create_maps_anypoint_mode_2()[source]

Creates Anypoint maps for mode 2 based on the configuration file.

set_alpha_beta(alpha, beta)[source]

Sets the values of alpha and beta and updates the configuration file.

property anypoint_mode

Get the current mode for Anypoint transformation.

Returns:

The current mode for Anypoint transformation.

Return type:

str

property maps_anypoint

Get the Anypoint maps.

Returns:

A tuple containing the X and Y Anypoint maps.

Return type:

tuple

image_anypoint(image)[source]

Apply Anypoint transformation to the given image.

Parameters:

image – The image to be transformed.

Returns:

The transformed image.

create_maps_anypoint_mode_1()[source]

Creates maps for anypoint mode 1 based on the configuration file.

If the configuration file exists, the function loads the alpha, beta, and zoom values for mode 1 from the configuration file. It then uses the loaded values to create the maps for anypoint mode 1 using the moildev.maps_anypoint_mode1() method. If the moildev attribute is not None, the function also creates an image result using the create_image_result() method.

Returns:

None.

create_maps_anypoint_mode_2()[source]

Creates maps for anypoint mode 2 based on the configuration file.

If the configuration file exists, the function loads the pitch, yaw, roll, and zoom values for mode 2 from the configuration file. It then uses the loaded values to create the maps for anypoint m)ode 2 using the moildev.maps_anypoint_mode2() method. If the moildev attribute is not None, the function also creates an image result using the create_image_result() method.

Returns:

None.

set_alpha_beta(alpha, beta)[source]

Set the values of alpha and beta and update the configuration file.

Parameters:
  • alpha (float) – the alpha value to set.

  • beta (float) – the beta value to set.

Returns:

None.

View Panorama Models

This model_view_panorama module handles Panorama view settings and operations within the MoilApp

class models.model_view_panorama.ModelViewPanorama(model)[source]

Bases: object

Class responsible for managing Panorama view settings and operations.

_model

The main model instance of the application.

Type:

object

_map_x_pano

Map for the x-coordinate transformation in Panorama view.

Type:

numpy.ndarray

_map_y_pano

Map for the y-coordinate transformation in Panorama view.

Type:

numpy.ndarray

_panorama_mode

Current Panorama mode.

Type:

str

panorama_mode.setter()

Setter method for the current Panorama mode.

maps_panorama()

Getter method for the Panorama maps.

panorama_image(image)[source]

Transforms the image using the Panorama maps.

get_cr_left_right_panorama_car(pano_car)[source]

Calculates the left and right coordinates of the panorama car.

crop_panorama_car(image)[source]

Crops the input image for the panorama car feature.

create_maps_panorama_car()[source]

Creates Panorama maps for the car feature based on the configuration file.

image_car_with_color_polygon()[source]

Creates an image of the car with polygon color drawing.

create_maps_panorama_tube()[source]

Creates Panorama maps for the tube feature based on the configuration file.

crop_panorama_tube(image)[source]

Crops the input image for the panorama tube feature.

property panorama_mode

Get the current mode for panorama transformation.

Returns:

The current mode for panorama transformation.

Return type:

str

property maps_panorama

Get the panorama maps.

Returns:

A tuple containing the X and Y panorama maps.

Return type:

tuple

panorama_image(image)[source]

Apply panorama transformation to the given image.

Arg:

image: The image to be transformed.

Returns:

The transformed image.

classmethod get_cr_left_right_panorama_car(pano_car)[source]

Calculate the left and right coordinates of the panorama car in the image.

This method identifies the left and right coordinates of the panorama car in the given image. It searches for pixels with the color [0, 255, 0] and collects their x-coordinates to determine the left and right boundaries of the car.

Arg:

pano_car: The input image of the panorama car.

Returns:

Left and right coordinates of the panorama car.

Return type:

cr_left_car_color, cr_right_car_color

crop_panorama_car(image)[source]

Crop the input image for the panorama car feature.

This method crops the input image for the panorama car feature using the cropping parameters defined in the configuration file loaded through the private method __load_config(). It resizes the image to twice its original width, then crops the image using the crop_left, crop_right, crop_top, and crop_bottom parameters. The resulting image is then returned.

Arg:

image: The input image to be cropped.

Returns:

The cropped image.

create_maps_panorama_car()[source]

Create maps x and y images for panorama car feature.

This method creates the map x and map y images needed for the panorama car feature using the parameters from the configuration file. It sets the generated maps to the respective attributes.

Returns:

None

image_car_with_color_polygon()[source]

Create image of car with color polygon drawing.

This method creates an image of the car with polygon color drawing. It draws a polygon on the resized image using the FOV maps and then remaps the image to the panorama view.

Returns:

None

create_maps_panorama_tube()[source]

Create the map images for the panorama tube feature.

This method creates the map images for the panorama tube feature using the MOIL SDK. If the configuration file exists, it retrieves the minimum and maximum alpha values for the tube from the configuration file using the private method __load_config(). If the MOIL device object is not None, this method creates the map images for the panorama tube feature using the alpha values and sets the image result.

Returns:

None.

crop_panorama_tube(image)[source]

Crop the top and bottom of the input image based on configuration values.

This method crops the top and bottom of the input image based on configuration values for the panorama tube feature. The crop values are retrieved from the configuration file using the private method load_config(). The cropped image is then returned.

Arg:

image: The input image to crop.

Returns:

The cropped image.

View Properties Models

The model_view_properties module manages view properties such as zooming and rotation within the MoilApp

class models.model_view_properties.ModelViewProperties(model)[source]

Bases: object

Class responsible for managing view properties such as zooming and rotation.

_model

The main model instance of the application.

Type:

object

_current_size

Current zoom size.

Type:

int

_rotate_original

Rotation degree for the original image.

Type:

int

_rotate_result

Rotation degree for the result image.

Type:

int

zooming_size()

Getter and setter method for the zoom size.

rotate_degree()

Getter and setter method for the rotation degree of the result image.

zoom_in()[source]

Increases the current zoom size by 100.

zoom_out()[source]

Decreases the current zoom size by 100.

percentage_zoom(value)[source]

Determines the closest zoom percentage to the given value.

rotate_left()[source]

Rotates the result image to the left by 5 degrees.

rotate_right()[source]

Rotates the result image to the right by 5 degrees.

change_rotate_value(value)[source]

Changes the rotation degree value for the result image.

change_rotation_original_value(value)[source]

Changes the rotation degree value for the original image.

property zooming_size

Get the current zooming size.

Returns:

The current zooming size.

property rotate_degree

Get the current rotation degree.

Returns:

The current rotation degree.

zoom_in()[source]

Increase the current size by 100 and returns the new size.

Returns:

The new size after increasing by 100.

Return type:

int

zoom_out()[source]

Decrease the current_size by 100, unless it’s already below 640.

Returns:

The new size after decreasing by 100, or the original current_size if it’s already below 640.

Return type:

int

percentage_zoom(value)[source]

Determine the closest zoom percentage to the given value.

This method calculates the closest zoom percentage from a predefined list to the given value. It updates the current size attribute with the closest zoom percentage.

Arg:

value (int): The desired zoom percentage value.

Returns:

None

rotate_left()[source]

Rotate the image to the left by 5 degrees.

Returns:

The new angle of rotation after rotating left by 5 degrees.

Return type:

int

rotate_right()[source]

Rotate the given angle to the right by 5 degrees.

Returns:

The new angle after rotation to the right.

Return type:

int

change_rotate_value(value)[source]

Change the rotate degree value for the result image.

This method updates the rotation degree value for the result image.

Arg:

value (int): The rotation degree value.

Returns:

None

change_rotation_original_value(value)[source]

Change the rotation degree value for the original image.

This method updates the rotation degree value for the original image.

Arg:

value (int): The rotation degree value.

Returns:

None

View Recenter Models

The model_view_recenter module is responsible for managing the recenter of the image within the MoilApp

class models.model_view_recenter.ModelRecenter(model)[source]

Bases: object

Class responsible for managing recentering of the image.

_model

The main model instance of the application.

Type:

object

_moildev

The MOIL device instance.

Type:

object

_maps_recenter

List to store recenter maps.

Type:

list

maps_recenter()

Getter method for the recenter maps.

create_maps_recenter()[source]

Create maps for recentering the image.

property maps_recenter

Get the maps for recentering.

Returns:

A tuple containing the X and Y maps for recentering.

Return type:

tuple

create_maps_recenter()[source]

Create maps for recentering the image.

This method creates the maps for recentering the image based on the current recenter coordinates.

Zoom Area Models

The model_zoom_area module manages the zoom area selection within the MoilApp.

class models.model_zoom_area.ModelZoomArea(model)[source]

Bases: object

Class responsible for managing the zoom area selection.

_model

The main model instance of the application.

Type:

object

_state_rubberband

State of the rubberband.

Type:

bool

_size_zoom

Size of the zoom area.

Type:

bool

_size_rubberband

Size of the rubberband.

Type:

QRect

_point_rectangle

List to store points defining the zoom area rectangle.

Type:

list

point_rectangle()

Getter method for the points defining the zoom area rectangle.

state_rubberband()

Getter and setter methods for the state of the rubberband.

size_rubberband()

Getter and setter methods for the size of the rubberband.

size_zoom()

Getter and setter methods for the size of the zoom area.

crop_image(image_ori)[source]

Crop the image based on the zoom area selection.

property point_rectangle

Getter for the points defining the zoom area rectangle.

property state_rubberband

Getter for the state of the rubberband.

property size_rubberband

Getter for the size of the rubberband.

property size_zoom

Getter for the size of the zoom area.

crop_image(image_ori)[source]

Crop the image based on the zoom area selection.

This method crops the input image based on the zoom area selection using the rubberband’s size and position.

Arg:

image_ori: The original image to be cropped.

Returns:

The cropped image.

Screen Capture Thread

This module provides functionality for screen recording and updating labels.

Classes:

Worker: Worker class responsible for screen recording and updating labels. UpdaterImage: Class for updating images.

models.thread_screen_capture.None
class models.thread_screen_capture.Worker[source]

Bases: QObject

Worker class responsible for screen recording and updating labels.

get_image

Signal for sending images.

Type:

pyqtSignal

__init__()[source]

Initialize the Worker.

initialize_record_screen()[source]

Initializes the screen recording.

record_state()

Getter and setter methods for the recording state.

get_event()[source]

Stores the given event position.

update_label()[source]

Updates the label with the current screen image.

qt_pixmap_to_cv_img()[source]

Converts a QPixmap object to a numpy array.

main()[source]

The main function of the Worker class.

Initialize the Worker.

This method initializes the Worker class with default values for its attributes. It also grabs the primary screen and sets the size of the recording window.

get_image

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

initialize_record_screen()[source]

Initializes the screen recording by creating a VideoWriter object.

If the VideoWriter object has not been created yet, this function creates it and sets the output video file path and codec. If the directory to store the recorded file does not exist, it will create it.

property record_state

A getter method for the private variable __record.

Returns:

The current state of the recording (True for active, False for inactive).

Return type:

bool

get_event(event)[source]

Stores the given event position.

Parameters:

event (QPoint) – The QPoint object containing the event position.

update_label()[source]

Updates the label with the current screen image.

If recording is active, it writes the current screen image to the output video file.

classmethod qt_pixmap_to_cv_img(qt_pixmap)[source]

Converts a QPixmap object to a numpy array.

Parameters:

qt_pixmap (QPixmap) – The QPixmap object to convert.

Returns:

The converted image as a numpy array.

Return type:

numpy.ndarray

main()[source]

The main function of the VideoRecorder class.

Initializes the QTimer object and sets the interval to 1/30 of a second. Connects the QTimer object to the update_label function.

class models.thread_screen_capture.UpdaterImage[source]

Bases: object

Class responsible for updating images.

thread

The thread for running the worker.

Type:

QThread

worker

The worker responsible for image updating.

Type:

Worker

__init__()[source]

Initializes the UpdaterImage.