thermography

The thermography package implements different computer vision and image progessing algorithms for automatic detection of solar panel modules.

Submodules

thermography.module_map module

class ModuleMap[source]

Bases: object

Class responsible for storing a spatial representation of the detected modules. Each module is keyed by an unique ID Multiple detections of the same module are considered and the existing module is updated in the internal representation of the map.

Example:
module_map = ModuleMap()
module_map.insert([rect1, rect2, ...], frame_id=0, motion_estimate = np.array([0, 0])
# module_map.global_module_map = {0: <..., rect1, frame_id_history=[0]>;
#                                 1: <..., rect2, frame_id_history=[0]>,
#                                 2: <..., rect3, frame_id_history=[0]>}
motion = np.array([4, 2])
rect1 += motion
module_map.insert([rect1, rect4], frame_id=1, motion_estimate=motion)
# module_map.global_module_map = {0: <..., rect1, frame_id_history=[0, 1]>;
#                                 1: <..., rect2, frame_id_history=[0]>,
#                                 2: <..., rect3, frame_id_history=[0]>,
#                                 3: <..., rect4, frame_id_history=[1]>}

Initializes the module map to be empty.

insert(rectangle_list: list, frame_id: int, motion_estimate: numpy.ndarray = None)[source]

Inserts all rectangles contained in the list passed as first parameter into the global map representation.

Parameters:
  • rectangle_list – List of detected rectangles to be inserted into the global module map.
  • frame_id – Frame id of the current image frame associated to the detected rectangles.
  • motion_estimate – Numpy array representing the motion estimate between the last frame (ID-1) and the frame containing the rectangles.
update_class_belief(probabilities: dict) → None[source]

Updates the current class probability for the modules being detected in the last step.

Parameters:probabilities – A dictionary keyed by the module ID, whose value is a probability distribution over the classes.

thermography.thermo_app module

class ThermoApp(input_video_path, camera_param_file)[source]

Bases: object

Application implementing the routines for module detections and analysis under the form of an object.

Example:
app = ThermoApp(path_to_input_video, camera_params)
app.run()

Initializes the ThermoApp instance by defining default parameters.

Parameters:
  • input_video_path – Absolute path to the input video.
  • camera_param_file – Parameter file of the camera.
classify_detected_modules() → None[source]

Classifies the modules in the global module map which have been detected in the current frame.

This function classifies all modules detected in the current frame which have been registered in the self.module_map module map. The modules are classified by the self.inference object which generates a class probability distribution for each module.

Note

This function must be called after inserting the modules in the global module map!

See Also:
Module inference for more details.
cluster_segments() → None[source]

Clusters the segments in self.last_segments according to the parameters in self.segment_clustering_parameters.

See Also:
Module segment_clustering for more details.
create_classes_image()[source]
create_module_list()[source]
create_module_map_image()[source]
create_rectangle_image()[source]
create_segment_image()[source]
detect_edges() → None[source]

Detects the edges in the self.last_preprocessed_image using the parameters in self.edge_detection_parameters.

See Also:
Module edge_detection for more details.
detect_intersections() → None[source]

Detects the intersections between the segments in self.last_cluster_list according to the parameters in self.intersection_detection_parameters.

See Also:
Module intersection_detection for more details.
detect_rectangles() → None[source]

Detects the rectangles defined through the intersections in self.last_intersections according to the parameters in self.rectangle_detection_parameters.

See Also:
Module rectangle_detection for more details.
detect_segments() → None[source]

Detects the segments in the self.last_edges_frame using the parameters in self.segment_detection_parameters.

See Also:
Module segment_detection for more details.
frames

Returns the frames loaded by the self.video_loader.

load_video(start_frame: int, end_frame: int) → None[source]

Loads the video associated with the absolute path given to the constructor between the frames indicated as argument.

Parameters:
  • start_frame – Starting frame (inclusive)
  • end_frame – Termination frame (exclusive), is set to None, the entire video will be loaded.

See Also: Module io for more details.

preprocess_frame() → None[source]

Preprocesses the frame stored at self.last_input_frame by scaling, rotating and computing the attention regions.

See Also:
Module preprocessing for more details.
reset() → None[source]

Resets the values computed in the last step.

run() → None[source]

Runs the ThermoApp by iterating over all frames and detecting the modules. This function does not perform module classification.

step(frame_id, frame) → bool[source]

Perform a single step of the module detection using the frame passed as argument.

If the detection step is successful, the self.last_* parameters are filled with the newly computed elements.

Parameters:
  • frame_id – Integer identifying the id of the frame to be processed.
  • frame – Numpy array containing the RGB image representing the frame to be processed.
Returns:

True if the detection was successful, False otherwise.