Source code for imagepypelines.core.Exceptions

# @Email: jmaggio14@gmail.com
# @Website: https://www.imagepypelines.org/
# @License: https://github.com/jmaggio14/imagepypelines/blob/master/LICENSE
# @github: https://github.com/jmaggio14/imagepypelines
#
# Copyright (c) 2018-2019 Jeff Maggio, Nathan Dileas, Ryan Hartzell
from .imports import import_opencv
from .constants import NUMPY_TYPES
cv2 = import_opencv()

[docs]class CameraReadError(ValueError): """Exception raised when the CameraCapture device is unable to read the camera """ pass
[docs]class InvalidInterpolationType(TypeError): """ Exception for an invalid interpolation Type where it's applicable Args: interp (cv2.constant): interpolation type """ def __init__(self,interp): interp_string = """cv2.INTER_NEAREST --> {} cv2.INTER_LINEAR --> {} cv2.INTER_AREA --> {} cv2.INTER_CUBIC --> {} cv2.INTER_LANCZOS4 --> {}""".format(cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_AREA, cv2.INTER_CUBIC, cv2.INTER_LANCZOS4) error_string = "'interpolation' ({}) must be one of the following!"\ .format(interp) error_string = error_string + '\n' + interp_string super(InvalidInterpolationType,self).__init__(error_string)
[docs]class InvalidNumpyType(TypeError): """ Exception for an invalid interpolation Type where it's applicable Args: dtype (np.dtype): numpy datatype """ def __init__(self,dtype): error_string = "'dtype' ({}) must be one of the following!"\ .format(dtype) error_string += "\n\t".join(str(t) for t in NUMPY_TYPES) super(InvalidNumpyType,self).__init__(error_string)
[docs]class CrackedPipeline(ValueError): pass
[docs]class BlockRequiresLabels(ValueError): pass
[docs]class IncompatibleTypes(Exception): pass
[docs]class InvalidBlockInputData(TypeError): def __init__(self,block): error_msg = "invalid input to block: {}, must be a list containing ({})".format( block.name, block.io_map.inputs, ) super(InvalidBlockInputData,self).__init__(error_msg)
[docs]class InvalidBlockInputLabels(TypeError): def __init__(self,block): error_msg = "{}: input labels must a list or NoneType".format( block.name, ) super(InvalidBlockInputData,self).__init__(error_msg)
[docs]class InvalidProcessStrategy(TypeError): def __init__(self,block): error_msg = "{}: function 'batch_process' must return a list!".format( block.name) super(InvalidProcessStrategy,self).__init__(error_msg)
[docs]class InvalidLabelStrategy(TypeError): def __init__(self,block): error_msg = "{}: function 'labels' must return a list or NoneType!".format( block.name) super(InvalidLabelStrategy,self).__init__(error_msg)
[docs]class DataLabelMismatch(TypeError): def __init__(self,processed,labels): error_msg = "you must have an equal number of processed ({}) and labels ({}). " error_msg += "Perhaps the size of your dataset is changing? " error_msg += "If so, then you'll have to modify number of labels, " error_msg += "look into overloading 'before_process', 'labels', " error_msg += "or 'label' depending on your system".format( len(processed), len(labels) ) super(DataLabelMismatch,self).__init__(error_msg)
[docs]class CachingError(RuntimeError): pass
[docs]class ChecksumError(RuntimeError): pass