API References
Controller Package
Main Controller
This module contains the Controller class, which serves as the main controller for the Moilapps application. The Controller class initializes the user interface, connects signals to their corresponding slots, handles keyboard and mouse events, and manages the application’s view modes and settings.
The Controller class imports several other modules and classes to fulfill its functionality, including UI elements, control classes for various features, and models for data management.
- class controllers.control_main.Controller(*args: Any, **kwargs: Any)[source]
Bases:
QMainWindow
The Controller class serves as the main controller for the Moilapps application. It initializes the user interface, connects signals to their corresponding slots, handles keyboard and mouse events, and manages the application’s view modes and settings.
- ui_object
An instance of the user interface object.
- Type:
object
- model
An instance of the ModelApps class for data management.
- Type:
object
- _stylesheet
An instance of the ControlStyleSheet class for managing stylesheets.
- Type:
object
- cap
Video capture object for handling media files.
- Type:
object
- image_original
Original image object.
- Type:
object
- ctrl_panel_page
Instance of the ControlPanelPage class for managing panel pages.
- Type:
object
- ctrl_stylesheet
Instance of the ControlStyleSheet class for managing stylesheets.
- Type:
object
- ctrl_fullscreen
Instance of the ControlViewFullscreen class for managing fullscreen mode.
- Type:
object
- ctrl_screen_record
Instance of the ScreenRecord class for managing screen recording.
- Type:
object
- ctrl_icon
Instance of the ConfigIconUI class for configuring icons.
- Type:
object
- ctrl_theme
Instance of the ControlThemeApps class for managing application themes.
- Type:
object
- ctrl_message_box
Instance of the ControlMessageBox class for managing message boxes.
- Type:
object
- ctrl_main_config
Instance of the AppConfigManager class for managing application configurations.
- Type:
object
- ctrl_plugin
Instance of the PluginManager class for managing plugins.
- Type:
object
- ctrl_github
Instance of the ControllerGitHub class for managing GitHub integration.
- Type:
object
- ctrl_save_media
Instance of the SaveMedia class for managing saved media.
- Type:
object
- ctrl_mouse_event
Instance of the MouseEvent class for managing mouse events.
- Type:
object
- view_recenter
Instance of the RecenterConfig class for managing view recentering.
- Type:
object
- view_fisheye
Instance of the ControlImageFisheye class for managing fisheye view.
- Type:
object
- view_anypoint
Instance of the AnypointConfig class for managing anypoint view.
- Type:
object
- view_panorama
Instance of the PanoramaConfig class for managing panorama view.
- Type:
object
- view_zoom
Instance of the ControlViewZoom class for managing zoom view.
- Type:
object
- view_rotate
Instance of the ControlViewRotate class for managing rotate view.
- Type:
object
- ctrl_img_result
Instance of the ControlImageResult class for managing image results.
- Type:
object
- ctrl_img_ori
Instance of the ControlImageOriginal class for managing original images.
- Type:
object
- timer
QTimer object for managing timing events.
- Type:
object
- ctrl_media_player
Instance of the VideoController class for managing media playback.
- Type:
object
- ctrl_recent_project
Instance of the RecentOpen class for managing recent projects.
- Type:
object
- onclick_change_state_debug()[source]
Toggles the debug mode state when the debug button is clicked.
- escape_event()[source]
Handles the escape button keyboard event, returning the application to its default state.
- initial_setup_view()[source]
Sets up the initial view mode based on the moilapp’s mode_view attribute.
- connect_signals()[source]
Connects signals to their corresponding slots in the user interface.
Signals include button clicks, key shortcuts, checkbox state changes, and menu toggling. Each signal is connected to a specific method or action to be performed in response.
- Returns:
None
- moveEvent(event)[source]
Moves the screen image worker to the position specified by the given event.
- Parameters:
event – A PyQt event containing information about the new position of the screen image worker.
- Returns:
The return value of the super() method for the same event.
- Raises:
N/A –
- onclick_change_state_debug()[source]
Toggles the debug mode state when the debug button is clicked.
If the debug mode is active, debug logging is enabled, and the button text is set to “Debug ON”. If the debug mode is inactive, debug logging is disabled, and the button text is set to “Debug OFF”.
- Returns:
None
- keyPressEvent(event)[source]
Handles key press events for keyboard shortcuts and special keys.
Activates different actions based on the key pressed and any modifiers. Supported shortcuts include toggling fullscreen with F11, handling escape events, and displaying message boxes for saving images or accessibility information.
- Arg:
event: The key press event object.
- Returns:
None
- escape_event()[source]
Handles the escape button keyboard event, returning the application to its default state.
When the escape button is pressed, this method closes any open menus, resets the panel page, and exits the rubber band zoom mode if active.
- Returns:
None
- initial_setup_view()[source]
Sets up the initial view mode based on the moilapp’s mode_view attribute.
Depending on the mode_view attribute, this method styles the corresponding button in the user interface to indicate the selected view mode. It then triggers the appropriate method to initialize the view settings and display the image accordingly.
- Returns:
None
- onclick_handle_open_media_button()[source]
Prompts the user to select a media source and loads it into the app. If a file is selected, updates the model with the media source and parameter name, and updates the UI accordingly. If there is an existing result image, prompts the user for confirmation before changing the media source.
- prompt_change_media_source()[source]
Prompts the user to confirm changing the media source.
Displays a confirmation message to the user asking if they want to change the media source. If the user confirms, the method proceeds to load the new media source.
- Returns:
None
- load_media_source()[source]
Prompt the user to confirm changing the media source.
Display a confirmation message to the user asking if they want to change the media source. If the user confirms, the method proceeds to load the new media source.
- Returns:
None
- update_model_and_create_original_image(source_type, cam_type, source_media, parameter_name)[source]
Updates the model configuration and creates the original image.
Update the main configuration attributes with the provided parameters, saves the updated configuration, processes the data configuration, and retrieves the list of recent projects.
- Arg:
source_type (str): The type of media source. cam_type (str): The type of camera. source_media (str): The path to the media source. parameter_name (str): The name of the parameter.
- Returns:
None
- adding_resolution_option()[source]
Add resolution options to the user interface.
Retrieves resolution options from the Moildev instance and populates the resolution combo box in the user interface with the available options.
- Returns:
None
- change_resolution_sources()[source]
Change the resolution sources based on the selected option from the combo box.
Updates the current resolution index in the Moildev instance, changes the resolution of the original image, recalculates label ratios, and updates the main configuration with the new resolution settings. It then performs the initial setup of the view.
- Returns:
None
- media_next_frame_signal()[source]
Proces the next frame for video processing.
Reads the next frame from the video capture device, calculates frame information, updates the video player, creates the image result, and displays the image to the user interface. If recording is enabled, writes the frame to the output video file.
- Returns:
None
- display_image_to_ui()[source]
Display the image to the user interface.
Create and display either the original image or the result image, depending on the current state of the application.
- Returns:
None
- showing_new_window_full_screen()[source]
Display a new window in full-screen mode.
Hide the current window, shows a new window maximized to full screen, sets the full-screen mode flag, and creates the image result.
- Returns:
None
Handle the click event of the setting menu button.
If the setting menu is inactive, it displays the setting menu and switches the current index of the stacked widget to either the side view setting or recent project view. If the setting menu is active, it toggles between the current index of the stacked widget.
- Arg:
index (int): The index of the stacked widget to switch to.
- Returns:
None
- onclick_open_about_us()[source]
Handle the click event of the ‘About Us’ button.
Display the ‘About Us’ page in the setting menu.
- Returns:
None
- back_to_home()[source]
Switch the content view to home screen and hides plugin buttons and sets the plugin index to None.
- onclick_help_button()[source]
Handle the click event of the help button.
Display an informational message box indicating that the help menu is still under development.
- Returns:
None
- onclick_clear_user_interface()[source]
Reset the user interface to its default state.
This method stop the timer, resets various model and UI attributes to their default values, and hides certain UI elements. It also clears the saved image list and resets the styles of specific UI buttons.
- reset_view_back_to_original()[source]
Reset the view back to the original state.
This method reset the view back to its original state, particularly when the user clicks on the “Back to Original” button. It hides certain UI elements and resets various attributes related to the view.
- read_the_documentation()[source]
Open the HTML documentation for this project in a new browser tab.
- Returns:
None
GitHub Controller
This module contains the ControllerGitHub class responsible for handling GitHub-related functionalities in the MoilApp application.
- Class:
- ControllerGitHub: Handles GitHub-related functionalities such as refreshing repository information,
changing branches, committing changes, checking for updates, etc.
- class controllers.control_github.ControllerGitHub(controller)[source]
Bases:
object
This class handles GitHub-related functionalities in the MoilApp application.
- _controller
The controller instance.
- _model
The model instance.
- _ui_object
The UI object instance.
- _ctrl_main_config
The main configuration controller instance.
- _github_config
The GitHub configuration from the main configuration.
- _github_repo
The GitHub repository associated with the application’s model.
- _show_message_box
A method to display message boxes.
- _showing_github_repository_information(self)[source]
Updates the UI with information about the GitHub repository.
- _show_info_update_in_github_repository(self)[source]
Fetches and displays information about commits behind the active branch.
- open_dialog_for_input_token(self)[source]
Displays a dialog box to prompt the user for a GitHub token.
Image Original Controller
This module contains the ControlImageOriginal class, which provides methods for creating and displaying original images in a user interface, along with applying optional modifications based on different view modes and checkbox states. It facilitates functionalities such as adding crosshairs, drawing polygons, and displaying recentered images based on user interactions.
- class controllers.control_image_original.ControlImageOriginal(controller)[source]
Bases:
object
This class provides methods for creating and displaying original images in a user interface, along with applying optional modifications based on different view modes and checkbox states. It facilitates functionalities such as adding crosshairs, drawing polygons, and displaying recentered images based on user interactions.
- _controller
The controller object responsible for managing the application flow.
- _model
The model object containing application data and logic.
- _main_config
Configuration settings for the main application.
- _icx
X-coordinate of the image center.
- _icy
Y-coordinate of the image center.
- _ui_object
User interface object containing UI elements.
- create_image_original()[source]
Creates and displays the original image in the user interface with optional modifications.
- _display_image_in_label_original(image)[source]
Displays the image in the original label with optional modifications.
- create_image_original()[source]
Create and display the original image in the user interface, with optional modifications.
Modifies the original image based on the view mode and checkbox states, such as adding a crosshair or drawing polygons. If ‘Reverse View’ is checked, additional adjustments are made, including displaying a recentered image and drawing polygons for specific view modes.
- Returns:
None
Image Result Controller
This module contains the ControlImageResult class, which provides methods for applying the current view mode to an image and displaying the resulting image in the UI. It handles functionalities such as applying remapping for ‘AnypointView’ and ‘PanoramaView’, as well as zooming and cropping based on user interaction.
- class controllers.control_image_result.ControlImageResult(controller)[source]
Bases:
object
This class provides methods for applying the current view mode to an image and displaying the resulting image in the UI. It handles functionalities such as applying remapping for ‘AnypointView’ and ‘PanoramaView’, as well as zooming and cropping based on user interaction.
- _controller
The controller object responsible for managing the application flow.
- _ui_object
User interface object containing UI elements.
- _model
The model object containing application data and logic.
- _display_image
Function for displaying an image to a label in the UI.
Media Player Controller
This module provides a VideoController class responsible for controlling video playback in a PyQt6 application. It handles events such as play/pause, stop, rewind, and forward, as well as updating the video timer and slider position. The VideoController interacts with the PyQt6 GUI elements and the underlying video model to manage video playback functionalities.
- class controllers.control_media_player.VideoController(controller)[source]
Bases:
object
This class manages the control logic for video playback in a PyQt6 application. It handles events such as play/pause, stop, rewind, and forward, as well as updating the video timer and slider position. The VideoController interacts with the PyQt6 GUI elements and the underlying video model to coordinate video playback functionalities.
- _controller
The controller object managing the application.
- _model
The model object containing application data and settings.
- _model_video_control
The video configuration model containing video-specific settings.
- _ui_object
The user interface object containing PyQt6 elements.
- check_active_play_pause_button()[source]
Checks the state of the play/pause button and updates its icon accordingly.
- show_timer_video_info()[source]
Update the video timer labels with the given time values.
This method takes a list parameter, list_timer, that contains four values representing the current and total times of the video in minutes and seconds. The current time is displayed in the label_current_time label, and the total time is displayed in the label_total_time label.
- set_slider_video_time_position()[source]
Set the value of a slider widget based on the current position of a video.
If a video is loaded, this function calculates the current time position as a percentage of the total duration and emits a signal with the corresponding value to update a slider widget. If no video is loaded, the function does nothing.
- set_slider_position(value)[source]
Set the position of the video slider.
This method takes a float parameter, value, that represents the position of the video slider. The slider is updated to the given value, and the blockSignals method is used to prevent signals from being emitted during the update.
Message Box Controller
This module contains the ControlMessageBox class which provides functionality for displaying various types of message boxes in the MoilApp application.
- class controllers.control_message_box.ControlMessageBox(main_controller)[source]
Bases:
object
ControlMessageBox class provides functionality for displaying various types of message boxes in the MoilApp application.
- display_ask_confirmation(message)[source]
Display a confirmation message box with the given message.
- Arg:
message (str): The message to display in the confirmation box.
- Returns:
True if the user clicks Yes, False if the user clicks No.
- Return type:
bool
- display_message_box(message='Default Message!', type_mode='information')[source]
Display a message box with the given message and type.
- Parameters:
message (str) – The message to display in the message box. Defaults to “Default Message!”.
type_mode (str) – The type of message box to display. Should be either “information” or “warning”. Defaults to “information”.
- show_update_dialog(message)[source]
Display a message box with options for the user to choose.
- Arg:
message: A string containing the message to be displayed in the message box.
- Returns:
An integer representing the user’s response to the message box.
- show_message_box_record()[source]
Display a message box for selecting the recording option (Original or Processed Video).
- Returns:
None
- show_message_box_save_image()[source]
Display a message box for selecting the save option (Original or Processed Video).
- Returns:
None
- record_original_video()[source]
Set the recording option to “Original” and logs the action if debug mode is enabled.
- Returns:
None
- record_processed_video()[source]
Set the recording option to “Processed” and logs the action if debug mode is enabled.
- Returns:
None
- record_cancel()[source]
Cancel the recording process by setting the recording option to None and logs the action if debug mode is enabled.
- Returns:
None
- show_information_of_image(label)[source]
Display information about the current image view.
Display a message box with information about the current image view, including whether it is a fisheye, anypoint, or panorama view. If the current view has a polygon drawn on it, the message box will indicate that the polygon is being shown and the user can change the ROI by clicking on the image.
If the application is in zooming mode to view a specific ROI, a message box will be displayed indicating that the user should close the preview or press ‘Esc’ on the keyboard to return.
- Arg:
label (str): The label of the current image view.
Mouse Event Controller
- class controllers.control_mouse_event.MouseEvent(controller)[source]
Bases:
object
- mouse_event_in_moil_logo(event)[source]
Handle mouse events in the Moil logo.
- Parameters:
event – The mouse event.
- label_original_mouse_release_event(event)[source]
Handle mouse release events on the original image label.
- Arg:
event: The mouse event.
- label_original_mouse_move_event(event)[source]
Handle mouse move events on the original image label.
- Arg:
event: The mouse event.
- label_original_mouse_press_event(event)[source]
Handle mouse press events on the original image label.
- Arg:
event: The mouse event.
- label_original_mouse_leave_event(event)[source]
Handle the mouse leave event on the original image label.
This method is called when the mouse leaves the original image label in the UI. It delegates the handling of the event to the model_apps instance of the Model class.
- label_original_mouse_double_click_event(event)[source]
Handle the mouse double-click event for the label_original widget, which displays the original fisheye image.
If the current view mode is AnypointView, calls the corresponding model_apps method and displays the corresponding view_anypoint UI widget.
- label_result_mouse_double_click(event)[source]
Handle mouse double-click events on the result label.
- Arg:
event: The mouse event.
- label_result_mouse_press_event(event)[source]
Handle the mouse press event on the result image label.
- Arg:
event: A QMouseEvent object representing the mouse press event.
- Returns:
None.
Note
This function is responsible for creating and showing a rubberband when the left mouse button is pressed on the result image label. The rubberband is used to select a specific region of interest (ROI) in the image.
- label_result_mouse_move_event(event)[source]
Handle mouse move events on the result label.
- Arg:
event: A QMouseEvent instance representing the mouse move event.
- Returns:
None.
- label_result_mouse_release_event(event)[source]
Handle the mouse release event on the label_result widget.
If the left mouse button was released and an image is loaded, the size of the rubberband is checked. If it has a width and height greater than 20 pixels and the state of the rubberband is False, the size of the rubberband is stored in the model’s size_rubberband attribute, the state of the rubberband is set to True, and a new image result is created. The rubberband is then hidden. If the right mouse button is released, the menu_mouse_event method is called with the event object and the string “label_result” as arguments.
Show a context menu on the mouse event with options for the specified label.
- Parameters:
event – A QMouseEvent object containing information about the mouse event.
label – A string indicating the label type, either “label_result” or “label_original”.
- label_recenter_mouse_press_event(event)[source]
Handle mouse press events on the recenter label.
- Arg:
event: The mouse event.
- label_recenter_mouse_move_event(event)[source]
Handle mouse move events on the recenter label.
- Arg:
event: The mouse event.
- update_label_recenter_mouse_move_event(label, event)[source]
Update the mouse move event for the recenter label.
- Parameters:
label – The label to update.
event – The mouse event.
- label_recenter_mouse_leave_event(event)[source]
Handle the mouse leave event for the recenter label.
- Arg:
event: The mouse event.
- update_label_recenter_mouse_leave_event()[source]
Update the mouse leave event for the label recenter.
This method updates the mouse leave event for the label recenter based on the current mode view.
- label_recenter_mouse_release_event(event)[source]
Handle the mouse release event for the label recenter.
This method handles the mouse release event for the label recenter and triggers a menu mouse event if the right mouse button is clicked.
- Arg:
event (QMouseEvent): The mouse event object.
- set_value_coordinate_image_original(cor_x, cor_y)[source]
Set the coordinate values for the original image label in the user interface.
This method sets the coordinate values for the original image label in the user interface based on the given x and y coordinates.
- Parameters:
cor_x (int) – The x-coordinate value.
cor_y (int) – The y-coordinate value.
- set_value_coordinate_image_recenter(cor_x, cor_y)[source]
Set the coordinate values for the recenter image label in the user interface.
This method sets the coordinate values for the recenter image label in the user interface based on the given x and y coordinates.
- Parameters:
cor_x (int) – The x-coordinate value.
cor_y (int) – The y-coordinate value.
- show_alpha_beta_label_original(alpha, beta)[source]
Set the alpha and beta values based on the given coordinate.
This method sets the alpha and beta values for the original image label in the user interface based on the given coordinates. If either value is None, then both alpha and beta are set to 0.0. Otherwise, the alpha and beta values are rounded to two decimal places before being set.
- Parameters:
alpha (float) – The alpha value.
beta (float) – The beta value.
- show_alpha_beta_label_recenter(alpha, beta)[source]
Set the alpha and beta values for recentered image label in the user interface.
This method sets the alpha and beta values for the recentered image label in the user interface based on the given coordinates. If either value is None, then both alpha and beta are set to 0.0. Otherwise, the alpha and beta values are rounded to two decimal places before being displayed.
- Parameters:
alpha (float) – The alpha value.
beta (float) – The beta value.
Plugin Collection Controller
This module defines the PluginCollection class responsible for managing a collection of plugins within a PyQt6 application.
- class controllers.control_plugin_collection.PluginCollection(plugin_package)[source]
Bases:
object
A class for managing a collection of plugins within a PyQt6 application.
- _plugins
A list to store instances of plugin classes.
- Type:
list
- name_application
A list to store names of plugins.
- Type:
list
- _seen_paths
A list to keep track of paths already visited during package scanning.
- Type:
list
- path_folder
A list to store the module paths of plugins.
- Type:
list
- plugin_package
The name of the package containing plugins.
- Type:
str
- reload_plugins()[source]
Reload the plugins from the specified package.
This function clears the existing plugin list, name list, and folder path list, then walks through the plugin package and appends any valid plugins to the plugin list.
- get_widget(index, model)[source]
Return the widget associated with a plugin at the specified index.
- Parameters:
index – The index of the plugin to get the widget for.
model – The model to use when initializing the plugin’s widget.
- Returns:
The widget associated with the plugin at the specified index, or None if there was an error.
- set_always_pop_up(index)[source]
Set the “always popup” property of the plugin at the specified index.
- Arg:
index (int): The index of the plugin.
- Returns:
The value of the “always popup” property for the plugin.
- get_icon_(index)[source]
Return the path of the icon for a given plugin index.
- Arg:
index (int): The index of the plugin.
- Returns:
The path to the icon file, or None if the plugin has no icon.
- Return type:
str or None
- change_theme(index)[source]
Change the stylesheet of the plugin at the given index to the current theme.
- Arg:
index (int): The index of the plugin to update.
- Returns:
None
Plugin Manager Controller
This module provides functionality for managing plugins within the application.
The PluginManager class defined in this module handles the installation, removal, and management of plugins within the application. It interacts with the PluginCollection class to load, install, and uninstall plugins. Additionally, it provides methods for opening plugins, displaying help information, and managing plugin-related UI elements.
- Class:
PluginManager: Manages the plugins in the application.
- class controllers.control_plugin_manager.PluginManager(*args: Any, **kwargs: Any)[source]
Bases:
QMainWindow
Manages the plugins in the application.
The PluginManager class handles the installation, removal, and management of plugins within the application. It provides methods for installing new plugins from a plugin store, opening installed plugins, removing plugins, and displaying help information for plugins.
- _controller
The main control object of the application.
- Type:
object
- _model
The model object of the application.
- Type:
object
- _stylesheet
The stylesheet object used for styling UI elements.
- Type:
object
- plugin
An instance of the PluginCollection class for managing plugins.
- Type:
- _message_box
An instance of the MessageBoxHandler class for displaying messages.
- Type:
object
- _plugin_list
A list of available plugins retrieved from the plugin store.
- Type:
list
- apps_activated
The name of the currently activated plugin.
- Type:
str
- index
The index of the currently activated plugin.
- Type:
int
- widget
The widget associated with the currently activated plugin.
- Type:
QWidget
- text_title
The title of the currently activated plugin.
- Type:
str
- _main_config
The main configuration settings of the application.
- Type:
dict
- _github_config
The GitHub configuration settings for accessing the plugin store.
- Type:
dict
- _access_token
The access token for accessing the GitHub repository.
- Type:
str
- connect_to_event()[source]
Connects the main window buttons to their corresponding actions.
This method is responsible for setting up event connections between the buttons in the main window and their corresponding actions.
- clicked_plugin_remove()[source]
Delete a plugin application from the system.
The function prompts the user with a confirmation message, and if the user confirms, deletes the plugin application from the system. The function then reloads the list of available plugins, initializes the available plugin UI, and displays a success message.
- download_plugins_from_github(plugin)[source]
Download a plugin from GitHub.
- Arg:
plugin (str): The name of the plugin to download.
- get_list_plugins()[source]
Get the list of plugins from the plugin store on GitHub.
Retrieve the list of plugins from the GitHub repository and displays them in the plugin store UI.
- clicked_install_plugins()[source]
Handle the installation of a plugin.
This method is triggered when the user clicks the install button for a plugin. It retrieves the name of the selected plugin and initiates the download process.
- init_available_plugin()[source]
Initialize the available plugins by adding buttons for each one to the UI.
Clear any existing buttons from the UI layout, then iterates over the list of available plugins and adds a button for each one. The icon for each plugin is retrieved using the get_icon_ method of the PluginCollection object.
- Returns:
None
- install_new_plugin()[source]
Open a file dialog for selecting a new plugin folder and installs it into the plugin store.
- refresh_the_plugin_available()[source]
Refresh the list of available plugins and adds new ones to the UI.
Retrieve the list of available plugins, compares it with the previous list, and adds any newly available plugins to the UI. Also displays a message box to inform the user about the successful addition of plugins.
- Returns:
None
- refresh_plugin_available(list_app)[source]
Refresh the list of available plugins.
- Arg:
list_app (list): The previous list of available plugins.
- Returns:
None
- refresh_theme_widget()[source]
Refresh the theme of the currently selected plugin widget, if any.
- Returns:
None
- open_pinned_plugin(index)[source]
Open the pinned plugin with the specified index.
- Arg:
index (int): The index of the pinned plugin to be opened.
- Returns:
None
- show_plugins_after_installation(widget)[source]
Show the installed plugin in the UI after installation.
- Arg:
widget: The widget representing the installed plugin.
- Returns:
None
- open_plugin_apps()[source]
Open the selected plugin application and displays its widget in the plugin layout.
- Raises:
IndexError – If the selected plugin index is not found in self.plugin.name_application.
- Side Effects:
Sets self.index to the index of the selected plugin.
Shows the “Delete Plugins” and “Close Plugin” buttons in the main control UI.
Closes all widgets in the plugin layout before adding the selected plugin’s widget.
Changes the current widget container to the plugin layout.
Hides the “MOIL App” and “View” buttons in the main control UI.
Sets self.apps_activated to the selected plugin’s name.
- add_btn_apps_plugin(icon_, name)[source]
Create and return a QPushButton widget with an icon and a name.
- Parameters:
icon – A string specifying the path of the icon file.
name – A string specifying the name of the plugin.
- Returns:
A QPushButton widget with the specified icon and name.
- clear_item_layout()[source]
Clear the items from the layout.
Remove all items from the vertical layout ‘verticalLayout_plugin_store’ in the UI.
- Returns:
None
- delete_plugin_apps()[source]
Delete a plugin application from the system.
The function prompts the user with a confirmation message, and if the user confirms, deletes the plugin application from the system. The function then reloads the list of available plugins, initializes the available plugin UI, and displays a success message.
- remove_plugin_folder(path)[source]
Remove a plugin folder from the directory.
- Arg:
path (str): The path to the plugin folder.
- Returns:
None
- classmethod handle_remove_readonly(func, path, _)[source]
Handle the removal of read-only files or directories.
This method is used as an error handler when attempting to remove read-only files or directories. It clears the read-only attribute of the file or directory and attempts to delete it again.
- Parameters:
func (callable) – The function used to remove the file or directory.
path (str) – The path to the read-only file or directory.
_ (object) – Ignored parameter required by the shutil.rmtree function.
- Returns:
None
Display a help message for the currently selected plugin in a pop-up box.
If the currently selected widget is the home screen, displays a generic message. Otherwise, displays a message that includes the plugin’s description.
- Returns:
None
Recent Project Controller
This module defines the RecentOpen class, which represents a PyQt6-based GUI application for managing recent projects and directories.
The RecentOpen class provides functionality for opening recent projects, displaying files in selected directories, and managing recent projects in the UI.
It includes methods for handling click events, processing directories, managing recent projects in the UI, and opening recent project images.
Classes: - RecentOpen: Represents the main application window for managing recent projects and directories.
- class controllers.control_recent_project.RecentOpen(*args: Any, **kwargs: Any)[source]
Bases:
QMainWindow
The RecentOpen class represents a PyQt6-based GUI application for managing recent projects and directories.
Attributes: - controller: The controller object responsible for managing the application. - _model: The model object containing the application’s data and logic. - _stylesheet: The stylesheet object for defining the visual appearance of the UI. - directory_open_list: A list to store the paths of files in the selected directory.
Methods: - __init__: Initializes the RecentOpen instance. - click_open_directory: Handles the click event of the open directory button. - process_open_directory: Processes the selected directory and displays the files in the UI. - combo_box_selected: Handles the selection of options from the combo box. - detect_available_on_recent: Detects if a given path is available in the recent project list. - click_push_button_open_file_directory: Handles the click event of the push button to open a project. - clear_item_layout_directory_open: Clears the directory item projects in the user interface. - get_list_recent_project: Retrieves the list of recent projects and displays them in the UI. - add_list_recent_project_to_ui: Adds recent projects to the user interface. - click_push_button_open: Handles the click event of the push button to open a recent project. - click_push_button_delete: Handles the click event of the push button to delete a recent project. - clear_item_layout: Clears the items from the layout. - open_image_from_directory: Opens an image from the selected directory. - open_recent_image: Opens a recent project image. - remove_recent_image: Removes a recent project image.
- process_open_directory()[source]
Process the selected directory and display the files in the UI.
This method retrieves files with specific extensions from the selected directory, creates UI elements for each file, and adds them to the layout.
- Returns:
None
- combo_box_selected()[source]
Handle the selection of options from the combo box.
Retrieves the index of the selected combo box and performs further actions based on the selection.
- Returns:
None
- detect_available_on_recent(path)[source]
Detects if the given path is available in the recent project list.
Checks if the provided path matches any of the paths stored in the recent project list.
- Arg:
path (str): The path to be checked.
- Returns:
- status (bool): True if the path is found in the recent project list, False otherwise.
index_recent_list (int or None): The index of the matching path in the recent project list, or None if not found.
theme (str): The theme of the detected path (‘install’ if found, ‘None’ otherwise).
- Return type:
tuple
- click_push_button_open_file_directory()[source]
Handle the click event of the push button to open a project.
Retrieve the index of the clicked push button and opens the corresponding project.
- Returns:
None
- clear_item_layout_directory_open()[source]
Clear the directory item projects in the user interface.
Remove all widgets from the vertical layout containing directory item projects.
- Returns:
None
- get_list_recent_project()[source]
Retrieve the list of recent projects and displays them in the UI.
- click_push_button_open()[source]
Handle the click event of the push button to open a recent project.
Retrieve the index of the clicked button and opens the corresponding recent project.
- click_push_button_delete()[source]
Handle the click event of the push button to delete a recent project.
Retrieve the index of the clicked button and removes the corresponding recent project.
- clear_item_layout()[source]
Clear the items from the layout.
Remove all items from the recent projects layout in the user interface.
- open_image_from_directory(index)[source]
Open an image from the selected directory.
If the image is already part of the recent projects, it opens that project. Otherwise, it sets the selected image as the main project, updates the model configuration accordingly, and displays the image in the user interface.
- Arg:
index (int): The index of the selected image in the directory.
- Returns:
True if the operation is successful, False otherwise.
- Return type:
bool
Saving Media Controller
This module contains the SaveMedia class, which provides methods for saving images to a selected folder, loading saved images into the GUI’s list widget, recording videos, and other related functionalities.
- class controllers.control_saving_media.SaveMedia(main_control)[source]
Bases:
object
Class to handle saving images and recording videos in the application.
- _controller
The main controller object.
- _ui_object
The UI object.
- _model
The model object.
- __dir_save
The directory path for saving images.
- __base_dir_save
The base directory path for saving images.
- _record_option
The recording option.
- _video_writer
The video writer object.
- add_widget_save_image(self, image, name_file, load=False)[source]
Adds a widget for a saved image to the list widget.
- list_widget_saved_image_activated(self)[source]
Handles the activation of a saved image in the list widget.
- _enable_action_while_record(self, status=True)[source]
Enables or disables actions while recording video.
- set_position_frame_save_image(self, config, file_name, original=False)[source]
Sets the position of a saved frame in the configuration view.
- property record_option
Get the recording option.
- Returns:
The recording option.
- Return type:
str
- property video_writer
Get the video writer.
- Returns:
The video writer object.
- Return type:
Any
- save_image_ori_result(image_result=True)[source]
Save the current or resulting image to a selected folder.
- Arg:
- image_result (bool, optional): Determines whether to save the resulting image
(True) or the original image (False). Defaults to True.
- Raises:
FileNotFoundError – If the base directory for saving images is not found.
- load_saved_image_list(load=False)[source]
Load saved images into the GUI’s list widget.
- Arg:
load (bool, optional): Whether to load the images into the list widget. Defaults to False.
- add_widget_save_image(image, name_file, load=False)[source]
Add a new widget to the saved image list with the given image and file name.
- Parameters:
image (numpy.ndarray) – The image to be displayed in the widget.
name_file (str) – The name of the image file.
load (bool, optional) – Whether the widget is being added during load or not. Defaults to False.
- list_widget_saved_image_activated()[source]
Handle the activation of a saved image in the list widget.
The function sets the appropriate image view mode and opens the saved image.
- onclick_record_video_button()[source]
Handle the click event on the Record Video button.
This function displays an information message indicating that video recording is currently under development, and unchecks the Record Video button.
- set_position_frame_save_image(config, file_name, original=False)[source]
This function sets the position of a saved frame from the Image_saved list in the configuration view. If the timer is active, it will be stopped and the status will be emitted. If the parent path of the saved image is the same as the media source, the position of the frame will be set and the next frame signal will be emitted. If the parent path is different, the saved image will be reopened.
- Parameters:
config
file_name (str) – The name of the saved file.
original (bool, optional) – Flag to indicate if the view is in original or not. Defaults to False.
Screen Record Controller
Module for handling screen recording functionality in the application.
This module contains the ScreenRecord class, which provides methods for recording the screen and managing the recording state.
- class controllers.control_screen_record.ScreenRecord(controller)[source]
Bases:
object
Class for handling screen recording functionality.
- _controller
The main controller object.
- _model
The model object.
- _ui_object
The UI object.
- onclick_record_screen()[source]
Handle the click event of the record screen button.
If the button is checked, the screen recording is started and the button icon is changed to the “record” icon. If the button is unchecked, the screen recording is stopped and the button icon is changed to the “stop” icon.
Setup Icon Controller
Module for configuring the icon theme and setting icons for various UI elements.
This module contains the ConfigIconUI class, which provides methods for setting up the icon theme and configuring icons for different UI elements in the application.
- Classes:
ConfigIconUI: A class for configuring the icon theme and setting icons for UI elements.
- class controllers.control_setup_icon.ConfigIconUI(ui_main_window)[source]
Bases:
object
Class for configuring the icon theme and setting icons for UI elements.
- _ui_object
The main user interface object of the application.
- __init__(self, ui_main_window)[source]
Initializes the ConfigIconUI object with the given main_ui object.
- _set_icon_for_dark_mode_theme(self)[source]
Sets the UI to dark mode by changing the icons and logo to dark mode.
Initialize the MoilApp object with the given main_ui object.
- Arg:
main_ui: A reference to the main user interface object of the application.
- Returns:
None.
Stylesheet Controller
This module contains the ControlStyleSheet class, which provides methods for changing style sheets of various UI elements based on user interactions and theme settings.
- class controllers.control_stylesheet.ControlStyleSheet(controller)[source]
Bases:
object
Class for controlling the style sheets of UI elements.
- _controller
The controller object.
- _model
The model object.
- _ui_object
The UI object.
Change the stylesheet of a selected menu button.
Returns the CSS stylesheet for the currently selected menu item.
Replaces the selected menu style with an unselected style.
- reset_style(self, widget)[source]
Resets the stylesheet of all push buttons in the frame_button_view.
Return the CSS stylesheet for a selected menu button in dark theme.
Returns the light theme stylesheet for the selected menu.
- change_stylesheet_selected_menu()[source]
Change the stylesheet of a selected menu button.
If an image is available, this function updates the style of a selected menu button by applying a new stylesheet that highlights it. The old stylesheet is reset for all other buttons.
- Arg:
self: An instance of the class that this method belongs to.
- Returns:
None
- set_style_selected_menu()[source]
Return the CSS stylesheet for the currently selected menu item.
The returned stylesheet is based on the current theme set in the model attribute.
- Returns:
The CSS stylesheet for the selected menu item.
- Return type:
str
- set_style_deselect_menu(get_style)[source]
Replace the selected menu style with an unselected style in the current theme.
- Arg:
get_style (str): The current style of the menu to be deselected.
- Returns:
The updated style of the menu with the selected style replaced with the unselected style.
- Return type:
str
- reset_style(widget)[source]
Reset the stylesheet of all push buttons in the frame_button_view except for the one with the given object name.
- Arg:
widget (str): The object name of the push button to exclude.
- Returns:
None
Theme Apps Controller
Module for controlling the theme of the application.
This module contains the ControlThemeApps class, which provides methods for initializing the UI with the current theme and for changing the theme between light and dark modes.
- Class:
ControlThemeApps: A class for controlling the theme of the application.
- class controllers.control_theme_apps.ControlThemeApps(controller)[source]
Bases:
object
Class for controlling the theme of the application.
- _controller
The controller object.
- _ui_object
The UI object.
- _model
The model object.
Initialize the ControlThemeApps object.
- Arg:
controller: The controller object.
- Returns:
None
UI Animation Controller
This module contains the ControlPanelPage class, which provides methods for handling UI elements and animations related to the panel page.
- class controllers.control_ui_animation.ControlPanelPage(controller)[source]
Bases:
object
Class for controlling the panel page of the application.
- _ui_object
The UI object.
- _theme_mode
The current theme mode of the application.
- _active_left
A flag indicating whether the left panel is active.
- _animation
Animation object for controlling panel animations.
- _group
Group animation object for coordinating multiple animations.
Animates the left-side menu of the application.
- button_about_us(self)[source]
Animates the “About Us” button and expands the right-hand additional frame.
Toggles the visibility of the additional left frame and updates the theme of the settings button.
- _start_box_animation(self, left_box_width, right_box_width, direction)[source]
Animates the left and right boxes to slide in or out.
- property active_left
Get the status of the left panel.
- Returns:
True if the left panel is active, False otherwise.
- Return type:
bool
- button_menu(max_width, enable)[source]
Animate the left-side menu of the application.
- Parameters:
max_width (int) – The maximum width the menu should extend to.
enable (bool) – Whether to enable or disable the animation.
- Returns:
None.
View Anypoint Controller
Module for managing Anypoint configuration.
This module contains the AnypointConfig class, which is responsible for handling the configuration and user interface interactions related to the Anypoint mode.
- class controllers.control_view_anypoint.AnypointConfig(controller)[source]
Bases:
object
Class for managing Anypoint configuration.
- _controller
The controller object.
- _ui_object
The UI object.
- _model
The model object.
Handles anypoint buttons click event.
- set_initial_value_to_ui_anypoint(self)[source]
Sets initial values to UI elements for Anypoint View.
- showing_config_mode_1(self)[source]
Reads the cached file to load the configuration data for Mode 1.
- showing_config_mode_2(self)[source]
Reads the cached file to load the configuration data for Mode 2.
- change_properties_mode_1(self)[source]
Updates the configuration data for Mode 1 and writes it to the cached file.
- change_properties_mode_2(self)[source]
Updates the configuration data for Mode 2 and writes it to the cached file.
- _get_alpha_beta_for_radio_mode(cls, button_name)[source]
Get alpha and beta angles for Anypoint View in radio mode.
- _get_pitch_yaw_for_non_radio_mode(cls, button_name)[source]
Get pitch and yaw angles for Anypoint View in non-radio mode.
- __block_signal(self)
Blocks signals for alpha, beta, roll, and zoom double spin boxes.
- __unblock_signal(self)
Unblock the signals of the alpha, beta, roll, and zoom double spin boxes in the GUI.
- onclick_btn_anypoint()[source]
Handle the button click event for the Anypoint mode.
Change the application state to the Anypoint mode, shows the Anypoint widget, and sets the current index of the widget to 0.
- Returns:
None
- change_mode_anypoint()[source]
Change the current anypoint mode.
Change the anypoint mode based on the selected radio button in the user interface. Shows or hides certain configuration options depending on the selected mode. Updates the anypoint maps and the anypoint mode in the model.
- Returns:
None
- change_properties_anypoint()[source]
Change the properties of the AnyPoint view mode.
If an image result is available, this method changes the properties of the AnyPoint view mode according to the values set in the GUI. The changes are applied to the configuration object, and new maps are created. The configuration file is updated accordingly.
- Raises:
None. –
- Returns:
None.
- onclick_anypoint_navigator()[source]
Handle anypoint buttons click event.
If radio_mode_1 is checked, set alpha and beta values based on the button clicked, then call showing_config_mode_1 and create_maps_anypoint_mode_1 methods. If radio_mode_1 is not checked, set alpha and beta values based on the button clicked, then call showing_config_mode_2 and create_maps_anypoint_mode_2 methods. Set state_rubberband attribute to False and update the file config.
- set_initial_value_to_ui_anypoint()[source]
Set the initial values to UI elements for Anypoint View.
This method sets initial values to spin boxes and double spin boxes for Anypoint View coordinates and angles. It first blocks signals of the UI elements to prevent emitting unnecessary signals while setting values. Then, it retrieves the initial values from the main configuration based on the active mode view. After setting the values, it unblocks signals of the UI elements.
- Returns:
None
- showing_config_mode_1()[source]
Read the cached file to load the configuration data for Mode 1.
This function reads the YAML data from the cached file and loads it into the self.__anypoint_config attribute. It then sets the values of the zoom, alpha, and beta parameters for Mode 1 in the UI double spin boxes. The function blocks signals while updating the spin box values to prevent recursive updates. Once the values are set, the function unblocks signals.
- Returns:
None
- showing_config_mode_2()[source]
Read the cached file to load the configuration data for Mode 2.
This function reads the YAML data from the cached file and loads it into the self.__anypoint_config attribute. It then sets the values of the pitch, yaw, roll, and zoom parameters for Mode 2 in the UI double spin boxes. The function blocks signals while updating the spin box values to prevent recursive updates. Once the values are set, the function unblocks signals.
- Returns:
None
- change_properties_mode_1()[source]
Update the configuration data for Mode 1 and writes it to the cached file.
This function updates the alpha, beta, and zoom parameters for Mode 1 using the values in the UI double spin boxes. It rounds the zoom value to three decimal places before updating the configuration data. The updated configuration data is then written to the cached file using YAML format.
- Returns:
None
- change_properties_mode_2()[source]
Update the configuration data for Mode 2 and writes it to the cached file.
This function updates the pitch, yaw, roll, and zoom parameters for Mode 2 using the values in the UI double spin boxes. It creates a list of tuples to store the control names and their corresponding values, and then iterates through the list to update the configuration data for each control. The zoom value is rounded to three decimal places before updating the configuration data. The updated configuration data is then written to the cached file using YAML format.
- Returns:
None
- check_box_active_mode_anypoint()[source]
Check and set the active mode for Anypoint View.
If the current mode view is “AnypointView”, this method blocks the signals of radio buttons to prevent emitting unnecessary signals while updating their states. It then sets the checked state of radio buttons based on the active view stored in the main configuration. Finally, it unblocks the signals of the radio buttons.
- Returns:
None
View Fisheye Controller
This module contains the ControlImageFisheye class, which is responsible for managing the interactions related to fisheye images in the application.
- class controllers.control_view_fisheye.ControlImageFisheye(controller)[source]
Bases:
object
Class for controlling fisheye images.
- _controller
The controller object.
- _model
The model object.
- _ui_object
The UI object.
Initialize the ControlImageFisheye object.
- Arg:
controller: The controller object.
- Returns:
None
View Fullscreen Controller
This module contains the ControlViewFullscreen class, which is responsible for managing the interactions related to the full-screen view in the application.
- class controllers.control_view_fullscreen.ControlViewFullscreen(controller)[source]
Bases:
object
Class for controlling full-screen view.
- _controller
The controller object.
- _model
The model object.
- _new_window
The new window object for full-screen view.
- _full_screen_mode
A boolean indicating whether full-screen mode is active.
- resize_event_new_window(self, a0
QtGui.QResizeEvent) -> None: Handles resize events for the new window.
- label_full_screen_double_click_event(self, event)[source]
Handles double-click event on the full-screen label.
- control_fov_full_screen(self)[source]
Controls field of view for the original image in full-screen mode.
Initialize the ControlViewFullscreen object.
- Arg:
controller: The controller object.
- Returns:
None
- resize_event_new_window(a0: PyQt6.QtGui.QResizeEvent) None [source]
Handle the resize event for the new window.
This method is triggered when the new window is resized. If the original image exists in the model, it updates the UI to display the image accordingly.
- Arg:
a0 (QtGui.QResizeEvent): The resize event.
- Returns:
None
- property new_window
Getter property for the new window.
- Returns:
The new window.
- Return type:
QtWidgets.QWidget
- property full_screen_mode
Getter property for the full screen mode.
- Returns:
The current full screen mode.
- Return type:
bool
View Panorama Controller
This module defines the PanoramaConfig class, which handles the configuration of panorama views in an application
- class controllers.control_view_panorama.PanoramaConfig(controller)[source]
Bases:
object
This class provides methods to handle user interactions related to configuring panorama views, including changing modes between car and tube, setting initial values for UI elements, updating properties based on user input, and managing signals between UI elements and the underlying model.
- set_initial_value_to_ui_panorama()[source]
Sets initial values for UI elements in panorama view configuration.
- change_properties_panorama()[source]
Changes properties of the panorama view configuration based on user input.
- change_properties_crop_panorama()[source]
Changes the properties of the panorama crop based on user input.
- unblock_signal_pano_tube()[source]
Unblocks signals for UI elements related to the tube panorama view.
- unblock_signal_pano_car()[source]
Unblocks signals for UI elements related to the car panorama view.
- showing_config_panorama_tube()[source]
Updates UI elements with panorama tube configuration values.
- change_properties_panorama_tube()[source]
Changes properties of the panorama tube view configuration.
- change_properties_panorama_car()[source]
Changes properties of the panorama car view configuration.
- onclick_btn_panorama()[source]
Handle click event for the ‘panorama’ button.
Change the app’s recent view state to ‘PanoramaView’, shows the widget mode view and frame pointer anypoint, sets the current index of the widget mode view to 1, and sets the state rubberband to False if an image has been loaded.
- Returns:
None
- change_mode_panorama()[source]
Change the panorama mode to either ‘car’ or ‘tube’.
This method sets the panorama mode to either ‘car’ or ‘tube’ based on the selected radio button. If the ‘car’ radio button is selected, the car configuration frame is shown and the tube configuration frame is hidden. The opposite is true if the ‘tube’ radio button is selected. The panorama configuration object is then updated and the maps for the selected mode are created.
- set_initial_value_to_ui_panorama()[source]
Set initial values to the user interface elements for the Panorama view configuration.
This method sets the initial values of spin boxes and double spin boxes in the user interface based on the Panorama view configuration.
- Returns:
None
- change_properties_panorama()[source]
Change the properties of the panorama configuration according to the selected options.
If there is a result image, this function updates the panorama configuration and maps based on the selected radio button, which can be “Car” or “Tube”. It then updates the file configuration. If there is no result image, this function does nothing.
- change_properties_crop_panorama()[source]
Change the properties of the current panorama crop.
If there is a panorama image loaded, this function updates the properties of the crop using the settings selected in the UI. If the “car” option is selected, the panorama is cropped to a horizontal field of view of 360 degrees and a vertical field of view of 90 degrees. If the “tube” option is selected, the panorama is cropped to a horizontal field of view of 180 degrees and a vertical field of view of 360 degrees.
After updating the properties of the crop, this function updates the app’s configuration file and creates a new image result.
- block_signal_pano_tube()[source]
Block signals for panoptic tube spin boxes and double spin boxes.
This method blocks signals for the following spin boxes and double spin boxes: - self.ui_object.doubleSpinBox_pano_tube_alpha_min - self.ui_object.doubleSpinBox_pano_tube_alpha_max - self.ui_object.doubleSpinBox_pano_tube_crop_top - self.ui_object.doubleSpinBox_pano_tube_crop_bottom
- unblock_signal_pano_tube()[source]
Unblock the signals for the pano tube settings widgets.
This function calls the _unblock_signal method to unblock the signals for the pano tube settings widgets.
- block_signal_pano_car()[source]
Block the signals of certain UI elements related to the panoramic car view.
- unblock_signal_pano_car()[source]
Unblock signals for a set of widgets related to the panoramic car view.
This function unblocks signals for the following widgets: doubleSpinBox_pano_car_alpha, doubleSpinBox_pano_car_beta, doubleSpinBox_pano_car_crop_left, doubleSpinBox_pano_car_crop_right, doubleSpinBox_pano_car_crop_top, doubleSpinBox_pano_car_crop_bottom. This allows changes to these widgets to trigger the corresponding slots.
This function is called by the GUI when the user leaves a specific tab or dialog box in the panoramic car view.
- showing_config_panorama_tube()[source]
Read the panorama configuration from a YAML file, and populates the relevant UI elements with the values.
Open the cached configuration file using the private attribute __cached_file as the file path, and reads its contents using PyYAML’s safe_load method. The relevant UI elements are then set to the corresponding values found in the configuration file.
Note
This function blocks signals from the UI elements while updating them with the configuration values.
- Raises:
IOError – If the configuration file cannot be read.
- showing_config_panorama_car()[source]
Load the panorama car configuration from a cached YAML file and updates the user interface with its values.
Read the cached file at self.__cached_file using the PyYAML library to parse the YAML content. The parsed configuration values are assigned to the instance variable self.__panorama_config. Blocks signals from all the widgets associated with the car panorama in the user interface to prevent any unintended updates during the UI update process. Then, sets the values of the panorama car configuration widgets in the UI with the parsed values from the configuration file. Finally, unblocks signals from all the widgets that were previously blocked.
- Returns:
None
- change_properties_panorama_tube()[source]
Change the properties of the panorama tube.
Read the new values for alpha_min, alpha_max, crop_top, and crop_bottom from the corresponding UI elements, and updates the __panorama_config dictionary with the new values if they meet certain criteria. Then writes the updated dictionary to a YAML file.
- change_properties_panorama_car()[source]
Update the properties of the car panorama and saves them to a YAML file.
Update the alpha and beta properties of the car panorama from the GUI spinboxes. Update the crop_left, crop_right, crop_top, and crop_bottom properties of the car panorama from the GUI double spinboxes. Saves the updated panorama configuration to a YAML file specified in self.__cached_file.
View Recenter Controller
This module contains classes for configuring panorama and recentering views in the application.
- Classes:
PanoramaConfig: Manages configuration related to panorama views, including car and tube modes.
RecenterConfig: Manages configuration related to recentering images in the application.
Each class provides methods to handle user interactions, update configurations, and create necessary image transformations.
- class controllers.control_view_recenter.RecenterConfig(controller)[source]
Bases:
object
This class provides methods to handle user interactions for changing the optical point coordinates, activating the change optical point feature, and creating recentered images based on the original image and recentering maps.
- activate_change_optical_point()[source]
Activates the change optical point feature based on the state of a checkbox.
- change_coordinate_optical_point()[source]
Changes the optical point coordinates based on user input.
- create_image_recenter()[source]
Creates a recentered image based on the original image and recentering maps.
View Rotate Controller
This module contains classes for managing various aspects of image processing and manipulation in the application’s user interface.
- Classes:
PanoramaConfig: Manages panorama view configuration settings and UI interactions.
RecenterConfig: Handles recentering of images and related UI controls.
ControlViewRotate: Manages image rotation functionality and UI controls.
- class controllers.control_view_rotate.ControlViewRotate(controller)[source]
Bases:
object
This class manages the rotation of images in the application’s user interface.
- - __init__(controller)
Initializes the ControlViewRotate instance.
- - _connect_event()
Connects GUI events to their corresponding methods.
- - _change_rotate_degree(direction)
Rotates the result image in the specified direction.
- - _show_rotation_value()
Sets the value of the rotation angle in the GUI.
- - _rotation_change_value()
Updates the rotation angle when the user changes its value.
- - _rotation_image_ori_change_value()
Updates the rotation angle for the original image.
- - _rotation_original_change_value()
Updates the rotation angle for the original image.
- - set_initial_value_to_ui_rotate()
Sets the initial rotation values in the user interface.
View Zoom Controller
This module contains classes for managing various view controls in the application.
- Classes:
ControlViewRotate: Manages image rotation functionality and UI controls.
ControlViewZoom: Manages image zoom functionality and UI controls.
- class controllers.control_view_zoom.ControlViewZoom(controller)[source]
Bases:
object
Manages image zoom functionality and UI controls.
This class provides methods to handle zoom in, zoom out operations, and control the zooming level displayed in the user interface.
- - __init__
Initializes the ControlViewZoom object.
- - _connect_event
Connects UI events to corresponding methods.
- - _onclick_zoom
Handles zoom in/out operations.
- - _control_change_zooming
Controls the change of zooming in the displayed image.
- - show_percentage_zoom
Displays the percentage of the current zoom level in the zoom spin box.
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.
- 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
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
- get_icon_link()[source]
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
- get_icon_external_link()[source]
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
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
Return a QIcon object representing the white menu icon.
- Returns:
White menu 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
- 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:
- property moildev_pano_rt
Get the panorama rectification Moildev instance.
- Returns:
The panorama rectification Moildev instance.
- Return type:
- property moildev_recenter
Get the recenter Moildev instance.
- Returns:
The recenter Moildev instance.
- Return type:
- 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.
- 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
- stylesheet_button_additional()[source]
Generates a stylesheet for additional QPushButton customization based on the provided state.
- 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
- 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
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.
- 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.
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.
- get_cr_left_right_panorama_car(pano_car)[source]
Calculates the left and right coordinates of the panorama car.
- create_maps_panorama_car()[source]
Creates Panorama maps for the car feature based on the configuration file.
- create_maps_panorama_tube()[source]
Creates Panorama maps for the tube feature based on the configuration file.
- 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.
- 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
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.
- property maps_recenter
Get the maps for recentering.
- Returns:
A tuple containing the X and Y maps for recentering.
- Return type:
tuple
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.
- 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.
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
- record_state()
Getter and setter methods for the recording state.
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.
Views Package
Main Views
Ui_splash_screen View
Full_screen View
moilutils Package
Moilutils Models
Project Name: MoilApps v4.1.0 Writer : Haryanto PROJECT MADE WITH: Qt Designer and PyQt6 Build for: MOIL-LAB Copyright: MOIL-2024
This project can be use a a template to create better user interface when you design a project.
There are limitations on Qt licenses if you want to use your products commercially, I recommend reading them on the official website: https://doc.qt.io/qtforpython/licenses.html
- class models.moilutils.moilutils.MoilUtils[source]
Bases:
MoilFisheyeMarker
- static moil_camera(cam_type=None, cam_id=None, resolution: Tuple[int, int] = None)[source]
create camera object from moil camera package
- Parameters:
cam_type
cam_id
resolution
Returns:
- static select_parameter_name()[source]
Generate a Q-dialog for select camera parameter name.
- Returns:
camera name
- select_media_source(from_plugin=False)[source]
Displays a dialog for selecting USB/web camera sources and detecting them. Available camera sources can be obtained by clicking the detection button on the dialog.
- Returns:
Port number for usb cameras or the source link for web cameras
- static show_image_to_label(label, image, width, options=None)[source]
Display an image to the label widget on the user interface.
- Parameters:
label – destination label
image – image to show
width – width for resizing the image while keeping the original aspect ratio
options (dict) – optional parameters including angle, plus_icon, and scale_content
- Returns:
None. Shows image on the label.
Example:
options = {'angle': 0, 'plus_icon': False, 'scale_content': False} MoilUtils.show_image_to_label(label, image, 400, options)
- classmethod connect_to_moildev(parameter_name, parameters_database=None, virtual_param_ratio=None)[source]
Return a Moildev instance for a specific type of camera.
- Parameters:
parameter_name – name of camera (You can use ‘select_type_camera()’ to get the name.)
parameters_database – parameter of the camera
virtual_param_ratio
- Returns:
Moildev instance
c_type = mutils.select_type_camera() moildev_camera1 = mutils.connect_to_moildev(type_camera=c_type)
- static remap_image(image, map_x, map_y)[source]
- Take an image and a pair of X-Y maps generated by a Moildev instance as inputs,
then return a remapped image using the maps.
- Parameters:
image – input image
map_x – mapping function in the x direction.
map_y – mapping function in the y direction.
- Returns:
remapped image, typically it would be an anypoint image or a panorama image.
- Return type:
image
Example:
image_anypoint = remap_image(image, mapX_anypoint, mapY_anypoint)
- static select_file(parent=None, title='Open file', dir_path='.', file_filter='')[source]
Generate a dialog for file selection and return the path of the file selected. If no file is selected, an empty string is returned.
- Parameters:
parent – parent windows of the dialog
title – dialog title
file_filter – filters for specific file types
dir_path – dialog’s working directory
- Returns:
path of the file selected.
Example:
path_img = mutils.select_file(dir_path="./", file_filter='*.jpg')
- static select_directory(parent=None, parent_dir='', title='Select Folder')[source]
Generate a dialog for directory selection and return the path of the directory selected. If no directory is selected, an empty string is returned.
- Returns:
path of the directory selected
Example:
path_dir = mutils.select_file()
- static copy_directory(src_directory, dst_directory)[source]
Recursively copy a whole directory to the destination directory.
- Parameters:
src_directory – path of the source folder
dst_directory – path of the destination directory
- Returns:
None
Example:
path_source = mutils.select_directory() mutils.copy_directory(path_source, '/home')
- static resize_image(image, width)[source]
Resize an image to one with a given width while maintaining its original aspect ratio and return it.
- Parameters:
image – input image
width – desired image width
- Returns:
resized image
- static rotate_image(src, angle, center=None, scale=1.0)[source]
Return an image after rotation and scaling(not resizing). :param src: input image :param angle: rotation angle :param center: coordinate of the rotation center. By default, it’s the image center. :param scale: scaling factor
- Returns:
rotated image
Example:
image = mutils.rotate_image(image, 90, center=(20,25))
- static calculate_height(image, width)[source]
Return the aspect ratio keeping height for a given image width
- Parameters:
image – input image
width – desired image width
- Returns:
image height
Example:
height = calculate_height(image, 140)
- static draw_polygon(image, mapX, mapY, is_fov=False)[source]
Return image with a drawn polygon indicating the remapped area given an anypoint map pair.
- Parameters:
image – input image
map_x – anypoint mapX
map_y – anypoint mapY
- Returns:
image with a polygon
Example:
img = mutils.read_image('sample_image.jpg') c_type = mutils.select_type_camera() m_instance = mutils.connect_to_moildev(type_camera=c_type) mx, my = m_instance.maps_anypoint(0, -90, 4) img = mutils.draw_polygon(img, mx, my)
- static write_camera_type(image_file, type_camera)[source]
Write the camera type into the image’s metadata.
- Parameters:
image_file – image file path
type_camera – name of camera
- Returns:
None
mutils.write_camera_type('sample_image.jpg', 'Camera_name')
- static read_camera_type(image_file)[source]
Read the camera type from image’s metadata.
- Parameters:
image_file – image file path
- Returns:
camera type
c_type = mutils.read_camera_type('sample_image.jpg')
- static save_image(image, dst_directory, type_camera=None)[source]
Save an image to a directory and write the camera type into its metadata if the type is given. The file name would be the date and time when the image is saved.
- Parameters:
image – input image
dst_directory – destination directory path
type_camera – camera type
- Returns:
file name
save_image(img, '.', 'camera_1')
- static draw_line(image, coordinate_point_1=None, coordinate_point_2=None)[source]
Draw a line on the image from the coordinate given. If no coordinate is given, it draws lines on image margins.
- Parameters:
image – input image
coordinate_point_1 – point 1 coordinate (x, y)
coordinate_point_2 – point 2 coordinate (x, y)
- Returns:
image with a line drawn
img = mutils.draw_line(img, (300, 300), (300, 400) )
- static calculate_ratio_image2label(label, image)[source]
Calculate the width and height ratio of the image to a label.
- Parameters:
label – UI label
image – input image
- Returns:
width ratio and height ratio
w_ratio, h_ratio = mutils.calculate_ratio_image2label(label, img)
- static cropping_image(image, left, right, top, bottom)[source]
Crop an image by ratio from every side.
- Parameters:
image – input image
right – ratio of right side (1-0)
bottom – ratio of bottom side (1-0)
left – ratio of left side (0-1)
top – ratio of top side (0-1)
- Returns:
image has already cropping
- static draw_list_point_with_text(image, coordinate_point, radius=5)[source]
Draw points and their indices on the image.
- Parameters:
image – input image
coordinate_point – a list of points’ coordinates
radius – point radius
- Returns:
image with the point and their sequences drawn.
points_to_draw = [(100, 250), (200, 200), (450, 0)] img = mutils.draw_list_point_with_text(img, points_to_draw, radius=3)
- classmethod draw_rectangle(image, point_1, point_2, thickness=5)[source]
Draw rectangle on the image.
- Parameters:
() (thickness) – input image
() – the first point
() – the second point to create rectangle
() – the thickness of rectangle line
- Returns:
image with rectangle object
- classmethod convert_cv2_to_q_image(image)[source]
Convert an image from OpenCV format to Qt format. The function takes an image in OpenCV format and returns the equivalent image in Qt format. The image can be grayscale, RGB or RGBA. The conversion is done by creating a QImage object and setting the image data and format accordingly.
- Parameters:
image (ndarray) – The image in OpenCV format (height x width x channels)
- Returns:
The image in Qt format
- Return type:
QImage
Moildev Models
- class models.moilutils.moildev.Moildev.Moildev(file_camera_parameter=None, camera_type=None, resolution_ratio=1, **kwarg)[source]
Bases:
object
Initializes the Moildev object and sets up the camera parameters.
The camera parameters must be configured at the start of the program. These parameters are the result of the MOIL laboratory’s camera calibration.
- Parameters:
file_camera_parameter (str, optional) – Path to the *.json file containing the camera parameters.
camera_type (str, optional) – The name of the camera type used (use if passing parameters via a *.json file).
resolution_ratio (float, optional) – The ratio for resizing the image resolution. Defaults to 1.
camera_name (str, optional) – The name of the camera used.
camera_fov (float, optional) – Camera field of view (FOV).
sensor_width (float, optional) – Size of the sensor width.
sensor_height (float, optional) – Size of the sensor height.
icx (float, optional) – Center image in the x-axis.
icy (float, optional) – Center image in the y-axis.
ratio (float, optional) – The value of the ratio image.
image_width (int, optional) – The width of the image.
image_height (int, optional) – The height of the image.
calibration_ratio (float, optional) – The value of the calibration ratio.
parameter_5 (parameter_0 ..) – Intrinsic fisheye camera parameters obtained from calibration.
For more details, please refer to https://github.com/perseverance-tech-tw/moildev
- classmethod version()[source]
Showing the information of the version moildev library.
- Returns:
Moildev version information
- property camera_name
Get camera name used.
- Returns:
Camera name (string)
- property sensor_width
Get sensor width used.
- Returns:
Camera name (string)
- property sensor_height
Get sensor height used.
- Returns:
Camera name (string)
- property ratio
Get ratio used.
- Returns:
Camera name (string)
- property calibration_ratio
Get calibration ratio used.
- Returns:
Camera name (string)
- property camera_fov
Get Field of View (FoV) from camera used.
- Returns:
FoV camera (int)
- property icx
Get center image x-axis from camera used.
- Returns:
Image center X (int)
- property icy
Get center image y-axis from camera used.
- Returns:
Image center Y(int)
- property image_width
Get the width of the image used.
- Returns:
image width(int)
- property image_height
Get the height of the image used.
- Returns:
image height(int)
- property param_0
Get the value of calibration parameter_0 from camera used.
- Returns:
Parameter_0 (float)
- property param_1
Get the value of calibration parameter_1 from camera used.
- Returns:
Parameter_1 (float)
- property param_2
Get the value of calibration parameter_2 from camera used.
- Returns:
Parameter_2 (float)
- property param_3
Get the value of calibration parameter_3 from camera used.
- Returns:
Parameter_3 (float)
- property param_4
Get the value of calibration parameter_4 from camera used.
- Returns:
Parameter_4 (float)
- property param_5
Get the value of calibration parameter_5 from camera used.
- Returns:
Parameter_5 (float)
- maps_anypoint_mode1(alpha, beta, zoom)[source]
Generate a pair of X-Y Maps for the specified alpha, beta and zoom parameters, and then utilize the resulting X-Y Maps to remap the original fisheye image to the target angle image. This function has 2 mode to generate maps anypoint, mode 1 is for tube application and mode 2 usually for car application
- Parameters:
alpha – value of zenith distance(float).
beta – value of azimuthal distance based on cartography system(float)
zoom – value of zoom(float)
- Returns:
the mapping matrices X mapY: the mapping matrices Y
- Return type:
mapX
please reference: https://github.com/perseverance-tech-tw/moildev
- maps_anypoint_mode2(pitch, yaw, zoom)[source]
Generate a pair of X-Y Maps for the specified pitch, yaw, and roll also zoom parameters, and then utilize the resulting X-Y Maps to remap the original fisheye image to the target image.
- Parameters:
pitch – pitch rotation (from -110 to 110 degree)
yaw – yaw rotation (from -110 to 110 degree)
zoom – zoom scale (1 - 20)
- Returns:
the mapping matrices X mapY: the mapping matrices Y
- Return type:
mapX
- maps_anypoint_car(pitch, yaw, roll, zoom)[source]
Generate a pair of X-Y Maps for the specified pitch, yaw, and roll also zoom parameters, and then utilize the resulting X-Y Maps to remap the original fisheye image to the target image.
- Parameters:
pitch – pitch rotation (from -110 to 110 degree)
yaw – yaw rotation (from -110 to 110 degree)
roll – roll rotation (from -110 to 110 degree)
zoom – zoom scale (1 - 20)
- Returns:
the mapping matrices X mapY: the mapping matrices Y
- Return type:
mapX
- maps_panorama_tube(alpha_min, alpha_max)[source]
To generate a pair of X-Y Maps for alpha within 0 … alpha_max degree, the result X-Y Maps can be used later to generate a panorama image from the original fisheye image.
- Parameters:
alpha_min – the minimum alpha degree given
alpha_max – the maximum alpha degree given. The recommended value is half of camera FOV. For example, use 90 for a 180 degree fisheye images and use 110 for a 220 degree fisheye images.
- Returns:
the mapping matrices X mapY: the mapping matrices Y
- Return type:
mapX
please reference: https://github.com/perseverance-tech-tw/moildev
- maps_panorama_car(alpha_max, ic_alpha_degree, ic_beta_degree, flip=False)[source]
To generate a pair of X-Y Maps for alpha within 0 alpha_max degree, the result X-Y Maps can be used later to generate a panorama image from the original fisheye image. The panorama image centered at the 3D direction with alpha = ic_alpha_degree and beta = ic_beta_degree.
- Parameters:
alpha_max – max of alpha. The recommended value is half of camera FOV. For example, use 90 for a 180 degree fisheye images and use 110 for a 220 degree fisheye images.
ic_alpha_degree – alpha angle of panorama center.
ic_beta_degree – beta angle of panorama center.
flip – flip image panorama.
- Returns:
mapX mapY
please reference: https://github.com/perseverance-tech-tw/moildev
- maps_panorama_rt(alpha_max, ic_alpha_degree, ic_beta_degree)[source]
To generate a pair of X-Y Maps for alpha within 0..alpha_max degree, the result X-Y Maps can be used later to generate a panorama image from the original fisheye image. The panorama image centered at the 3D direction with alpha = ic_alpha_degree and beta = ic_beta_degree.
- Parameters:
alpha_max – max of alpha. The recommended value is half of camera FOV. For example, use 90 for a 180 degree fisheye images and use 110 for a 220 degree fisheye images.
ic_alpha_degree – alpha angle of panorama center.
ic_beta_degree – beta angle of panorama center.
- Returns:
mapX mapY
please reference: https://github.com/perseverance-tech-tw/moildev
- maps_recenter(alpha_max, beta_degree)[source]
Create maps for reverse image. this can work using input panorama rotation image
- Parameters:
alpha_max – max of alpha. The recommended value is half of camera FOV. For example, use 90 for a 180 degree fisheye images and use 110 for a 220 degree fisheye images.
beta_degree – beta angle.
- Returns:
maps_x_reverse, maps_y_reverse
- anypoint_mode1(image, alpha, beta, zoom)[source]
Generate anypoint view image. for mode 1, the result rotation is betaOffset degree rotation around the Z-axis(roll) after alphaOffset degree rotation around the X-axis(pitch). for mode 2, The result rotation is thetaY degree rotation around the Y-axis(yaw) after thetaX degree rotation around the X-axis(pitch).
- Parameters:
image – source image given
alpha – the alpha offset that corespondent to the pitch rotation
beta – the beta offset that corespondent to the yaw rotation
zoom – decimal zoom factor, normally 1..12
- Returns:
anypoint image
please reference: https://github.com/perseverance-tech-tw/moildev
- anypoint_mode2(image, pitch, yaw, zoom)[source]
Generate anypoint view image. for mode 1, the result rotation is betaOffset degree rotation around the Z-axis(roll) after alphaOffset degree rotation around the X-axis(pitch). for mode 2, The result rotation is thetaY degree rotation around the Y-axis(yaw) after thetaX degree rotation around the X-axis(pitch).
- Parameters:
image – source image given
pitch – the alpha offset that corespondent to the pitch rotation
yaw – the beta offset that corespondent to the yaw rotation
zoom – decimal zoom factor, normally 1..12
- Returns:
anypoint image
please reference: https://github.com/perseverance-tech-tw/moildev
- anypoint_car(image, pitch, yaw, roll, zoom)[source]
Anypoint car mode with roll rotation
- Parameters:
image – source image given
pitch – the alpha offset that corespondent to the pitch rotation
yaw – the beta offset that corespondent to the yaw rotation
roll – the beta offset that corespondent to the yaw rotation
zoom – decimal zoom factor, normally 1..12
- Returns:
anypoint image
please reference: https://github.com/perseverance-tech-tw/moildev
- panorama_tube(image, alpha_min, alpha_max)[source]
The panorama image
- Parameters:
image – image source given
alpha_min
alpha_max
- Returns:
Panorama view image
please reference: https://github.com/perseverance-tech-tw/moildev
- panorama_car(image, alpha_max, alpha, beta, left, right, top, bottom, flip=False)[source]
The function that generate a moil dash panorama image from fisheye camera. the image can control by alpha to change the pitch direction and beta for yaw direction. in order to select the roi, we can control by the parameter such as left, right, top, and bottom.
- Parameters:
image – input fisheye image
alpha_max
alpha – change the pitch direction(0 ~ 180)
beta – change the yaw direction(-90 ~ 90)
left – crop the left image by scale(0 ~ 1)
right – crop the right image by scale(0 ~ 1)
top – crop the top image by scale(0 ~ 1)
bottom – crop the bottom image by scale(0 ~ 1)
flip – Horizontal flip (Bool)
- Returns:
Panorama image
- recenter(image, alpha_max, ic_alpha_degree, ic_beta_degree)[source]
Change the optical point of fisheye image.
- Parameters:
image – input image
alpha_max – max of alpha. The recommended value is half of camera FOV. For example, use 90 for a 180 degree fisheye images and use 110 for a 220 degree fisheye images.
ic_alpha_degree – alpha angle of panorama center
ic_beta_degree – beta angle of panorama center
- Returns:
reverse image
- get_alpha_from_rho(rho)[source]
Get the alpha from rho image.
- Parameters:
rho – the value of rho given
- Returns:
alpha
- get_rho_from_alpha(alpha)[source]
Get rho image from alpha given.
- Parameters:
alpha – the value of alpha given
- Returns:
rho image
- get_alpha_beta(coordinateX, coordinateY, mode=1)[source]
Get the alpha beta from specific coordinate image.
- Parameters:
coordinateX
coordinateY
mode
- Returns:
alpha, beta (if you get none, the coordinate is out of range that can cover)
please reference: https://github.com/perseverance-tech-tw/moildev
Moil_camera Models
Moil_fisheye_marker Models
This module provides functionality for adding markers to fisheye images.
- class models.moilutils.moil_fisheye_marker.fisheye_marker.MoilFisheyeMarker[source]
Bases:
object
A class for marking points on fisheye images.
- static point(image: ndarray, pixel_coordinate: Tuple[int, int], radius: int = None, color: tuple = (0, 0, 255), fill: bool = False) ndarray [source]
Marks a point on the image at the specified pixel coordinates.
- Parameters:
image (np.ndarray) – Input image.
pixel_coordinate (Tuple[int, int]) – Pixel coordinates (x, y) of the point.
radius (int, optional) – Radius of the circle. If not provided, it will be automatically determined based on image size.
color (tuple, optional) – Color of the point marker in BGR format. Default is (0, 0, 255) for red.
fill (bool, optional) – If True, fills the circle. Default is False.
- Returns:
Image with the marked point.
- Return type:
np.ndarray
- static crosshair(image: ndarray, pixel_coordinate: Tuple[int, int], color: Tuple[int, int, int] = (0, 0, 255)) ndarray [source]
Draws a crosshair at the specified pixel coordinates on the image.
- Parameters:
image (np.ndarray) – Input image.
pixel_coordinate (Tuple[int, int]) – Pixel coordinates (x, y) of the center of the crosshair.
color (Tuple[int, int, int], optional) – Color of the crosshair in BGR format. Default is (0, 0, 255) for red.
- Returns:
Image with the drawn crosshair.
- Return type:
np.ndarray
- static cross(image: ndarray, pixel_coordinate: Tuple[int, int], color: Tuple[int, int, int] = (0, 0, 255)) ndarray [source]
Draws a cross at the specified pixel coordinates on the image.
- Parameters:
image (np.ndarray) – Input image.
pixel_coordinate (Tuple[int, int]) – Pixel coordinates (x, y) of the center of the cross.
color (Tuple[int, int, int], optional) – Color of the cross in BGR format. Default is (0, 0, 255) for red.
- Returns:
Image with the drawn cross.
- Return type:
np.ndarray
- static square(image: ndarray, pixel_coordinate: Tuple[int, int], color: Tuple[int, int, int] = (0, 0, 255)) ndarray [source]
Draws a square around the specified pixel coordinates on the image.
- Parameters:
image (np.ndarray) – Input image.
pixel_coordinate (Tuple[int, int]) – Pixel coordinates (x, y) of the center of the square.
color (Tuple[int, int, int], optional) – Color of the square in BGR format. Default is (0, 0, 255) for red.
- Returns:
Image with the drawn square.
- Return type:
np.ndarray
- static triangle(image: ndarray, pixel_coordinate: Tuple[int, int], color: Tuple[int, int, int] = (0, 0, 255)) ndarray [source]
Draws a triangle centered at the specified pixel coordinates on the image.
- Parameters:
image (np.ndarray) – Input image.
pixel_coordinate (Tuple[int, int]) – Pixel coordinates (x, y) of the center of the triangle.
color (Tuple[int, int, int], optional) – Color of the triangle in BGR format. Default is (0, 0, 255) for red.
- Returns:
Image with the drawn triangle.
- Return type:
np.ndarray
- static boundary_fov(image: ndarray, moildev, fov: int = 90, color: tuple = (255, 255, 0)) ndarray [source]
Draws the boundary of the field of view (FOV) on the image for a given Moildev object and FOV angle.
- Parameters:
image (np.ndarray) – Input image.
moildev – Moildev object representing the camera model.
fov (int, optional) – Field of view angle in degrees. Default is 90 degrees.
color (tuple, optional) – Color of the boundary in BGR format. Default is (255, 255, 0) for light blue.
- Returns:
Image with the drawn FOV boundary circle.
- Return type:
np.ndarray
- static line_horizontal_vertical(image: ndarray, pixel_coordinate: Tuple[int, int], color: Tuple[int, int, int] = (0, 0, 0), translucent: float = 0.5)[source]
Draws horizontal and vertical lines passing through the specified pixel coordinates on the image.
- Parameters:
image (np.ndarray) – Input image.
pixel_coordinate (Tuple[int, int]) – Pixel coordinates (x, y) through which the lines pass.
color (Tuple[int, int, int], optional) – Color of the lines in BGR format. Default is (0, 0, 0) for black.
translucent (float, optional) – Transparency level of the lines. Should be between 0 and 1. Default is 0.5, where 0 means fully transparent and 1 means fully opaque.
- Returns:
Image with the drawn horizontal and vertical lines.
- Return type:
np.ndarray
- static line_p2p_distorted(image: ndarray, moildev, parameter_file: str, start_img_point: tuple, end_img_point: tuple, color: Tuple[int, int, int] = (0, 0, 255)) ndarray [source]
Draws a distorted line between two points on the image based on the camera model parameters.
- Parameters:
image (np.ndarray) – Input image.
moildev – Moildev object representing the camera model.
parameter_file (str) – Path to the JSON file containing camera model parameters.
start_img_point (tuple) – Pixel coordinates (x, y) of the starting point of the line.
end_img_point (tuple) – Pixel coordinates (x, y) of the ending point of the line.
color (Tuple[int, int, int], optional) – Color of the line in BGR format. Default is (0, 0, 255) for red.
- Returns:
Image with the drawn distorted line between the two points.
- Return type:
np.ndarray