arcjetCV.utils.output module

class arcjetCV.utils.output.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

JSON encoder for NumPy arrays.

This class extends the JSONEncoder class to handle NumPy arrays, converting them to lists before encoding.

Example: `python encoder = NumpyEncoder() encoded_array = encoder.encode(numpy_array) `

Attributes:

None

default(obj)[source]

Convert NumPy arrays to lists for JSON serialization.

Parameters:

obj – Object to encode.

Returns:

Encoded object.

class arcjetCV.utils.output.OutputListJSON(path)[source]

Bases: list

Extension of list with write to file function, expected to hold dictionary objects corresponding to analysis of individual video frames.

This class extends the list class and provides a method to write its contents to a JSON file. It is designed to hold dictionaries corresponding to the analysis of individual video frames. The filename must contain low and high index constraints delimited by underscores, e.g., “myoutput_0_10.json”.

Args:

list (list): Base list class. filepath (str): Path for saving file.

Example: `python output_list = OutputListJSON('output.json') output_list.append({'INDEX': 0, 'data': 'some_data'}) output_list.write() `

Attributes:

path (str): Path to the JSON file. folder (str): Directory containing the JSON file. _lock (threading.Lock): Threading lock for thread-safe operations. prefix (list): Prefix extracted from the filename. low_index (int): Low index constraint extracted from the filename. high_index (int): High index constraint extracted from the filename.

append(obj)[source]

Appends an object to the list if its INDEX is within the specified range.

Parameters:

obj – Object to append.

load(path, extend=True)[source]

Loads data from a JSON file.

Parameters:
  • path – Path to the JSON file.

  • extend – Whether to extend the current list with the loaded data (default=True).

Returns:

Loaded data.

write(indent=None)[source]

Writes the list to a JSON file.

Parameters:

indent – Number of spaces for indentation (default=None).