P2DingoCV.HotspotLogic.DiagonsticsUtil
Classes
|
Utility class for visualizing and saving images, histograms, and tables. |
- class P2DingoCV.HotspotLogic.DiagonsticsUtil.VisualUtils(pathToVisuals='visuals')[source]
Bases:
object
Utility class for visualizing and saving images, histograms, and tables.
Provides methods to plot image histograms, save frames, plot frequency arrays, and pretty-print tables. All outputs are saved to the specified directory.
- Parameters:
pathToVisuals (str)
- __init__(pathToVisuals='visuals')[source]
Initialize the VisualUtils object and create output directory.
- Parameters:
pathToVisuals (str) – Path to directory where visuals will be saved. Defaults to “visuals”.
- plotFreqArray(arr, title)[source]
Plot a 1D array as a bar chart and save it as a PNG.
- Parameters:
arr (np.ndarray) – 1D array of values to plot.
title (str) – Title of the plot, also used as filename.
- Return type:
None
- plotHistogram(frame)[source]
Plot and save the histogram of an image.
Supports grayscale and BGR images. Saves the histogram as a PNG in the output directory.
- Parameters:
frame (np.ndarray) – Image array (grayscale or BGR).
- Returns:
The input frame, also displayed using OpenCV.
- Return type:
np.ndarray | None
- Raises:
AssertionError – If frame is None.
ValueError – If the image format is unsupported.
- static printTable(data, headers=None, precision=2)[source]
Pretty-print a list of lists (or tuples) as a table with borders.
Numeric values are formatted to the specified precision. Nested tuples/lists are also formatted.
- Parameters:
data (list[list|tuple]) – 2D list or list of tuples containing table data.
headers (list[str] | None) – Optional list of column headers.
precision (int) – Number of decimal places for numeric values. Defaults to 2.
- Return type:
None
- saveFrame(frame, tag, frameCount, folder='frames')[source]
Save an image frame with a tag and frame count.
- Parameters:
frame (np.ndarray) – Image frame to save.
tag (str) – Descriptive tag for the frame.
frameCount (int) – Frame number to include in the filename.
folder (str) – Subfolder under the output path to save frames. Defaults to “frames”.
- Return type:
None