import enum
from typing import Any,Tuple
import numpy
from typing import Any
"""
SAIL basic
===============

Provides
  1. Basic data types, mainly including Handle and Tensor 
  2. Some common basic interfaces that do not rely on sophon multimedia

"""


class Dtype(enum.Enum):
    BM_FLOAT32 = 0
    BM_FLOAT16 = 1
    BM_INT8 = 2
    BM_UINT8 = 3
    BM_INT16 = 4
    BM_UINT16 = 5
    BM_INT32 = 6
    BM_UINT32 = 7
    BM_BFLOAT16 = 8

class IOMode(enum.Enum):
    SYSI = 0
    SYSO = 1
    SYSIO = 2
    DEVIO = 3

class LogLevel(enum.Enum):
    """
    The Enumeration class of log level, including TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF.
    """
    TRACE       = 0
    DEBUG       = 1
    INFO        = 2
    WARN        = 3
    ERROR       = 4
    CRITICAL    = 5
    OFF         = 6

class Handle:
    def __init__(self, dev_id: int) -> Handle:
        """ 
        Constructor with device id.

        Parameters:
        ----------
        dev_id: int
           ID of TPU.
        """
        pass

    def get_device_id(self) -> int:
        """ Get device id of this handle. """
        pass

    def get_sn(self) -> str:
        """ Get Serial Number. """
        pass

    def get_target(self) -> str:
        """ Get TPU chip type of this handle. """
        pass

class Tensor:
    def __init__(self, handle: Handle, shape: list[int], 
        dtype: Dtype = Dtype.BM_FLOAT32,
        own_sys_data: bool = False,
        own_dev_data: bool = False) -> Tensor: pass
        
    def __init__(self, handle: Handle, data: numpy.ndarray[Any,numpy.dtype[Any]], own_sys_data: bool = True, own_dev_data: bool = True) -> Tensor: 
        """
        Constructor allocates device memory of the tensor use numpy.ndarray, \n
        Input numpy must be C_CONTIGUOUS True

        Parameters:
        ----------
        handle: Handle
        data: numpy.ndarray
            dtype is float_ | uint8 | int32 | int_, C_CONTIGUOUS flag must be True.
        own_sys_data: bool, default is True.
            Indicator of whether own system memory, If false, the memory will be copied to device directly  
        own_dev_data: bool, default is True.
        """
        pass
    
    def __init__(self, other: Tensor, ranges: list[Tuple[int,int]] | list[tuple[int,int],tuple[int,int]], d2d_flag = True):
        """
        Create a tensor from specific range of another tensor.
        like the slice function in numpy.
        Only supports tensor with at most 2D.

        Parameters:
        ----------
        other: Tensor
            other 2D or 1D tensor. 
        ranges: list(tuple())
            a list of tuple
            if you want to slice a tensor like tensor[20:40, 50:60] in numpy
            you can give the para ranges = [(20,40), (50,60)]
        
        d2d_flag: bool
            true for d2d
            false for c2c

        """
        pass

    def __init__(self, src: Tensor, shape: list[int], offset: int, no_copy: bool = True):
        """
        Create a Tensor from another existing Tensor. 
        The created Tensor can reuse src's memory without copy.

        Parameters:
        ----------
        shape: list[int]
            The created Tensor's shape.
        offset: int
            Start reading src Tensor's momery from this offset (in element, not byte). 
        no_copy: bool
            If no_copy flag is set to True, the created tensor will reuse 
            the src's memory, instead of allocating new memory.

        """
        pass
  
    def shape(self) -> list[int]: pass
 
    def dtype(self) -> int: pass
 
    def reshape(self, shape: list[int]) -> None: pass

    def own_sys_data(self) -> bool: pass

    def own_dev_data(self) -> bool: pass

    def size(self) -> int: 
        """ Returns the number of elements in this tensor. """
        pass

    def element_size(self) -> int: 
        """ Returns the size in bytes of an individual element. """
        pass

    def nbytes(self) -> int: 
        """ Return the total number of bytes occupied by all elements of Tensor. """
        pass

    def asnumpy(self, shape: list[int] = None) -> numpy.ndarray[Any,numpy.dtype[Any]] : 
        """
        Get ndarray in system memory of the tensor.

        Parameters:
        ----------
        shape: list[int], optional
            If provided, Shape of output data. 
        """
        pass

    def update_data(self, data: numpy.ndarray[Any, numpy.dtype[numpy.any]]) -> None: 
        """
        If own_sys_data, Update system data of the tensor. \n
        Else if own_dev_data Update device data of the tensor. 

        Parameters:
        ----------
        data: numpy.ndarray
            dtype is float_ | uint8 | int32 | int_.
        """
        pass

    def scale_from(self, data: numpy.ndarray[Any, numpy.dtype[numpy.any]], scale: float) -> None:
        """ 
        Scale data to tensor in system memory

        Parameters:
        ----------
        data : ndarray
            Data of type float32 to be scaled from. 
        scale : float
            Scale value. 
        """
        pass

    def scale_to(self, scale: float, shape: list[int] = None) -> numpy.ndarray[Any, numpy.dtype[Any]] :
        """ 
        Scale tensor to data in system memory.

        Parameters:
        ----------
        scale : float
            Scale value. 
        shape : list[int], optional
            If provided, Shape of output data to scale to. 

        """
        pass

    def sync_s2d(self, size: int = None) -> None:
        """ 
        move size data from system to device

        Parameters:
        ----------
        size : int, optional
            If provided, byte size to be copied.
            else, move all data from system to device.
        """
        pass

    def sync_s2d(self, src: Tensor, offset_src: int, offset_dst: int, len: int):
        """ 
        Copy data from system memory to device memory with specified size.

        Parameters:
        ----------
        src: Tensor, Specifies the Tensor to be copied from.
        offset_src: int, Specifies the number of elements to offset in the source Tensor from where to start copying.
        offset_dst: int, Specifies the number of elements to offset in the destination Tensor from where to start copying.
        len: int, Specifies the length of the copy, i.e., the number of elements to copy.
        """
        pass

    def sync_d2s(self, size: int = None) : 
        """ 
        move size data from device to system

        Parameters:
        ----------
        size : int, optional
            If provided, byte size to be copied.
            else, move size data from device to system
        """
        pass

    def sync_d2s(self, src: Tensor, offset_src: int, offset_dst: int, len: int):
        """ 
        Copy data from device memory to system memory with specified size.

        Parameters:
        ----------
        src: Tensor, Specifies the Tensor to be copied from.
        offset_src: int, Specifies the number of elements to offset in the source Tensor from where to start copying.
        offset_dst: int, Specifies the number of elements to offset in the destination Tensor from where to start copying.
        len: int, Specifies the length of the copy, i.e., the number of elements to copy.
        """
        pass

    def sync_d2d(self, src: Tensor, offset_src: int, offset_dst: int, len: int):
        """ 
        Copy data from device memory to device memory with specified size.

        Parameters:
        ----------
        src: Tensor, Specifies the Tensor to be copied from.
        offset_src: int, Specifies the number of elements to offset in the source Tensor from where to start copying.
        offset_dst: int, Specifies the number of elements to offset in the destination Tensor from where to start copying.
        len: int, Specifies the length of the copy, i.e., the number of elements to copy.
        """
        pass
    
    def pysys_data(self) ->  numpy.ndarray[Any, numpy.dtype[numpy.int32]] :   pass

    def memory_set(self, c: any) -> None : 
        """
        Fill memory with a scalar, it will be automatically converted to tensor's dtype.

        Parameters:
        ----------
        c: int
        """
        pass
    
    def zeros(self) -> None:
        """
        Fill memory with zeros
        """

    def ones(self) -> None:
        """
        Fill memory with ones
        """

    def is_dev_data_valid(self) -> bool:
        """
        Check whether device data is valid
        """

    def is_sys_data_valid(self) -> bool:
        """
        Check whether system data is valid
        """

    def device_id(self) -> int:
        """
        Get device id.
        """

    def dump_data(self, file_name: str, bin:bool = False) -> None:
        """
        Dump Tensor data to file.

        Parameters:
        ----------
        file_name: str
            file path to dump tensor
        
        bin: bool
            binary format, default False.
        """
        pass

class TensorPTRWithName:
    def get_name(self) -> str:
        """ Get the name of the Tensor.

        pass
        """

    def get_data(self) -> Tensor:
        """ Get the Tensor.
        
        pass
        """

def ReleaseTensorPtr(tensor_with_name: TensorPTRWithName) -> None:
    """ Release TensorPTRWithName data.

    pass
    """

def CreateTensorPTRWithName(name: str, handle: Handle, data: numpy.ndarray[Any,numpy.dtype[Any]], own_sys_data: bool = False, own_dev_data:bool = True) -> TensorPTRWithName:
    """ Create TensorPTRWithName use name and numpy array.

    Parameters:
    ----------
    name: input numpy array name
    handle: Handle with result
    data: input numpy array
    own_sys_data: bool, default is False.
        Indicator of whether own system memory, If false, the memory will be copied to device directly  
    own_dev_data: bool, default is True.
    Returns
    -------
    TensorPTRWithName
    """

def get_available_tpu_num() -> int:
    """
    Get the number of available TPUs.

    Returns
    -------
    Number of available TPUs.
    """
    pass

def set_print_flag(print_flag: bool) -> None:
    """ Print main process time use  """
    pass

def set_dump_io_flag(dump_io_flag: bool) -> None:
    """ Dump io data"""
    pass

def argmax(tensor:Tensor) -> int:
    """ 
    Get the indices of the maximum value

    Parameters:
    ----------
    tensor : Tensor, input tensor.

    Returns
    -------
    int, the indices of the maximum value.
    """ 
    pass
  

def argmin(tensor:Tensor) -> int:
    """ 
    Get the indices of the minimum value

    Parameters:
    ----------
    tensor : Tensor, input tensor.

    Returns
    -------
    int, the indices of the minimum value.
    """ 
    
def set_loglevel(loglevel: LogLevel) -> int:
    """
    Set the level of output log.

    Parameters:
    ----------
    loglevel: LogLevel
        The optional level is TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF. The default level is INFO. 

    Returns:
    ----------
        int, 0 for success and -1 for failure.
    """
    pass


class Engine:
    def __init__(self, dev_id: int) : pass
    def __init__(self, handle: Handle) : pass
    def __init__(self, bmodel_path: str, dev_id: int, mode:IOMode) : pass
    def __init__(self, bmodel_bytes: bytes, bmodel_size: int, dev_id: int, mode:IOMode) : pass

    def load(self, bmodel_path: str) -> bool: 
        """ Load bmodel from file """
        pass

    def load(self, bmodel_bytes: bytes, bmodel_size: int) -> bool: 
        """ load bmodel from system memory """
        pass

    def get_handle(self) -> Handle:
        """Get Handle instance """
        pass

    def get_device_id(self) -> int:
        """Get device id of this engine """
        pass

    def get_graph_names(self) -> list[str]:
        """Get all graph names in the loaded bomodels """
        pass

    def set_io_mode(self, graph_name: str, mode: IOMode) -> bool:
        """Set IOMode for a graph """
        pass

    def get_input_names(self, graph_name: str) -> list[str]:
        """Get all input tensor names of the specified graph """
        pass

    def get_output_names(self, graph_name: str) -> list[str]:
        """Get all output tensor names of the specified graph """
        pass
    
    def get_max_input_shapes(self, graph_name: str) -> dict[str, list[int]]:
        """Get max shapes of input tensors in a graph """
        pass

    def get_input_shape(self, graph_name: str, tensor_name: str) -> list[int]:
        """Get the shape of an input tensor in a graph """
        pass

    def get_max_output_shapes(self, graph_name: str) -> dict[str, list[int]]:
        """Get max shapes of output tensors in a graph """
        pass
    
    def get_output_shape(self, graph_name: str, tensor_name: str) -> list[int]:
        """Get the shape of an output tensor in a graph """
        pass
    
    def get_input_dtype(self, graph_name: str, tensor_name: str) -> Dtype:
        """Get data type of an input tensor"""
        pass
    
    def get_output_dtype(self, graph_name: str, tensor_name: str) -> Dtype:
        """Get data type of an output tensor"""
        pass

    def get_input_scale(self, graph_name: str, tensor_name: str) -> float:
        """Get scale of an input tensor"""
        pass

    def get_output_scale(self, graph_name: str, tensor_name: str) -> float:
        """Get scale of an output tensor"""
        pass

    def process(self, graph_name: str, 
        input: dict[str, Tensor], 
        output: dict[str, Tensor],
        core_list: list[int] = []) -> None:
        """
        Inference with provided input and output tensors

        Parameters:
        ----------
        graph_name: str
            The specified graph name.
        input : dict[str, Tensor]
            Input tensors.
        output : dict[str, Tensor]
            Output tensors.
        core_list : list[int]
            Cores used to inference, default is [].
        """
        pass
    
    def process(self, graph_name: str, 
        input: dict[str, Tensor], 
        input_shapes: dict[str, list[int]],
        output: dict[str, Tensor],
        core_list: list[int] = []) -> None:
        """
        Inference with provided input and output tensors and input shapes.
        
        Parameters:
        ----------
        graph_name: str
            The specified graph name.
        input : dict[str, Tensor]
            Input tensors.
        input_shapes : dict[str, list[int]]  
            Real input tensor shapes.
        output : dict[str, Tensor]
            Output tensors.
        core_list : list[int]
            Cores used to inference, default is [].
        """
        pass
    def process(self, graph_name: str,
        input_tensors: dict[str, numpy.ndarray[Any, numpy.dtype[numpy.float_]]],
        core_list: list[int] = []) -> dict[str, numpy.ndarray[Any, numpy.dtype[numpy.float_]]] :
        """
        Inference with provided input.

        Parameters:
        ----------
        graph_name : str
            The specified graph name.
        input_tensors: dict[str,ndarray]
            Input tensors.
        core_list : list[int]
            Cores used to inference, default is [].

        Returns
        -------
        dict[str,ndarray]
        """
        pass
    
    def create_input_tensors_map(self, graph_name: str, create_mode: int = -1) -> dict[str,Tensor]:
        """
        Create input tensors map, according to and bmodel.

        Parameters:
        ----------
        graph_name : str
            The specified graph name.
        create_mode: Tensor Create mode
            case 0: only allocate system memory 
            case 1: only allocate device memory
            case other: according to engine IOMode

        Returns
        -------
        dict[str,Tensor]
        """
        pass

    def create_output_tensors_map(self, graph_name: str, create_mode: int = -1) -> dict[str,Tensor]:
        """
        Create output tensors map, according to and bmodel.

        Parameters:
        ----------
        graph_name : str
            The specified graph name.
        create_mode: Tensor Create mode
            case 0: only allocate system memory 
            case 1: only allocate device memory
            case other: according to engine IOMode

        Returns
        -------
        dict[str,Tensor]
        """
        pass  


class MultiEngine:
    def __init__(self, bmodel_path: str, dev_ids: list[int], sys_out: bool = True, graph_idx: int = 0) : pass

    def set_print_flag(self, flag:bool) -> None :pass

    def set_print_time(self, flag:bool) -> None :pass
    
    def get_device_ids(self) -> list[int]:
        """Get device ids of this MultiEngine """
        pass

    def get_graph_names(self) -> list[str]:
        """Get all graph names in the loaded bomodels """
        pass  

    def get_input_names(self, graph_name: str) -> list[str]:
        """Get all input tensor names of the specified graph """
        pass

    def get_output_names(self, graph_name: str) -> list[str]:
        """Get all output tensor names of the specified graph """
        pass

    def get_input_shape(self, graph_name: str, tensor_name: str) -> list[int]:
        """Get the shape of an input tensor in a graph """
        pass

    def get_output_shape(self, graph_name: str, tensor_name: str) -> list[int]:
        """Get the shape of an output tensor in a graph """
        pass

    def process(self,
        input_tensors: dict[str, numpy.ndarray[Any, numpy.dtype[numpy.float_]]]) -> dict[str, numpy.ndarray[Any, numpy.dtype[numpy.float_]]] :
        """
        Inference with provided input.

        Parameters:
        ----------
        input_tensors: dict[str,ndarray]
            Input tensors.

        Returns
        -------
        dict[str,ndarray]
        """
        pass    


"""
SAIL Kernel API
===============

Provides
  1. Based on tpu kernel 

"""


class tpu_kernel_api_yolov5_detect_out:
    
    def __init__(self, device_id: int, shapes: list[list[int]], network_w:int = 640, network_h:int = 640, 
                module_file: str='/opt/sophon/libsophon-current/lib/tpu_module/libbm1684x_kernel_module.so'): 

        """ tpu_kernel_api_yolov5_detect_out Constructor.

        Parameters:
        ----------
        device_id: int, Device id
        shapes: list[list[int]],Input Data shape
        network_w: int, Network input width 
        network_h: int, Network input height 
        module_file: str, TPU Kernel module file,default is '/opt/sophon/libsophon-current/lib/tpu_module/libbm1684x_kernel_module.so'
        """
        pass


    def process(self,input:list[TensorPTRWithName], dete_threshold: float, nms_threshold: float, release_input: bool = False) -> list[list[tuple[int, int, int, int, int, float]]]:
        """ Process

        Parameters:
        ----------
        input: list[TensorPTRWithName], Input Data 
        dete_threshold: float, Detection threshold
        nms_threshold: float, NMS threshold
        release_input: bool, Release input memory

        Returns
        -------
        list[list[tuple[left, top, right, bottom, class_id, score]]]
            
        """

    def process(self,input:dict[str, Tensor], dete_threshold: float, nms_threshold: float, release_input: bool = False) -> list[list[tuple[int, int, int, int, int, float]]]:
        """ Process

        Parameters:
        ----------
        input: dict[str, Tensor], Input Data 
        dete_threshold: float, Detection threshold
        nms_threshold: float, NMS threshold
        release_input: bool, Release input memory

        Returns
        -------
        list[list[tuple[left, top, right, bottom, class_id, score]]]
            
        """
                
    def reset_anchors(self, anchors_new: list[list[list[int]]]):

        """ Reset Anchors
        
        Parameters:
        ----------
        anchors_new: list[list[list[int]]]
        
        Returns
        -------
        return 0 for success and other for failure
        """
        pass

class tpu_kernel_api_openpose_part_nms:
    
    def __init__(self, device_id: int, network_c: int,  
                module_file: str='/opt/sophon/libsophon-current/lib/tpu_module/libbm1684x_kernel_module.so'): 

        """ tpu_kernel_api_openpose_part_nms Constructor.

        Parameters:
        ----------
        device_id: int, Device id
        network_c: int, Pose input channel 
        module_file: str, TPU Kernel module file,default is '/opt/sophon/libsophon-current/lib/tpu_module/libbm1684x_kernel_module.so'
        """
        pass


    def process(self, input_data: TensorPTRWithName, shape: list[int], threshold: list[float], max_peak_num: list[int]) -> tuple[list[list[int]], list[list[float]], list[list[int]]]:
        """ Process

        Parameters:
        ----------
        input_data: TensorPTRWithName, Input Data 
        shape: list[int], Input Data width and height
        threshold: list[float], Detection threshold
        max_peak_num: list[int], Peak Detection maxium num

        Returns
        -------
        tuple[list[list[int]], list[list[float]], list[list[int]]]
            
        """

    def process(self, input: dict[str, Tensor], shape: list[int], threshold: list[float], max_peak_num: list[int]) -> tuple[list[list[int]], list[list[float]], list[list[int]]]:
        """ Process

        Parameters:
        ----------
        input: dict[str, Tensor], Input Data 
        shape: list[int], Input Data width and height
        threshold: list[float], Detection threshold
        max_peak_num: list[int], Peak Detection maxium num

        Returns
        -------
        tuple[list[list[int]], list[list[float]], list[list[int]]]
            
        """
                
    def reset_network_c(self, network_c_new: int):

        """ Reset channel_num
        
        Parameters:
        ----------
        network_c_new: int
        
        Returns
        -------
        return 0 for success and other for failure
        """
        pass


class algo_yolov5_post_1output:
    
    def __init__(self, shape: list[int], network_w:int = 640, network_h:int = 640, max_queue_size: int=20, input_use_multiclass_nms: bool=True, agnostic: bool=False): 
        """ algo_yolov5_post_1output Constructor.

        Parameters:
        ----------
        shape: list[int]
        network_w: int, network input width 
        network_h: int, network input height 
        max_queue_size: int, default 20
        input_use_multiclass_nms: bool, default True
        agnostic: bool, default False
        """
        pass

    def push_npy(self, 
                channel_idx : int, 
                image_idx : int, 
                data : numpy.ndarray[Any, numpy.dtype[numpy.float_]], 
                dete_threshold : float, 
                nms_threshold : float,
                ost_w : int, 
                ost_h : int,
                padding_left : int,
                padding_top : int,
                padding_width : int,
                padding_height : int) -> int:
        """ algo_yolov5_post_1output push data.

        Parameters:
        ----------
        
        channel_idx : Channel index number of the image.
        image_idx : Image index number of the image.
        data : Input Data
        dete_threshold : Detection threshold
        nms_threshold : NMS threshold
        ost_w : Original image width
        ost_h : Original image height
        padding_left : Padding left
        padding_top : Padding top
        padding_width : Padding width
        padding_height : Padding height

        Returns
        -------
        return 0 for success and other for failure
        """
        pass

    def get_result_npy(self) -> tuple[tuple[int, int, int, int, int, float],int, int]:
        """ Get the PostProcess result
        
        Returns
        -------
        tuple[tuple[left, top, right, bottom, class_id, score],channel_idx, image_idx]
            
        """
        pass


    def push_data( self, 
        channel_idx : list[int], 
        image_idx : list[int], 
        input_data : TensorPTRWithName, 
        dete_threshold : list[float],
        nms_threshold : list[float],
        ost_w : list[int],
        ost_h : list[int],
        padding_attr : list[list[int]]) -> int:
        """ algo_yolov5_post_1output push data.

        Parameters:
        ----------
        
        channel_idx : Channel index number of the images.
        image_idx : Image index number of the images.
        data : Input Data
        dete_threshold : Detection thresholds
        nms_threshold : NMS thresholds
        ost_w : Original images width
        ost_h : Original images height
        padding_attr : Padding Attribute[start_x, start_y, width, height]

        Returns
        -------
        return 0 for success and other for failure
        """
        pass


class bytetrack_tracker_controller:
    def __init__(self, frame_rate:int = 30, track_buffer:int = 30):

        """bytetrack Constructor

        Parameters:
        ----------
        frame_rate: int, max_lost_time = int(frame_rate / 30.0 * track_buffer)
        track_buffer: int, max_lost_time = int(frame_rate / 30.0 * track_buffer)
        
        """

    def process(detected_objects:list[tuple[int, int, int, int, int, float]])-> list[tuple[int, int, int, int, int, float, int]]:
        
        """process interface

        Parameters:
        ----------
        detected_objects: list(tuple(left, top, right, bottom, class_id, score)), detected box list
        

        Returns:
        tracked_objects: list(tuple(left, top, right, bottom, class_id, score, track_id)), tracked box list output
        

        """

class deepsort_tracker_controller:
    def __init__(self, max_cosine_distance:float, nn_budget:int, k_feature_dim:int, max_iou_distance:float=0.7, max_age:int=30, n_init:int=3):

        """deepsort Constructor

        Parameters:
        ----------
        max_cosine_distance:float, 
        nn_budget:int, 
        k_feature_dim:int, 
        max_iou_distance:float=0.7, 
        max_age:int=30, 
        n_init:int=3,
        
        
        """

    def process(self, detected_objects:list[tuple[int, int, int, int, int, float]], features:list[Tensor])-> list[tuple[int, int, int, int, int, float, int]]:
        
        """process interface

        Parameters:
        ----------
        detected_objects: list(tuple(left, top, right, bottom, class_id, score)), detected box list
        
        features: list[sail.Tensor], features extracted by extractor

        Returns:
        tracked_objects: list(tuple(left, top, right, bottom, class_id, score, track_id)), tracked box list output
        

        """
    
    def process(self, detected_objects:list[tuple[int, int, int, int, int, float]], features:numpy.array)-> list[tuple[int, int, int, int, int, float, int]]:
        
        """process interface

        Parameters:
        ----------
        detected_objects: list(tuple(left, top, right, bottom, class_id, score)), detected box list
        
        features: numpy.array, features extracted by extractor

        Returns:
        tracked_objects: list(tuple(left, top, right, bottom, class_id, score, track_id)), tracked box list output
        

        """

class sort_tracker_controller:
    def __init__(self,max_iou_distance:float=0.7, max_age:int=30, n_init:int=3):

        """sort Constructor

        Parameters:
        ----------
        max_iou_distance:float=0.7, 
        max_age:int=30, 
        n_init:int=3,
        
        
        """

    def process(self, detected_objects:list[tuple[int, int, int, int, int, float]])-> list[tuple[int, int, int, int, int, float, int]]:
        
        """process interface

        Parameters:
        ----------
        detected_objects: list(tuple(left, top, right, bottom, class_id, score)), detected box list

        Returns:
        tracked_objects: list(tuple(left, top, right, bottom, class_id, score, track_id)), tracked box list output
        

        """

def nms_rotated(boxes: numpy.ndarray[Any, numpy.dtype[numpy.float32]], 
                scores: numpy.ndarray[Any, numpy.dtype[numpy.float32]], 
                threshold: float)-> list[int]:
    
    """nms with rotated boxes
        
    Parameters:
    ----------   
    boxes: numpy array (float), [x,y,w,h,theta]
    scores: numpy array (float), score of each box
    threshold: float, IOU threshold
    
    Returns:
    keep_id: list (int), the id of original boxes that kept after filtering

    
    """


class EngineLLM:
    def __init__(self, bmodel_path: str, dev_ids: list[int]) :
        """ Constructor, which loads bmodel from file. 
        
        Parameters:
        -----------
        bmodel_path: str
            The path of bmodel to be load.
        dev_ids : list[int]
            A list of int, representing device indexes used to inference.

        """
        pass

    def __init__(self, bmodel_path: str, flags: int, dev_ids: list[int]) :
        """ Constructor, which loads bmodel from file, with specific bmrt flags.
            Old SDK versions may not support this interface.
        
        Parameters:
        -----------
        bmodel_path: str
            The path of bmodel to be load.
        flags: int
            flags for bmruntime.
            Value should be set by enum BmrtFlag, like BM_RUNTIME_SHARE_MEM.
            Refer to Bmruntime doc for more details
        dev_ids : list[int]
            A list of int, representing device indexes used to inference.

        """
        pass

    def __init__(self, bmodel_bytes: bytes, bmodel_size: int, dev_ids: list[int]) : 
        """ Constructor, which loads bmodel from bytes.

        Parameters:
        -----------
        bmodel_bytes: bytes
            A bytes data representing the bmodel to be load.
        bmodel_size: int
            The size of the binary model in bytes. 
            This is typically the length of the `bmodel_bytes`.
        dev_ids : list[int]
            A list of int, representing device indexes used to inference.

        """ 
        pass

    def get_device_ids(self) -> list[int]:
        """Get device id list of this engine """
        pass

    def get_graph_names(self) -> list[str]:
        """Get all graph names in the loaded bmodels """
        pass

    def get_addr_mode(self, graph_name: str) -> int:
        """Get address assign mode of a graph
        
        Parameters:
        -----------
        graph_name: str
            The specified graph name.

        Returns:
        -----------
        addr_mode: int
            addr_mode 1 means bmodel will allocate device mem internally, and 0 means not.

        """
        pass

    def get_stage_num(self, graph_name: str) -> int:
        """Get stage num of a graph
        
        Parameters:
        -----------
        graph_name: str
            The specified graph name.

        Returns:
        -----------
        stage_num: int

        """
        pass

    def get_input_num(self, graph_name: str) -> int:
        """Get the number of a graph's input  """
        pass

    def get_output_num(self, graph_name: str) -> int:
        """Get the number of a graph's output  """
        pass

    def get_is_dynamic(self, graph_name: str) -> bool:
        """Get whether the graph is dynamic  """
        pass


    def process(self, graph_name: str, 
        input: dict[int, Tensor], 
        output: dict[int, Tensor],
        core_list: list[int] = [0]) -> int:
        # output: dict[int, Tensor],
        # core_list: list[int] = []) -> int:
        """
        Inference with provided input and output tensors

        Parameters:
        ----------
        graph_name: str
            The specified graph to inference.
        input : dict[int, Tensor]
            Input index and tensor.
        output : dict[int, Tensor]
            Output index and tensor.

        Returns:
        ----------
        return: int
            0 means success and else for failure.
        """
        pass


    def get_input_name(self, graph_name: str, index: int) -> str:
        """Get input tensor name of a specified index in a graph  """
        pass

    def get_input_tensor_devid(self, graph_name: str, index: int) -> int:
        """Get device id of a input tensor in a graph  """
        pass

    def get_output_name(self, graph_name: str, index: int) -> str:
        """Get output tensor name of a specified index in a graph  """
        pass

    def get_output_tensor_devid(self, graph_name: str, index: int) -> int:
        """Get device id of a output tensor in a graph  """
        pass
    
    def get_input_shape(self, graph_name: str, index: int, stage: int = 0) -> list[int]:
        """Get the shape of an input tensor in a graph """
        pass

    def get_input_max_shape(self, graph_name: str, index: int) -> list[int]:
        """Get the max shape of a graph's index-th input """
        pass

    def get_output_shape(self, graph_name: str, index: int, stage: int = 0) -> list[int]:
        """Get the shape of an output tensor in a graph """
        pass
    
    def get_output_max_shape(self, graph_name: str, index: int) -> list[int]:
        """Get the max shape of a graph's index-th output """
        pass

    def get_input_dtype(self, graph_name: str, index: int) -> Dtype:
        """Get data type of an input tensor"""
        pass

    def get_output_dtype(self, graph_name: str, index: int) -> Dtype:
        """Get data type of an output tensor"""
        pass

    def get_input_scale(self, graph_name: str, index: int) -> float:
        """Get scale of an input tensor"""
        pass

    def get_output_scale(self, graph_name: str, index: int) -> float:
        """Get scale of an output tensor"""
        pass

    def get_input_tensors(self, graph_name: str, tensor_name: str, stage: int = 0) -> dict[int,Tensor]: 
        """Get all input Tensors and input index, only for address assign mode is 1 """
        pass

    def get_input_tensors(self, graph_name: str, stage: int = 0) -> dict[int,Tensor]: 
        """Get all input Tensors and input index, only for address assign mode is 1 """
        pass

    def get_input_tensor(self, graph_name: str, index: int, stage: int = 0) -> Tensor: 
        """Get one input Tensor, only for address assign mode is 1 """
        pass

    def create_max_input_tensors(self, graph_name: str) -> dict[int,Tensor]: 
        """Create input Tensors according to max input shape, only for address assign mode 0 """
        pass

    def get_output_tensors(self, graph_name: str, tensor_name: str, stage: int = 0) -> dict[int,Tensor]: 
        """Get all output Tensors and output index, only for address assign mode is 1 """
        pass

    def get_output_tensors(self, graph_name: str, stage: int = 0) -> dict[int,Tensor]: 
        """Get all output Tensors and output index, only for address assign mode is 1 """
        pass

    def get_output_tensor(self, graph_name: str, index: int, stage: int = 0) -> Tensor: 
        """Get one output Tensor, only for address assign mode is 1 """
        pass

    def create_max_output_tensors(self, graph_name: str) -> dict[int,Tensor]: 
        """Create output Tensors according to max output shape, only for address assign mode 0 """
        pass

    def get_input_tensors_addrmode0(self, graph_name: str, stage: int = 0) -> dict[int,Tensor]: 
        """Get all input Tensors and input index, even when addr_mode is 0 """
        pass

    def get_output_tensors_addrmode0(self, graph_name: str, stage: int = 0) -> dict[int,Tensor]: 
        """Get all output Tensors and output index, even when addr_mode is 0 """
        pass

"""
SAIL multimedia
===============

Provides
  1.  Codec
  2.  Bmcv

"""


class Format(enum.Enum):
    FORMAT_YUV420P = 0
    FORMAT_YUV422P = 1
    FORMAT_YUV444P = 2
    FORMAT_NV12 = 3
    FORMAT_NV21 = 4
    FORMAT_NV16 = 5
    FORMAT_NV61 = 6
    FORMAT_NV24 = 7
    FORMAT_RGB_PLANAR = 8
    FORMAT_BGR_PLANAR = 9
    FORMAT_RGB_PACKED = 10
    FORMAT_BGR_PACKED = 11
    FORMAT_RGBP_SEPARATE = 12
    FORMAT_BGRP_SEPARATE = 13
    FORMAT_GRAY = 14
    FORMAT_COMPRESSED = 15
    FORMAT_ARGB_PACKED = 16

class ImgDtype(enum.Enum):
    DATA_TYPE_EXT_FLOAT32 = 0
    DATA_TYPE_EXT_1N_BYTE = 1
    DATA_TYPE_EXT_4N_BYTE = 2
    DATA_TYPE_EXT_1N_BYTE_SIGNED = 3
    DATA_TYPE_EXT_4N_BYTE_SIGNED = 4

class bmcv_resize_algorithm(enum.Enum):
    BMCV_INTER_NEAREST = 0
    BMCV_INTER_LINEAR = 1
    BMCV_INTER_BICUBIC = 2

class DecoderStatus(enum.Enum):
    NONE = -1
    OPENED = 0
    CLOSED = 1
    STATUS_MAX = 2

def set_decoder_env(env_name: str, env_value: str) -> None:
    """ Set Decoder environment, must set befor Decoder Constructor, else use default values
    
    refcounted_frames, extra_frame_buffer_num, rtsp_transport, stimeout, rtsp_flags, buffer_size, max_delay, probesize, analyzeduration
    """
    pass

def base64_encode(handle: Handle, input_bytes: bytes) -> bytes:
    """ Encode a base64 string """
    pass

def base64_decode(handle: Handle, encode_bytes: bytes) -> bytes:
    """ Decoder a base64 string """
    pass

def base64_encode_array(handle: Handle, input_arr: numpy.ndarray) -> bytes:
    """ Encode a base64 string """
    pass

def base64_decode_asarray(handle: Handle, encode_arr_bytes: bytes, array_type:str = "uint8") -> numpy.ndarray:
    """ Decoder a base64 string """
    pass

class bm_image:
    def width(self) -> int: pass
    def height(self) -> int: pass
    def format(self) -> Format: pass
    def dtype(self) -> ImgDtype: pass
        
class BMImage:
    def __init__(self) -> BMImage: pass

    def __init__(self, handle: Handle, 
        h: int, w: int, 
        format: Format, 
        dtype: ImgDtype) -> BMImage: pass

    def __init__(self, handle: Handle, 
        buffer: bytes | numpy.ndarray, 
        h: int, w: int, 
        format: Format, 
        dtype: ImgDtype = ImgDtype.DATA_TYPE_EXT_1N_BYTE, 
        strides: list = [], 
        offset: int = 0
        ) -> BMImage: pass

    def width(self) -> int: pass

    def height(self) -> int: pass

    def format(self) -> int: pass

    def dtype(self) -> int: pass

    def data(self) -> bm_image: 
        """ Get inner bm_image  """
        pass

    def get_plane_num(self) -> int: pass

    def need_to_free(self) -> bool: pass

    def empty_check(self) -> int: pass

    def get_device_id(self) -> int: pass

    def get_handle(self) -> Handle:
        """ Get Handle of BMImage """
        pass

    def asmat(self) -> numpy.ndarray[numpy.uint8]: pass

    def asnumpy(self) -> numpy.ndarray: 
        """
        Convert BMImage to numpy.ndarray containing raw data, without color 
        space convert.
        """
        pass


class Decoder:
    def __init__(self, file_path: str, compressed: bool =  True, dev_id: int = 0) -> Decoder:
        """ 
        Decoder by VPU

        Parameters:
        ----------
        file_path : str
            Path or rtsp url to the video/image file.
        compressed : bool, optional
            Whether the format of decoded output is compressed NV12.
            Defaults is True.
        dev_id : int, optional
            ID of TPU. 
            Defaults to 0.
        """
        pass

    def is_opened(self) -> bool:
       """ Judge if the source is opened successfully. """
       pass
    
    def get_frame_shape(self) -> list[int]:
        """ Get frame shape in the Decoder.
       
        Returns
        -------
        list[int], [1, C, H, W]
        """
        pass

    def read(self, handle: Handle) -> BMImage: pass
    # def read(self, handle: Handle, image: BMImage) -> int: pass
    def read_(self, handle: Handle, image: bm_image) -> None: pass    
    def get_fps(self) -> float: pass
    def release(self) -> None: pass
    def reconnect(self) -> int: pass
    
    def enable_dump(self, dump_max_seconds: int) -> None: pass
    def disable_dump(self) -> None: pass
    def dump(self, dump_pre_seconds: int, dump_post_seconds: int, file_path: str) -> int:
        """ dump input video without encode.
       
        Parameters:
        ----------
        dump_pre_seconds : int
            dump video length(seconds) before dump moment
        dump_post_seconds : int
            dump video length(seconds) after dump moment
        file_path : str
            output path
            
        Returns
        -------
        int, 0 for success
        """
        pass

    def get_pts_dts(self) -> list:
        """ Get the pts and dts
        
        Returns
        -------
            lists, pts and dts
        """
        pass

class Decoder_RawStream:
    def __init__(self, tpu_id: int = 0 , decformat: str = None ) -> Decoder_RawStream:
        pass

    def read_(self, data_bytes: bytes, image: bm_image, continue_frame: bool = False) -> int:
        """
        Read from the decoder.
        Parameters:
        - data_bytes: Input h264 or h265 data as bytes.
        - image: Output bm_image.
        - continue_frame: Flag to indicate if it's a continuous frame.
        Returns:
        - int: 0 for success, other values for failure.
        """
        pass

    def read(self, data: bytes, image: BMImage, continue_frame: bool = False) -> int:
        pass

    def release(self) -> None: pass

    def read_single_frame(self, data: bytes, image: BMImage, continue_frame: bool = False, need_flush: bool = False) -> int:
        pass


class PaddingAtrr:
    def __init__(self): pass
    def __init__(self,stx: int, sty: int, w: int, h: int, \
        r: int, g: int, b: int): pass
    def set_stx(self, stx: int) -> None : pass
    def set_sty(self, sty: int) -> None : pass
    def set_w(self, w: int) -> None : pass
    def set_h(self, h: int) -> None : pass
    def set_r(self, r: int) -> None : pass
    def set_g(self, g: int) -> None : pass
    def set_b(self, b: int) -> None : pass


class Bmcv:
    def __init__(self, handle: Handle) -> None: pass

    def bm_image_to_tensor(self, img: BMImage|BMImageArray, tensor: Tensor) -> None:
        """
        Convert BMImage|BMImageArray to tensor

        Parameters:
        ----------
        img : BMImage|BMImageArray(Input image)

        Returns
        -------
        tensor: Tensor(Output tensor)
        """
        pass

    def bm_image_to_tensor(self, img: BMImage|BMImageArray) -> Tensor:
        """
        Convert BMImage|BMImageArray to tensor

        Parameters:
        ----------
        img : BMImage|BMImageArray(Input image)

        Returns
        -------
        tensor: Tensor(Output tensor)
        """
        pass

    def tensor_to_bm_image(self, tensor: Tensor, img: BMImage|BMImageArray, bgr2rgb: bool = False, layout: str = 'nchw') -> None:
        """
        Convert tensor to BMImage|BMImageArray

        Parameters:
        ----------
        tensor : Tensor
            Input tensor.
        bgr2rgb : bool, optional
            Swap color channel, default is False.
        layout : str, optional
            Layout of the input tensor: 'nchw' or 'nhwc', default is 'nchw'.

        Returns
        -------
        img: BMImage|BMImageArray
            Output image
        """
        pass
    
    def tensor_to_bm_image(self, tensor: Tensor, img: BMImage|BMImageArray, format: Format) -> None:
        """
        Convert tensor to BMImage|BMImageArray

        Parameters:
        ----------
        tensor : Tensor
            Input tensor.
        format : Format
            Format of the BMImage.

        Returns
        -------
        img: BMImage|BMImageArray
            Output image
        """
        pass

    def tensor_to_bm_image(self, tensor: Tensor, bgr2rgb: bool = False, layout: str = 'nchw') -> BMImage:
        """
        Convert tensor to BMImage

        Parameters:
        ----------
        tensor : Tensor
            Input tensor.
        bgr2rgb : bool, optional
            Swap color channel, default is False.
        layout : str, optional
            Layout of the input tensor: 'nchw' or 'nhwc', default is 'nchw'.

        Returns
        -------
        img: BMImage
            Output image
        """
        pass

    def tensor_to_bm_image(self, tensor: Tensor, format: Format) -> BMImage:
        """
        Convert tensor to BMImage

        Parameters:
        ----------
        tensor : Tensor
            Input tensor.
        format : Format
            Format of the BMImage.

        Returns
        -------
        img: BMImage
            Output image
        """
        pass
    
    def mat_to_bm_image(self, mat: numpy.ndarray[numpy.uint8]) -> BMImage:
        """
        Convert cv mat to BMImage
        
        Parameters:
        ----------
        mat: input cv mat, rgb_packed.
        
        Returns
        -------
        img: BMImage
            Output image
        """
        pass

    def mat_to_bm_image(self, mat: numpy.ndarray[numpy.uint8], img: BMImage) -> int:
        """
        Convert cv mat to BMImage
        
        Parameters:
        ----------
        mat: input cv mat, rgb_packed.
        img: output BMImage
        """
        pass
    
    def crop_and_resize(self, input: BMImage|BMImageArray,
        crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int, 
        resize_alg: bmcv_resize_algorithm = bmcv_resize_algorithm.BMCV_INTER_NEAREST) -> BMImage|BMImageArray:
        """Crop then resize an image. """
        pass
    
    def crop(self, input: BMImage|BMImageArray, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int) -> BMImage|BMImageArray:
        """Crop an image with given window. """
        pass

    def resize(self, input: BMImage|BMImageArray, resize_w: int, resize_h: int, 
               resize_alg: bmcv_resize_algorithm = bmcv_resize_algorithm.BMCV_INTER_NEAREST) -> BMImage|BMImageArray:
        """Resize an image with interpolation of INTER_NEAREST. """
        pass

    def vpp_crop_and_resize(self, input: BMImage|BMImageArray,
        crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int, 
        bmcv_resize_algorithm = bmcv_resize_algorithm.BMCV_INTER_NEAREST) -> BMImage|BMImageArray:
        """Crop then resize an image using vpp. """
        pass

    def vpp_crop(self, input: BMImage|BMImageArray, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int) -> BMImage|BMImageArray:
        """Crop an image with given window using vpp. """
        pass

    def vpp_resize(self, input: BMImage|BMImageArray, output: BMImage|BMImageArray, resize_w: int, resize_h: int, 
                   bmcv_resize_algorithm = bmcv_resize_algorithm.BMCV_INTER_NEAREST) -> None:
        """Resize an image with interpolation of INTER_NEAREST using vpp. """
        pass
    
    def vpp_resize(self, input: BMImage|BMImageArray, resize_w: int, resize_h: int, 
                   bmcv_resize_algorithm = bmcv_resize_algorithm.BMCV_INTER_NEAREST) -> BMImage|BMImageArray:
        """Resize an image with interpolation of INTER_NEAREST using vpp. """
        pass

    def vpp_crop_and_resize_padding(self, input: BMImage|BMImageArray, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, 
        resize_w: int, resize_h: int, padding_in: PaddingAtrr, 
        resize_alg: bmcv_resize_algorithm = bmcv_resize_algorithm.BMCV_INTER_NEAREST) -> BMImage|BMImageArray:
        """Crop then resize an image using vpp. """
        pass
    
    def crop_and_resize_padding(self, input: BMImage, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, 
        resize_w: int, resize_h: int, padding_in: PaddingAtrr) -> BMImage:
        """Crop then resize an image. """
        pass

    def vpp_crop_padding(self, input: BMImage|BMImageArray, resize_w: int, resize_h: int, padding_in: PaddingAtrr) -> BMImage|BMImageArray:
        """Crop an image with given window using vpp. """
        pass

    def vpp_resize_padding(self, input: BMImage|BMImageArray, resize_w: int, resize_h: int, padding_in: PaddingAtrr,
                           bmcv_resize_algorithm = bmcv_resize_algorithm.BMCV_INTER_NEAREST) -> BMImage|BMImageArray:
        """Resize an image with interpolation of INTER_NEAREST using vpp. """
        pass

    def yuv2bgr(self, input: BMImage|BMImageArray) -> BMImage|BMImageArray: 
        """Convert an image from YUV to BGR."""
        pass

    def warp(self, input: BMImage|BMImageArray, matrix, use_bilinear: int = 0, similar_to_opencv: bool = False) -> BMImage|BMImageArray:
        """
        Applies an affine transformation to an image.
        
        Parameters:
        ----------
        input: BMImage|BMImageArray(Input image)
        matrix: 2x3 transformation matrix
        use_bilinear: Bilinear use flag, 0 for nearest interpolation and 1 for bilinear interpolation
        similar_to_opencv: Whether to use the interface aligning the affine transformation interface of OpenCV

        Returns:
        -------
        Output image
        """
        pass
    def warp(self, input: BMImage|BMImageArray, output: BMImage|BMImageArray, matrix, use_bilinear: int = 0, similar_to_opencv: bool = False) -> int:
        """
        Applies an affine transformation to an image.
        
        Parameters:
        ----------
        input: BMImage|BMImageArray(Input image)
        output: BMImage|BMImageArray(Output image)
        matrix: 2x3 transformation matrix
        use_bilinear: Bilinear use flag, 0 for nearest interpolation and 1 for bilinear interpolation
        similar_to_opencv: Whether to use the interface aligning the affine transformation interface of OpenCV

        Returns:
        -------
        int, 0 for success
        """
        pass
    
    def warp_perspective(self, input: BMImage, coordinate, output_width: int,  output_height: int, \
        format: Format = Format.FORMAT_BGR_PLANAR,  dtype: ImgDtype = ImgDtype.DATA_TYPE_EXT_1N_BYTE, \
        use_bilinear: int = 0 ) -> BMImage:
        """
        Applies a perspective transformation to an image.
        
        Parameters:
        ----------
        input: BMImage
        coordinate: Original coordinate, like(left_top.x, left_top.y), (right_top.x, right_top.y), \
            (left_bottom.x, left_bottom.y), (right_bottom.x, right_bottom.y)
        output_width: Output width
        output_height: Output height
        Format: Output image format, Only FORMAT_BGR_PLANAR,FORMAT_RGB_PLANAR 
        dtype: Output image dtype, Only DATA_TYPE_EXT_1N_BYTE,DATA_TYPE_EXT_4N_BYTE
        use_bilinear: Bilinear use flag.

        Returns:
        -------
        Output image
        """
        pass

    def convert_to(self, input: BMImage|BMImageArray, output: BMImage|BMImageArray, alpha_beta) -> None:
        """
        Applies a linear transformation to an image.

        Parameters:
        ----------
        input: BMImage|BMImageArray(Input image)
        alpha_beta:like (a0, b0), (a1, b1), (a2, b2) factors

        Returns:
        output: BMImage|BMImageArray(Output image)
        """
        pass

    def convert_to(self, input: BMImage|BMImageArray, alpha_beta) -> BMImage|BMImageArray:
        """
        Applies a linear transformation to an image.

        Parameters:
        ----------
        input: BMImage|BMImageArray(Input image)
        alpha_beta:  (a0, b0), (a1, b1), (a2, b2) factors

        Returns:
        output: BMImage|BMImageArray(Output image)
        """
        pass

    def rectangle(self, image: BMImage, x: int, y: int, w: int, h: int, color, thickness: int = 1) -> None:
        """
        Draw a rectangle on input image.

        Parameters:
        ----------
        image: BMImage, Input image
        x: int, Start point x of rectangle
        y: int, Start point y of rectangle
        w: int, Width of rectangle
        h: int, Height of rectangle
        color: Color of rectangle, like (0, 0, 255)
        thickness: int, optional, default is 1
        """
        pass

    def rectangle(self, image: bm_image, x: int, y: int, w: int, h: int, color, thickness: int = 1) -> None:
        """
        Draw a rectangle on input image.

        Parameters:
        ----------
        image: bm_image, Input image
        x: int, Start point x of rectangle
        y: int, Start point y of rectangle
        w: int, Width of rectangle
        h: int, Height of rectangle
        color: Color of rectangle, like (0, 0, 255)
        thickness: int, optional, default is 1
        """
        pass
    def fillRectangle(self, image: BMImage, x: int, y: int, w: int, h: int, color) -> None:
        """
        Fill a rectangle on input image.

        Parameters:
        ----------
        image: BMImage, Input image
        x: int, Start point x of rectangle
        y: int, Start point y of rectangle
        w: int, Width of rectangle
        h: int, Height of rectangle
        color: Color of rectangle, like (0, 0, 255)
        """
        pass
    def fillRectangle(self, image: bm_image, x: int, y: int, w: int, h: int, color) -> None:
        """
        Fill a rectangle on input image.

        Parameters:
        ----------
        image: bm_image, Input image
        x: int, Start point x of rectangle
        y: int, Start point y of rectangle
        w: int, Width of rectangle
        h: int, Height of rectangle
        color: Color of rectangle, like (0, 0, 255)
        """
        pass
    def putText(self, image: BMImage, text: str, x: int, y: int, color, fontScale: float, thickness: int=1) -> None:
        """
        Draw Text on input image.

        Parameters:
        ----------
        image: BMImage, Input image
        text: str, Text string to be drawn
        x: int, Start point x
        y: int, Start point y
        color: color of text, like(0, 0, 255)
        fontScale: float, Font scale factor that is multiplied by the font-specific base size
        thickness: int, optional, default is 1
        """
        pass

    def putText(self, image: bm_image, text: str, x: int, y: int, color, fontScale: float, thickness: int=1) -> None:
        """
        Draw Text on input image.

        Parameters:
        ----------
        image: bm_image, Input image
        text: str, Text string to be drawn
        x: int, Start point x
        y: int, Start point y
        color: color of text, like(0, 0, 255)
        fontScale: float, Font scale factor that is multiplied by the font-specific base size
        thickness: int, optional, default is 1
        """
        pass


    def imwrite(self, filename: str, image: BMImage) -> None:
        """
        Save the image to the specified file.

        Parameters:
        ----------
        filename: str
            Name of the save file.
        image: BMImage
            Image to be saved.
        """
        pass

    def imwrite(self, filename: str, image: bm_image) -> None:
        """
        Save the image to the specified file.
        
        Parameters:
        ----------
        filename: str
            Name of the save file.
        image: bm_image
            Image to be saved.
        """
        pass

    def get_handle(self) -> Handle: 
        """Get Handle instance. """
        pass

    def convert_format(self, input: BMImage, output: BMImage) -> None: 
        """Convert input to output format. """
        pass

    def convert_format(self, input: BMImage) -> BMImage: 
        """Convert an image to BGR PLANAR format. """
        pass

    def vpp_convert_format(self, input: BMImage, output: BMImage) -> None: 
        """Convert input to output format using vpp. """
        pass

    def vpp_convert_format(self, input: BMImage) -> BMImage: 
        """Convert an image to BGR PLANAR format using vpp. """
        pass

    def get_bm_data_type(self, format: ImgDtype) -> Dtype: pass

    def get_bm_image_data_format(self, dtype: Dtype) -> ImgDtype: pass

    def image_add_weighted(self, input1: BMImage, alpha: float, input2: BMImage, \
        beta: float, gamma: float, output: BMImage) -> int:  
        """output = input1 * alpha + input2 * beta + gamma."""
        pass

    def image_add_weighted(self, input1: BMImage, alpha: float, input2: BMImage, \
        beta: float, gamma: float) -> BMImage:
        """output = input1 * alpha + input2 * beta + gamma."""
        pass

    def image_copy_to(self, input: BMImage|BMImageArray, output: BMImage|BMImageArray, \
        start_x: int, start_y: int) -> None:
        """
        Copy the input to the output.

        Parameters:
        ----------
        input: BMImage|BMImageArray(Input image)
        output: BMImage|BMImageArray(Output image)
        start_x: point start x
        start_y: point start y
        """
        pass

    def image_copy_to_padding(self, input: BMImage|BMImageArray, output: BMImage|BMImageArray, \
        padding_r: numpy.uint8, padding_g: numpy.uint8, padding_b: numpy.uint8, start_x: int, start_y: int) -> None:
        """
        Copy the input to the output width padding.

        Parameters:
        ----------
        input: BMImage|BMImageArray(Input image)
        output: BMImage|BMImageArray(Output image)
        padding_r: r value for padding
        padding_g: g value for padding
        padding_b: b value for padding
        start_x: point start x
        start_y: point start y
        """
        pass

    def convert_yuv420p_to_gray(self, input:BMImage, output:BMImage) -> int:
        """
        Convert YUV420P to gray image.

        Parameters:
        ----------
        input: BMImage(Input image)
        output: BMImage(Output image)
        """
        pass

    def convert_yuv420p_to_gray(self, input:bm_image, output:bm_image) -> int:
        """
        Convert YUV420P to gray image.

        Parameters:
        ----------
        input: bm_image(Input image)
        output: bm_image(Output image)
        """
        pass

    def nms(self, input: numpy.ndarray[Any, numpy.dtype[numpy.float32]], threshold: float) -> numpy.ndarray[Any, numpy.dtype[numpy.float32]]:
        """
        Do nms use tpu.

        Parameters:
        ----------
        input: input proposal array
            shape must be (n,5) n<56000, proposal:[left,top,right,bottom,score]
        threshold: nms threshold

        Returns:
        ----------
        return nms result, numpy.ndarray[Any, numpy.dtype[numpy.float32]]
        """
        pass

    def drawPoint(self, image: BMImage, center: tuple[int, int], color: tuple[int, int, int], radius: int) -> int:
        """
        Draw Point on input image.

        Parameters:
        ----------
        image: BMImage, Input image
        center: Tuple[int, int], center of point, (point_x, point_y)
        color: Tuple[int, int, int], color of drawn, (b,g,r)
        radius: Radius of drawn
        """
        pass

    def drawPoint(self, image: bm_image, center: tuple[int, int], color: tuple[int, int, int], radius: int) -> int:
        """
        Draw Point on input image.

        Parameters:
        ----------
        image: bm_image, Input image
        center: Tuple[int, int], center of point, (point_x, point_y)
        color: Tuple[int, int, int], color of drawn, (b,g,r)
        radius: Radius of drawn
        """
        pass

    def polylines(self, image: BMImage, pts: list[list[tuple[int, int]]], isClosed: bool, color: tuple[int, int, int], thickness: int = 1, shift: int = 0) -> int:
        """
        Draw one or more line segments on an image and polygonal curves.

        Parameters:
        ----------
        image: input image
        pts: The starting point and end point coordinates of the line segment, multiple coordinate points can be entered. 
            The upper left corner of the image is the origin, 
            extending to the right in the x direction and extending down in the y direction.
        isClosed: Whether the graph is closed.
        color: The color of the line is the value of the three RGB channels.
        thickness: The width of the lines is recommended to be even for YUV format images.
        shift: Polygon scaling multiple. Default is not scaling. The scaling factor is(1/2)^shift。

        Returns:
        ----------
        returns 0 if success. 
        """
        pass
        
    def mosaic(self, mosaic_num: int, img: BMImage, rects: list[list[int,int,int,int]], is_expand:int) -> int:
        """
        Print one or more mosaics on an image.

        Parameters:
        ----------
        mosaic_num: Number of mosaics, length of list in rects.
        img: Input BMImage.
        rects: Multiple Mosaic positions, the parameters in each element in the list are 
            [Mosaic at X-axis start point, Mosaic at Y-axis start point, Mosaic width, Mosaic height].
        is_expand:A value of 0 means that the column is not expanded, 
            and a value of 1 means that a macro block (8 pixels)

        Returns:
        ----------
        returns 0 if success. 
        """
        pass

    def transpose(self, src: BMImage, dst: BMImage) -> int:
        """
        Transpose of image width and height.

        Parameters:
        ----------
        src: Input BMImage
        dst: Output BMImage

        Returns:
        ----------
        returns 0 if success. 
        """
        pass    

    def transpose(self, src: BMImage) -> BMImage:
        """
        Transpose of image width and height.

        Parameters:
        ----------
        src: Input BMImage

        Returns:
        ----------
        Output BMImage 
        """
        pass

    def gaussian_blur(self, input: BMImage, kw: int, kh : int, sigmaX : float, sigmaY : float = 0.0) -> BMImage: 
        """
        Gaussian blur
        
        Parameters:
        ----------
        input: BMImage
        kw: int, size of kernel in the width direction.
        kh: int, size of kernel in the height direction.
        sigmaX : float, gaussian kernel standard deviation in the X direction.
        sigmaY : float, gaussian kernel standard deviation in the Y direction.Default is 0.0, 
                which means that it is the same standard deviation as the Gaussian kernel in the X direction.

        Returns:
        ----------
        return gaussian blur image
        """
        pass

    def Sobel(self, input: BMImage, output: BMImage, dx: int, dy: int, ksize: int = 3, scale: float = 1, delta: float = 0) -> int:
        """
        Edge detection Sobel Operator.

        Parameters:
        ----------
        input         Input BMImage 
        output        Output BMImage
        dx            Order of the derivative x.
        dy            Order of the derivative y
        ksize         ize of the extended Sobel kernel; it must be -1, 1, 3, 5, or 7.
        scale         Optional scale factor for the computed derivative values; by default, no scaling is applied
        delta         Optional delta value that is added to the results prior to storing them in dst.
        
        Returns:
        ----------
        return 0 if success
        """
        pass

    def Sobel(self, input: BMImage, dx: int, dy: int, ksize: int = 3, scale: float = 1, delta: float = 0) -> BMImage:
        """
        Edge detection Sobel Operator.

        Parameters:
        ----------
        input         Input BMImage 
        dx            Order of the derivative x.
        dy            Order of the derivative y
        ksize         ize of the extended Sobel kernel; it must be -1, 1, 3, 5, or 7.
        scale         Optional scale factor for the computed derivative values; by default, no scaling is applied
        delta         Optional delta value that is added to the results prior to storing them in dst.
        
        Returns:
        ----------
        return processed BMImage
        """
        pass

    def imdecode(self, data_bytes: bytes) -> BMImage:
        """
        Load Jpeg image from system memory.

        Parameters:
        ----------
        data_bytes: image data bytes in system memory


        Returns:
        ----------
        return decoded image
        """
        pass

    def imencode(self, ext: str, img: BMImage) -> numpy.ndarray:
        """
        Compresses the BMImage and stores it in the memory

        Parameters:
        ----------
        ext: File extension that defines the output format.
        img: BMImage to be written
        buf: Output buffer resized to fit the compressed BMImage

        Returns:
        ----------
        return encoded array
        """
        pass

    def imread(self, filename: str) -> BMImage:
        """
        Read a jpeg image from file. Only support jpeg baseline image. The returned BMImage keeps YUV color space.

        Parameters:
        ----------
        filename: Name of file to be read.

        Returns:
        ----------
        Return decoded BMImage, whose pixel format is in YUV color space.
        """
        pass

    def stft(self, input_real: numpy.ndarray, input_imag: numpy.ndarray, real_input: bool, normalize: bool, n_fft: int, hop_len: int,
             pad_mode: int, win_mode: int) -> tuple[numpy.ndarray, numpy.ndarray]:
        """
        Short-Time Fourier Transform (STFT) for NumPy arrays.

        Parameters:
        ----------
        input_real: numpy.ndarray
            The real part of the input signal as a 1D array.
        input_imag: numpy.ndarray
            The imaginary part of the input signal as a 1D array.
        real_input: bool
            Indicates whether the input is purely real. If true, the imaginary part is ignored.
        normalize: bool
            Indicates whether to normalize the output.
        n_fft: int
            The number of points in the FFT. This defines the resolution of the frequency bins.
        hop_len: int
            The number of samples to hop between successive frames. This controls the overlap.
        pad_mode: int
            An integer indicating the padding mode to use when the input signal is shorter than the expected length:
            - 0: Constant padding (pads with zeros).
            - 1: Reflective padding (pads by reflecting the signal).
        win_mode: int
            An integer specifying the window function to apply to each segment:
            - 0: Hann window.
            - 1: Hamming window.

        Returns:
        ----------
        tuple[numpy.ndarray, numpy.ndarray]
            A tuple containing two NumPy arrays representing the STFT output:
            - The first array is the real part of the STFT.
            - The second array is the imaginary part of the STFT.
        """
        pass

    def stft(self, input_real: Tensor, input_imag: Tensor, real_input: bool, normalize: bool, n_fft: int, hop_len: int,
             pad_mode: int, win_mode: int) -> tuple[Tensor, Tensor]:
        pass 

    def istft(self, input_real: numpy.ndarray, input_imag: numpy.ndarray, real_input: bool, normalize: bool, L: int, hop_len: int,
             pad_mode: int, win_mode: int) -> tuple[numpy.ndarray, numpy.ndarray]:
        """
        Inverse Short-Time Fourier Transform (ISTFT) for NumPy arrays.

        Parameters:
        ----------
        input_real: numpy.ndarray
            The real part of the STFT output as a 1D array.
        input_imag: numpy.ndarray
            The imaginary part of the STFT output as a 1D array.
        real_input: bool
            Indicates whether the input STFT is purely real. If true, the imaginary part is ignored.
        normalize: bool
            Indicates whether to normalize the output.
        L: int
            The length of the original time-domain signal to reconstruct.
        hop_len: int
            The number of samples to hop between successive frames. This controls the overlap.
        pad_mode: int
            An integer indicating the padding mode to use when the input signal is shorter than the expected length:
            - 0: Constant padding (pads with zeros).
            - 1: Reflective padding (pads by reflecting the signal).
        win_mode: int
            An integer specifying the window function to apply to each segment when reconstructing the signal:
            - 0: Hann window.
            - 1: Hamming window.

        Returns:
        ----------
        tuple[numpy.ndarray, numpy.ndarray]
            A tuple containing two NumPy arrays representing the reconstructed time-domain signal:
            - The first array is the reconstructed signal.
            - The second array is the corresponding phase information (if applicable).
        """
        pass

    def istft(self, input_real: Tensor, input_imag: Tensor, real_input: bool, normalize: bool, L: int, hop_len: int,
             pad_mode: int, win_mode: int) -> tuple[Tensor, Tensor]:
        pass 

    def fft(self, forward: bool, input_real: Tensor) -> list[Tensor]:
        """
        1d or 2d fft (only real part)
        
        Parameters:
        ----------
        forward: bool, positive transfer
        input_real: Tensor, input tensor
        
        
        Returns:
        ----------
        return list[Tensor], The real and imaginary part of output
        """
        pass
    
    def fft(self, forward: bool, input_real: Tensor, input_imag: Tensor) -> list[Tensor]:
        """
        1d or 2d fft (real part and imaginary part)
        
        Parameters:
        ----------
        forward: bool, positive transfer
        input_real: Tensor, input tensor real part
        input_imag: Tensor, input tensor imaginary part

        
        Returns:
        ----------
        return list[Tensor], The real and imaginary part of output
        """
        pass
    
    def bmcv_overlay(self, image: BMImage, overlay_info: list[list[int]], overlay_image: list[BMImage]) -> int:
        """
        Add a watermark with a transparent channel to the image

        Parameters:
        -----------
        image: BMImage, the base image
        overlay_info: a list of rect (x,y,w,h)
        overlay_image: a list of watermark image with a transparent channel

        Returns:
        return ret, 0 for success and others for failed
        """
class BMImageArray():
    def __init__(self) -> None: ...

    def __init__(self, handle: Handle, h: int, w: int, format: Format, dtype: ImgDtype ) -> None: ...

    def __len__(self) -> int: pass

    def __getitem__(self, i: int) -> bm_image: pass

    def __setitem__(self, i: int, data: bm_image) -> None: 
        """
        Copy the image to the specified index.

        Parameters:
        ----------
        i: int
            Index of the specified location.
        data: bm_image
            Input image.
        """
        pass

    def copy_from(self, i: int, data:BMImage) -> None: 
        """
        Copy the image to the specified index.

        Parameters:
        ----------
        i: int
            Index of the specified location.
        data: bm_image
            Input image.
        """
        pass

    def attach_from(self, i: int, data: BMImage) -> None: 
        """
        Attach the image to the specified index.(Because there is no memory copy, the original data needs to be cached)

        Parameters:
        ----------
        i: int
            Index of the specified location.
        data: BMImage
            Input image.
        """
        pass
    
    def watermark_superpose(self,
        image: BMImage,
        water_name:str,
        bitmap_type: int,
        pitch: int,
        rects: list[list[int]],
       color: tuple
                ) -> int:
        """
        Add a watermark_superpose to BMImage.

        Parameters:
        ----------
        image: BMImage
            input BMImage
        water_name:str
            input watermark_superpose
        bitmap_type: int
            bitmap_type of input watermark_superpose,0/1,0 8byte,1 1byte
        pitch: int
            the width of input watermark_superpose
        rects: list[list[int]]
            the rects of input watermark_superpose
        color: tuple
            the color of input watermark_superpose
        """
        pass
    
    def get_device_id(self) -> int: pass


class BMImageArray2D(BMImageArray): pass
class BMImageArray3D(BMImageArray): pass
class BMImageArray4D(BMImageArray): pass
class BMImageArray8D(BMImageArray): pass
class BMImageArray16D(BMImageArray): pass
class BMImageArray32D(BMImageArray): pass
class BMImageArray64D(BMImageArray): pass
class BMImageArray128D(BMImageArray): pass
class BMImageArray256D(BMImageArray): pass
    
class MultiDecoder:

    def __init__(self, queue_size: int = 10, tpu_id: int = 0, discard_mode: int = 0): 
        """ MultiDecoder Constructor.

        Parameters:
        ----------
        queue_size: int
            Max queue size,default is 10.
        tpu_id: int
            ID of TPU, default is 0.
        discard_mode: int
            Data discard policy when the queue is full. Default is 0.
            If 0, do not push the data to queue, else pop the data from queue and push new data to queue.
        """
        pass


    def set_read_timeout(self, timeout: int) -> None : 

        """ Set read frame timeout waiting time 
        
        Parameters:
        ----------
        timeout: int
            Set read frame timeout waiting time in seconds.
        """
        pass


    def add_channel(self, file_path: str, frame_skip_num: int = 0) -> int:
        
        """ Add a channel to decode

        Parameters:
        ----------
        file_path : str
            file path
        frame_skip_num : int
            frame skip number, default is 0

        Returns:
        ----------
        return channel index number, int
        """
        pass

    def add_channel(self, file_path: str, frame_skip_num: int, loop_num: int) -> int:
        
        """ Add a channel to decode

        Parameters:
        ----------
        file_path : str
            file path
        frame_skip_num : int
            frame skip number
        loop_num : int
            loop number

        Returns:
        ----------
        return channel index number, int
        """
        pass

    def del_channel(self, channel_idx: int) -> int : 
        """ Delete channel
        
        Parameters:
        ----------
        channel_idx : int
            channel index number

        Returns:
        -------
        0 for success and other for failure.
        """
        pass

    def get_channel_fps(self, channel_idx: int) -> float:
        """ Get the fps of the video stream in a specified channel
        
        Parameters:
        ----------
        channel_idx : int
            channel index number

        Returns:
        -------
        Returns the fps of the video stream in the specified channel
        """
        pass

    def clear_queue(self, channel_idx: int) -> int : 
        """ Clear data cache queue 
        
        Parameters:
        ----------
        channel_idx : int
            channel index number

        Returns:
        -------
        0 for success and other for failure.
        """
        pass

    def read(self, channel_idx: int, image: BMImage, read_mode: int = 0) -> int : 
        """ Read a BMImage from the MultiDecoder with a given channel.

        Parameters:
        ----------
        channel_idx : int
            channel index number
        image: BMImage
            BMImage instance to be read to
        read_mode: int
            Read data mode, 0 for not waiting data and other waiting data.

        Returns:
        -------
        0 for successed get data.
        """
        pass

    def read(self,channel_idx: int) -> BMImage :
        """ Read a BMImage from the MultiDecoder with a given channel.

        Parameters:
        ----------
        channel_idx : int
            channel index number

        Returns:
        -------
            BMImage instance to be read to
        """
        pass


    def read_(self, channel_idx: int, image: bm_image, read_mode: int=0) -> int :
        """ Read a bm_image from the MultiDecoder with a given channel.

        Parameters:
        ----------
        channel_idx : int
            channel index number
        image: bm_image
            bm_image instance to be read to
        read_mode: int
            read data mode, default 0, if 0, not waiting data, else waiting data.

        Returns:
        -------
        return 0 if get data.
        """
        pass

    def read_(self,channel_idx: int) -> int :
        """ Read a bm_image from the MultiDecoder with a given channel.

        Parameters:
        ----------
        channel_idx : int
            channel index number

        Returns:
        -------
            bm_image instance to be read to
        """
        pass

        
    def reconnect(self, channel_idx: int) -> int :
        """ Reconnect Decoder for instance channel
            
        Parameters:
        ----------
        channel_idx : int
            channel index number

        Returns:
        -------
        0 for success and other for failure.
            
        """
        pass


    def get_frame_shape(self, channel_idx: int) -> list[int]:
        """ Get frame for instance channel
        
        Parameters:
        ----------
        channel_idx : int
            channel index number

        Returns
        -------
        list[int], [1, C, H, W]
        """
        pass

    def set_local_flag(self, flag: bool) -> None: 
        """ Set local video flag

        Parameters:
        ----------
        flag : bool
            If flag is True, Decode up to 25 frames per second

        """
        pass

    def exhausted(self) -> None:
        """ Set a flag.
        just a status flag. Always uesd when image dataset has been traversed.

        """
        pass

    def get_exhausted_flag(self) -> bool:
        """ get exhausted flag

        """
        pass

    def get_channel_status(self, channel_idx: int) -> DecoderStatus:
        """ Get the status of the specific channel.
        
        Parameters:
        ----------
        channel_idx : int
            channel index

        Returns:
        -------
        Returns the status of the the specified channel
        """
        pass

    def is_channel_eof(self, channel_idx: int) -> bool:
        """
        Get whether end of file is reached in the specific channel.

        Parameters
        ----------
        channel_idx : int
            channel index

        Returns
        -------
        out : bool
            Return True if EOF is reached else False
        """

class sail_resize_type(enum.Enum):
    BM_RESIZE_VPP_NEAREST = 0
    BM_RESIZE_TPU_NEAREST = 1
    BM_RESIZE_TPU_LINEAR = 2
    BM_RESIZE_TPU_BICUBIC = 3
    BM_PADDING_VPP_NEAREST = 4
    BM_PADDING_TPU_NEAREST = 5
    BM_PADDING_TPU_LINEAR = 6
    BM_PADDING_TPU_BICUBIC = 7


class Encoder:

    def __init__(self):
        """
        encoder constructor for pic
        """
        pass

    def __init__(self, output_path: str, handle: Handle, enc_fmt: str, pix_fmt: str, enc_params: str, cache_buffer_length: int=5, abort_policy: int=0):
        """
        encoder constructor for video

        Parameters:
        ----------
        output_path: local file path or stream url
        handle: sail.Handle
        enc_fmt: encoder name, support h264_bm and h265_bm
        pix_fmt: encoder pixel format, support I420 and NV12
        enc_params: encoder params, width=1920:height=1080:bitrate=2000:gop=32:gop_preset=2:framerate=25
        cache_buffer_length: The internal cache queue length defaults to 6.
        abort_policy:The reject policy for video_write. 0 for returns -1 immediately. 1 for pop queue header. 2 for clear the queue. 3 for blocking.
        """
        pass

    def __init__(self, output_path: str, device_id: int, enc_fmt: str, pix_fmt: str, enc_params: str, cache_buffer_length: int=5, abort_policy: int=0):
        """
        encoder constructor for video

        Parameters:
        ----------
        output_path: local file path or stream url
        device_id: device id
        enc_fmt: encoder name, support h264_bm and h265_bm
        pix_fmt: encoder pixel format, support I420 and NV12
        enc_params: encoder params, width=1920:height=1080:bitrate=2000:gop=32:gop_preset=2:framerate=25
        cache_buffer_length: The internal cache queue length defaults to 6.
        abort_policy:The reject policy for video_write. 0 for returns -1 immediately. 1 for pop queue header. 2 for clear the queue. 3 for blocking.
        """
        pass

    def is_opened(self) -> bool:

        pass

    def pic_encode(self, ext: str, image: BMImage) -> numpy.ndarray[Any, numpy.dtype[Any]]:
        """
        pic encode

        Parameters:
        ----------
        ext: encode format, .jpg .png ...
        image: input image

        Returns:
        ----------
        return pic data numpy.ndarray[Any, numpy.dtype[numpy.uint8_t]]
        """
        pass

    def pic_encode(self, ext: str, image: bm_image) -> numpy.ndarray[Any, numpy.dtype[Any]]:

        pass

    def video_write(self, image: BMImage) -> int:
        """
        On BM1684, it is required that the image shape be consistent with the width and height specified by the encoder, \
            video_write use bmcv_image_storage_convert to perform format conversion.
        On BM1684X, video_write use bmcv_image_vpp_convert to resize and format conversion.

        Parameters:
        ----------
        image: BMImage

        Returns:
        ----------
        Successfully returned 0, internal cache queue full returned -1. encode failed returns -2. push stream failed returns -3. unknown abort policy returns -4.
        """
        pass

    def video_write(self, image: bm_image) -> int:

        pass

    def release(self) -> None:
        """
        release resources
        only invoked when video encode finished
        """
        pass


class EngineImagePreProcess:
    
    def __init__(self, bmodel_path: str, tpu_id: int, use_mat_output: bool = False, core_list:list = []): 
        """ EngineImagePreProcess Constructor.

        Parameters
        ----------
        bmodel_path: str
        tpu_id: int
            ID of TPU, there may be more than one TPU for PCIE mode,default is 0.
        core_list: list
            CORE of choosed TPU,default is None.
        use_mat_output : bool
            Use opencv Mat for output images
        """
        pass

    def InitImagePreProcess(self, resize_mode: sail_resize_type, bgr2rgb: bool = False,
        queue_in_size: int = 20, queue_out_size: int = 20) -> int:
        """ initialize ImagePreProcess.

        Parameters
        ----------
        resize_mode: sail_resize_type
            Resize Methods
        bgr2rgb: bool
            The flag of convert BGR image to RGB, default is False.
        queue_in_size: int
            Max input image data queue size, default is 20.
        queue_out_size: int
            Max output tensor data queue size, default is 20.
        
        Returns
        -------
        0 for success and other for failure 
        """
        pass


    def SetPaddingAtrr(self,padding_b:int=114,padding_g:int=114,padding_r:int=114,align:int=0) -> int :
        """ Set the padding attribute object.

        Parameters
        ----------
        padding_b: int
            padding value of b channel, dafault 114
        padding_g: int
            padding value of g channel, dafault 114
        padding_r: int
            padding value of r channel, dafault 114
        align: int
            padding position, default 0: start left top, 1 for center
        
        Returns
        -------
        0 for success and other for failure 
        """

    def SetConvertAtrr(self,alpha_beta) -> int :
        """ Set the linear transformation attribute 

        Parameters
        ----------
        alpha_beta:like (a0, b0), (a1, b1), (a2, b2) factors

        Returns
        -------
        0 for success and other for failure 
        """
        pass

    def PushImage(self, channel_idx : int, image_idx : int, image: BMImage) -> int: 
        """ Push Image
        Parameters
        ----------
        channel_idx : int
            Channel index number of the image
        image_idx: int
            Image index number of the image
        image: BMImage
            Input image
        
        Returns
        -------
        0 for success and other for failure 
        """
        pass


    def GetBatchData_Npy(self) -> tuple:
        """ Get the Batch Data object
        
        Returns
        -------
        [dict[str, ndarray], list[BMImage],list[int],list[int],list[list[int]]]
            Output ndarray map, Original Images, Original Channel index, Original Indexm, Padding Atrr(start_x, start_y, width, height)
        """
        pass

    def GetBatchData_Npy2(self) -> tuple:
        """ Get the Batch Data object
        
        Returns
        -------
        [dict[str, ndarray], list[numpy.ndarray[numpy.uint8]],list[int],list[int],list[list[int]]]
            Output ndarray map, Original Images, Original Channel index, Original Indexm, Padding Atrr(start_x, start_y, width, height)
        """
        pass

    def GetBatchData(self, need_d2s: bool = True) -> tuple:
        """ Get the Batch Data object
        
        Parameters
        ------------
        need_d2s : bool
            Need copy data to system memory.

        Returns
        -------
        [list[TensorPTRWithName], list[BMImage],list[int],list[int],list[list[int]]]
            Output ndarray map, Original Images, Original Channel index, Original Indexm, Padding Atrr(start_x, start_y, width, height)
        """
        pass

    def get_graph_name(self) -> str:
        """ Get first graph name in the loaded bomodel
        
        Returns
        -------
        First graph name
        """
        pass

    def get_input_width(self) -> int:
        """ Get model input width

        Returns
        -------
        Model input width
        """
        pass

    def get_input_height(self) -> int:
        """ Get model input height

        Returns
        -------
        Model input height
        """
        pass

    def get_output_names(self) -> list[str]:
        """ Get all output tensor names of the first graph

        Returns
        -------
        All the output tensor names of the graph
        """
        pass
    
    def get_output_shape(self, tensor_name: str) -> list[int]:
        """ Get the shape of an output tensor in frist graph
        
        Parameters
        ----------
        tensor_name : str
             The specified tensor name

        Returns
        -------
        The shape of the tensor
        """
        pass

class ImagePreProcess:
    
    def __init__(self, batch_size: int, resize_mode:sail_resize_type, tpu_id: int=0, 
        queue_in_size: int=20, queue_out_size: int=20):  
        """ ImagePreProcess Constructor.

        Parameters
        ----------
        batch_size: int
            Output batch size.
        resize_mode: sail_resize_type
            Resize Methods
        tpu_id: int
            ID of TPU, there may be more than one TPU for PCIE mode,default is 0.
        queue_in_size: int
            Max input image data queue size, default is 20.
        queue_out_size: int
            Max output tensor data queue size, default is 20.
        """
        pass


    def SetResizeImageAtrr(self, output_width: int, output_height: int ,bgr2rgb : bool, dtype: ImgDtype) -> None : 

        """ Set the Resize Image attribute 
        
        Parameters
        ----------
        output_width: int
            The width of resized image.
        output_height: int
            The height of resized image.
        bgr2rgb: bool
            The flag of convert BGR image to RGB.
        dtype: ImgDtype  
            The data type of resized image,Only supported BM_FLOAT32,BM_INT8,BM_UINT8   
        """
        pass


    def SetPaddingAtrr(self,padding_b:int=114,padding_g:int=114,padding_r:int=114,align:int=0) -> None :
        """ Set the padding attribute object.

        Parameters
        ----------
        padding_b: int
            padding value of b channel, dafault 114
        padding_g: int
            padding value of g channel, dafault 114
        padding_r: int
            padding value of r channel, dafault 114
        align: int
            padding position, default 0: start left top, 1 for center

        """
        pass


    def SetConvertAtrr(self,alpha_beta) -> int :
        """ Set the linear transformation attribute 

        Parameters
        ----------
        alpha_beta:like (a0, b0), (a1, b1), (a2, b2) factors

        Returns
        -------
        0 for success and other for failure 
        """
        pass


    def PushImage(self, channel_idx : int, image_idx : int, image: BMImage) -> int: 
        """ Push Image
        Parameters
        ----------
        channel_idx : int
            Channel index number of the image
        image_idx: int
            Image index number of the image
        image: BMImage
            Input image
        
        Returns
        -------
        0 for success and other for failure 
        """
        pass

    def GetBatchData(self) -> tuple[Tensor, list[BMImage],list[int],list[int],list[list[int]]]:
        """ Get the Batch Data object
        
        Returns
        -------
        [Tensor, list[BMImage],list[int],list[int],list[list[int]]]
            Output Tensor, Original Images, Original Channel index, Original Index, Padding Atrr(start_x, start_y, width, height)
        """
        pass

    def set_print_flag(self, flag : bool) -> None:
        """ Set the print flag
        
        Parameters
        ----------
        flag : int
        """
        pass

class algo_yolov5_post_1output:
    
    def __init__(self, shape: list[int], network_w:int = 640, network_h:int = 640, max_queue_size: int=20, input_use_multiclass_nms: bool=True, agnostic: bool=False): 
        
        """ algo_yolov5_post_1output Constructor.

        Parameters
        ----------
        shape: list[int]
        network_w: int, network input width 
        network_h: int, network input height 
        max_queue_size: int, default 20
        input_use_multiclass_nms: bool, default True
        agnostic: bool, default False
        """
        pass

    def push_npy(self, 
                channel_idx : int, 
                image_idx : int, 
                data : numpy.ndarray[Any, numpy.dtype[numpy.float_]], 
                dete_threshold : float, 
                nms_threshold : float,
                ost_w : int, 
                ost_h : int,
                padding_left : int,
                padding_top : int,
                padding_width : int,
                padding_height : int) -> int:
        """ algo_yolov5_post_1output push data.

        Parameters
        ----------
        
        channel_idx : Channel index number of the image.
        image_idx : Image index number of the image.
        data : Input Data
        dete_threshold : Detection threshold
        nms_threshold : NMS threshold
        ost_w : Original image width
        ost_h : Original image height
        padding_left : Padding left
        padding_top : Padding top
        padding_width : Padding width
        padding_height : Padding height

        Returns
        -------
        return 0 for success and other for failure
        """
        pass

    def get_result_npy(self) -> tuple[tuple[int, int, int, int, int, float],int, int]:
        """ Get the PostProcess result
        
        Returns
        -------
        tuple[tuple[left, top, right, bottom, class_id, score],channel_idx, image_idx]
            
        """
        pass


    def push_data( self, 
        channel_idx : list[int], 
        image_idx : list[int], 
        input_data : TensorPTRWithName, 
        dete_threshold : list[float],
        nms_threshold : list[float],
        ost_w : list[int],
        ost_h : list[int],
        padding_attr : list[list[int]]) -> int:
        """ algo_yolov5_post_1output push data.

        Parameters
        ----------
        
        channel_idx : Channel index number of the images.
        image_idx : Image index number of the images.
        data : Input Data
        dete_threshold : Detection thresholds
        nms_threshold : NMS thresholds
        ost_w : Original images width
        ost_h : Original images height
        padding_attr : Padding Attribute[start_x, start_y, width, height]

        Returns
        -------
        return 0 for success and other for failure
        """
        pass

class algo_yolov8_post_1output_async:
    
    def __init__(self, shape: list[int], network_w:int = 640, network_h:int = 640, max_queue_size: int=20, input_use_multiclass_nms: bool=True, agnostic: bool=False): 
        """ algo_yolov8_post_1output_async Constructor.

        Parameters
        ----------
        shape: list[int]
        network_w: int, network input width 
        network_h: int, network input height 
        max_queue_size: int, default 20
        input_use_multiclass_nms: bool, default True
        agnostic: bool, default False
        """
        pass

    def push_npy(self, 
                channel_idx : int, 
                image_idx : int, 
                data : numpy.ndarray[Any, numpy.dtype[numpy.float_]], 
                dete_threshold : float, 
                nms_threshold : float,
                ost_w : int, 
                ost_h : int,
                padding_left : int,
                padding_top : int,
                padding_width : int,
                padding_height : int) -> int:
        """ algo_yolov8_post_1output_async push data.

        Parameters
        ----------
        
        channel_idx : Channel index number of the image.
        image_idx : Image index number of the image.
        data : Input Data
        dete_threshold : Detection threshold
        nms_threshold : NMS threshold
        ost_w : Original image width
        ost_h : Original image height
        padding_left : Padding left
        padding_top : Padding top
        padding_width : Padding width
        padding_height : Padding height

        Returns
        -------
        return 0 for success and other for failure
        """
        pass

    def get_result_npy(self) -> tuple[tuple[int, int, int, int, int, float],int, int]:
        """ Get the PostProcess result
        
        Returns
        -------
        tuple[tuple[left, top, right, bottom, class_id, score],channel_idx, image_idx]
            
        """
        pass


    def push_data( self, 
        channel_idx : list[int], 
        image_idx : list[int], 
        input_data : TensorPTRWithName, 
        dete_threshold : list[float],
        nms_threshold : list[float],
        ost_w : list[int],
        ost_h : list[int],
        padding_attr : list[list[int]]) -> int:
        """ algo_yolov8_post_1output_async push data.

        Parameters
        ----------
        
        channel_idx : Channel index number of the images.
        image_idx : Image index number of the images.
        data : Input Data
        dete_threshold : Detection thresholds
        nms_threshold : NMS thresholds
        ost_w : Original images width
        ost_h : Original images height
        padding_attr : Padding Attribute[start_x, start_y, width, height]

        Returns
        -------
        return 0 for success and other for failure
        """
        pass
    
class algo_yolov8_post_cpu_opt_1output_async:
    
    def __init__(self, shape: list[int], network_w:int = 640, network_h:int = 640, max_queue_size: int=20, input_use_multiclass_nms: bool=True, agnostic: bool=False): 
        """ algo_yolov8_post_cpu_opt_1output_async Constructor.

        Parameters
        ----------
        shape: list[int]
        network_w: int, network input width 
        network_h: int, network input height 
        max_queue_size: int, default 20
        input_use_multiclass_nms: bool, default True
        agnostic: bool, default False
        """
        pass

    def push_npy(self, 
                channel_idx : int, 
                image_idx : int, 
                data : numpy.ndarray[Any, numpy.dtype[numpy.float_]], 
                dete_threshold : float, 
                nms_threshold : float,
                ost_w : int, 
                ost_h : int,
                padding_left : int,
                padding_top : int,
                padding_width : int,
                padding_height : int) -> int:
        """ algo_yolov8_post_cpu_opt_1output_async push data.

        Parameters
        ----------
        
        channel_idx : Channel index number of the image.
        image_idx : Image index number of the image.
        data : Input Data
        dete_threshold : Detection threshold
        nms_threshold : NMS threshold
        ost_w : Original image width
        ost_h : Original image height
        padding_left : Padding left
        padding_top : Padding top
        padding_width : Padding width
        padding_height : Padding height

        Returns
        -------
        return 0 for success and other for failure
        """
        pass

    def get_result_npy(self) -> tuple[tuple[int, int, int, int, int, float],int, int]:
        """ Get the PostProcess result
        
        Returns
        -------
        tuple[tuple[left, top, right, bottom, class_id, score],channel_idx, image_idx]
            
        """
        pass


    def push_data( self, 
        channel_idx : list[int], 
        image_idx : list[int], 
        input_data : TensorPTRWithName, 
        dete_threshold : list[float],
        nms_threshold : list[float],
        ost_w : list[int],
        ost_h : list[int],
        padding_attr : list[list[int]]) -> int:
        """ algo_yolov8_post_cpu_opt_1output_async push data.

        Parameters
        ----------
        
        channel_idx : Channel index number of the images.
        image_idx : Image index number of the images.
        data : Input Data
        dete_threshold : Detection thresholds
        nms_threshold : NMS thresholds
        ost_w : Original images width
        ost_h : Original images height
        padding_attr : Padding Attribute[start_x, start_y, width, height]

        Returns
        -------
        return 0 for success and other for failure
        """
        pass
    
class algo_yolov5_post_3output:
    
    def __init__(self, shape: list[list[int]], network_w:int = 640, network_h:int = 640, max_queue_size: int=20, input_use_multiclass_nms: bool=True, agnostic: bool=False): 
        """ algo_yolov5_post_1output Constructor.

        Parameters
        ----------
        shape: list[list[int]]
        network_w: int, network input width 
        network_h: int, network input height 
        max_queue_size: int, default 20
        input_use_multiclass_nms: bool, default True
        agnostic: bool, default False
        """
        pass
    
    def reset_anchors(self, anchors_new: list[list[list[int]]]):
        """ Reset Anchors
        
        Parameters
        ----------
        anchors_new: list[list[list[int]]]
        
        Returns
        -------
        return 0 for success and other for failure
        """
        pass
    
    def get_result_npy(self) -> tuple[tuple[int, int, int, int, int, float],int, int]:
        """ Get the PostProcess result
        
        Returns
        -------
        tuple[tuple[left, top, right, bottom, class_id, score],channel_idx, image_idx]
            
        """
        pass


    def push_data( self, 
        channel_idx : list[int], 
        image_idx : list[int], 
        input_data : list[TensorPTRWithName], 
        dete_threshold : list[float],
        nms_threshold : list[float],
        ost_w : list[int],
        ost_h : list[int],
        padding_attr : list[list[int]]) -> int:
        """ algo_yolov5_post_1output push data.

        Parameters
        ----------
        
        channel_idx : Channel index number of the images.
        image_idx : Image index number of the images.
        data : Input Data
        dete_threshold : Detection thresholds
        nms_threshold : NMS thresholds
        ost_w : Original images width
        ost_h : Original images height
        padding_attr : Padding Attribute[start_x, start_y, width, height]

        Returns
        -------
        return 0 for success and other for failure
        """
        pass

class algo_yolov5_post_cpu_opt_async:
    
    def __init__(self, shape: list[list[int]], network_w:int = 640, network_h:int = 640, max_queue_size: int=20, use_multiclass_nms: bool=True): 
        """ algo_yolov5_post_cpu_opt_async Constructor.

        Parameters
        ----------
        shape: list[list[int]]
        network_w: int, network input width 
        network_h: int, network input height 
        max_queue_size: int, default 20
        use_multiclass_nms: bool, whether to use multi-class NMS, default True
        """
        pass
    
    def reset_anchors(self, anchors_new: list[list[list[int]]]):
        """ Reset Anchors
        
        Parameters
        ----------
        anchors_new: list[list[list[int]]]
        
        Returns
        -------
        return 0 for success and other for failure
        """
        pass
    
    def get_result_npy(self) -> tuple[tuple[int, int, int, int, int, float],int, int]:
        """ Get the PostProcess result
        
        Returns
        -------
        tuple[tuple[left, top, right, bottom, class_id, score],channel_idx, image_idx]
            
        """
        pass


    def push_data( self, 
        channel_idx : list[int], 
        image_idx : list[int], 
        input_data : list[TensorPTRWithName], 
        dete_threshold : list[float],
        nms_threshold : list[float],
        ost_w : list[int],
        ost_h : list[int],
        padding_attr : list[list[int]]) -> int:
        """ algo_yolov5_post_cpu_opt_async push data.

        Parameters
        ----------
        
        channel_idx : Channel index number of the images.
        image_idx : Image index number of the images.
        input_data : Input Data
        dete_threshold : Detection thresholds
        nms_threshold : NMS thresholds
        ost_w : Original images width
        ost_h : Original images height
        padding_attr : Padding Attribute[start_x, start_y, width, height]

        Returns
        -------
        return 0 for success and other for failure
        """
        pass

class algo_yolov5_post_cpu_opt:
    
    def __init__(self, shapes: list[list[int]], network_w:int = 640, network_h:int = 640): 

        """ algo_yolov5_post_cpu_opt Constructor.

        Parameters
        ----------
        shapes: list[list[int]],Input Data shape
        network_w: int, Network input width 
        network_h: int, Network input height 
        """
        pass


    def process(self,input_data:list[TensorPTRWithName], ost_w: list[int], ost_h: list[int], dete_threshold: list[float], nms_threshold: list[float], input_keep_aspect_ratio: bool, input_use_multiclass_nms: bool) -> list[list[tuple[int, int, int, int, int, float]]]:
        """ Process

        Parameters
        ----------
        input_data: list[TensorPTRWithName], Input Data 
        ost_w: list[int], Original image width
        ost_h: list[int], Original image height
        dete_threshold: list[float], Detection threshold
        nms_threshold: list[float], NMS threshold
        input_keep_aspect_ratio: bool, Input keeping aspect ratio  
        input_use_multiclass_nms: bool, Input with multiclass

        Returns
        -------
        list[list[tuple[left, top, right, bottom, class_id, score]]]
            
        """
        pass

    def process(self,input:dict[str, Tensor], ost_w: list[int], ost_h: list[int], dete_threshold: list[float], nms_threshold: list[float], input_keep_aspect_ratio: bool, input_use_multiclass_nms: bool) -> list[list[tuple[int, int, int, int, int, float]]]:
        """ Process

        Parameters
        ----------
        input: dict[str, Tensor], Input Data 
        ost_w: list[int], Original image width
        ost_h: list[int], Original image height
        dete_threshold: list[float], Detection threshold
        nms_threshold: list[float], NMS threshold
        input_keep_aspect_ratio: bool, Input keeping aspect ratio  
        input_use_multiclass_nms: bool, Input with multiclass

        Returns
        -------
        list[list[tuple[left, top, right, bottom, class_id, score]]]
            
        """
        pass
                
    def reset_anchors(self, anchors_new: list[list[list[int]]]):

        """ Reset Anchors
        
        Parameters
        ----------
        anchors_new: list[list[list[int]]]
        
        Returns
        -------
        return 0 for success and other for failure
        """
        pass

class algo_yolov8_seg_post_tpu_opt:
    
    def __init__(self, bmodel_file: str, dev_id: int, detection_shape: list[int], segmentation_shape: list[int], network_h: int, network_w: int): 

        """ algo_yolov8_seg_post_tpu_opt Constructor.

        Parameters
        ----------
        bmodel_file: str, The TPU getmask bmodel path
        dev_id: int, device id
        detection_shape: list[int], The shapes of detection head
        segmentation_shape: list[int], The shapes of segmentation head, that is Prototype Mask
        network_h: int, The input height of yolov8 network
        network_w: int, The input width of yolov8 network
        """
        pass
    
    def process(self, detection_input: TensorPTRWithName, segmentation_input: TensorPTRWithName, ost_h: int, ost_w: int, dete_threshold: float, nms_threshold: float, input_keep_aspect_ratio: bool, input_use_multiclass_nms: bool) -> list[tuple[int, int, int, int, float, int, list[float], numpy.ndarray]]:
        """ Process

        Parameters
        ----------
        detection_input: TensorPTRWithName, The input data of detection head
        segmentation_input: TensorPTRWithName, The input data of segmentation head, that is Prototype Mask
        ost_h: int, Original image height
        ost_w: int, Original image width
        dete_threshold: float, Detection threshold
        nms_threshold: float, NMS threshold
        input_keep_aspect_ratio: bool, Input keeping aspect ratio  
        input_use_multiclass_nms: bool, Input with multiclass

        Returns
        -------
        list[tuple[left, top, right, bottom, score, class_id, contour, mask]]
            
        """
        pass
    
    def process(self, detection_input: dict[str, Tensor], segmentation_input: dict[str, Tensor], ost_h: int, ost_w: int, dete_threshold: float, nms_threshold: float, input_keep_aspect_ratio: bool, input_use_multiclass_nms: bool) -> list[tuple[int, int, int, int, float, int, list[float], numpy.ndarray]]:
        """ Process

        Parameters
        ----------
        detection_input: dict[str, Tensor], The input data of detection head
        segmentation_input: dict[str, Tensor], The input data of segmentation head, that is Prototype Mask
        ost_h: int, Original image height
        ost_w: int, Original image width
        dete_threshold: float, Detection threshold
        nms_threshold: float, NMS threshold
        input_keep_aspect_ratio: bool, Input keeping aspect ratio  
        input_use_multiclass_nms: bool, Input with multiclass

        Returns
        -------
        list[tuple[left, top, right, bottom, score, class_id, contour, mask]]
            
        """
        pass

class deepsort_tracker_controller_async:
    def __init__(self, max_cosine_distance:float, nn_budget:int, k_feature_dim:int, max_iou_distance:float=0.7, max_age:int=30, n_init:int=3, queue_size:int=10):

        """asynchronous deepsort Constructor

        Parameters
        ----------
        max_cosine_distance:float, 
        nn_budget:int, 
        k_feature_dim:int, 
        max_iou_distance:float=0.7, 
        max_age:int=30, 
        n_init:int=3,
        queue_size:int=10
        """

    def push_data(self, detected_objects:list[tuple[int, int, int, int, int, float]], feature:Tensor) -> int:
        """ Asynchronous processing interface. Use with get_result_npy()!
            Track the objects based on the detected objects and their features
        
        Parameters
        ----------
        detected_objects: list(tuple(left, top, right, bottom, class_id, score))
        feature: sail.Tensor, the features of the detected objects
        
        Returns
        -------
        int:Returns 0 on success and others on failure.
        """
    
    def push_data(self, detected_objects:list[tuple[int, int, int, int, int, float]], feature:list[numpy.array]) -> int:
        """ Asynchronous processing interface. Use with get_result_npy()!
            Track the objects based on the detected objects and their features
        
        Parameters
        ----------
        detected_objects: list(tuple(left, top, right, bottom, class_id, score))
        feature: list[numpy.array], the features of the detected objects
        
        Returns
        -------
        int:Returns 0 on success and others on failure.
        """

    def get_result_npy(self) -> list[tuple[int, int, int, int, int, float, int]]:
        """ Asynchronous processing interface. Use with push_data()!
            Track the objects based on the detected objects and their features
        
        Returns
        -------
        tracked_objects: list(tuple(left, top, right, bottom, class_id, score, track_id))
        """
    def set_processing_timer(flag: bool):
        """ set the flag whether printing time cost of each processing 

        Parameters
        ----------
        flag: bool, if True, print the time cost in each processing
                    if False, nothing happens
        
        """

class sort_tracker_controller_async:
    def __init__(self, max_iou_distance:float=0.7, max_age:int=30, n_init:int=3, input_queue_size:int=10, result_queue_size:int=10):

        """asynchronous sort Constructor

        Parameters
        ----------
        max_iou_distance:float=0.7, 
        max_age:int=30, 
        n_init:int=3,
        input_queue_size:int=10,
        result_queue_size:int=10
        """

    def push_data(self, detected_objects:list[tuple[int, int, int, int, int, float]]) -> int:
        """ Asynchronous processing interface. Use with get_result_npy()!
            Track the objects based on the detected objects and their features
        
        Parameters
        ----------
        detected_objects: list(tuple(left, top, right, bottom, class_id, score))
        
        Returns
        -------
        int:Returns 0 on success and others on failure.
        """

    def get_result_npy(self) -> list[tuple[int, int, int, int, int, float, int]]:
        """ Asynchronous processing interface. Use with push_data()!
            Track the objects based on the detected objects and their features
        
        Returns
        -------
        tracked_objects: list(tuple(left, top, right, bottom, class_id, score, track_id))
        """


class Perf:
    def __init__(self, bmodel_path:str, tpu_id:list[int], max_que_size:int, mode:IOMode=IOMode.SYSO, thread_count:int=2, free_input:bool=False):

        """Perf Constructor

        Parameters
        ----------
        bmodel_path:float, Path to bmodel.\n
        tpu_id:list[int], ID of TPUs, there may be more than one TPU for PCIE mode.\n
        max_que_size:int, max queue size.\n
        mode:IOMode, Specify the input/output tensors are in system memory or device memory, default SYSO.\n
        thread_count:int, thread counts with each tpu.\n
        free_input:bool,  release memory of input, default false.\n
        """

    def PushTensor(self, tensor_index:int, input_tensors:list[TensorPTRWithName]) -> int:
        """ Push Tensors 
        
        Parameters
        ----------
        tensor_index: int, index number of the Tensors.
        input_tensors: list[TensorPTRWithName], Input tensors with name
        
        Returns
        -------
        int:Returns 0 on success and others on failure.
        """
    
    def SetEnd(self) -> int:
        """ Stop Push Tensors
        
        Returns
        -------
        int:Returns 0 on success and others on failure.
        """

    def GetResult(self) -> tuple[int, list[TensorPTRWithName]]:
        """ Get the Result Data object
        
        Returns
        -------
        tensor_index: int, Original input data index
        output_data: list(TensorPTRWithName), Output result
        """

    def get_input_dtype(self, graph_name: str, tensor_name: str) -> Dtype:
        """Get data type of an input tensor"""
        pass

    def get_input_scale(self, graph_name: str, tensor_name: str) -> float:
        """Get scale of an input tensor"""
        pass

    def get_input_shape(self, graph_name: str, tensor_name: str) -> list[int]:
        """Get the shape of an input tensor in a graph """
        pass

    def get_output_names(self, graph_name: str) -> list[str]:
        """Get all output tensor names of the specified graph """
        pass

    def get_input_names(self, graph_name: str) -> list[str]:
        """Get all input tensor names of the specified graph """
        pass

    def get_graph_names(self) -> list[str]:
        """Get all graph names in the loaded bomodels """
        pass

class DecoderImages:
    def __init__(self, image_list:list[str], tpu_id:int, queue_size:int):
        """ DecoderImages Constructor

        Parameters
        -----------
        image_list:list[str], image name list\n
        tpu_id:int,TPU ID. You can use bm-smi to see available IDs.\n
        queue_size:int, max queue size\n
        """
        pass

    def setResizeAttr(self, width:int, height:int, resize_alg:bmcv_resize_algorithm = bmcv_resize_algorithm.BMCV_INTER_LINEAR) -> int:
        """ Set the Resize Attr object
        Parameters
        -----------
        width:int,output width\n
        height:int,output height\n
        resize_alg:bmcv_resize_algorithm, Resize algorithm, defalut BMCV_INTER_LINEAR

        Returns
        -----------
        int:Returns 0 on success, other for failed.
        """
        pass

    def start(self) -> int:
        """ Start read images

        Returns
        -----------
        int:Returns 0 on success, other for failed.
        """
        pass


    def read(self, image: BMImage) -> int:
        """ read

        Parameters
        -----------
        image: Output BMImage.

        Returns
        -------
        int:Returns 0 on success, 1 for queue empty, -1 for end or thread stoped.
        """  
        pass

    def stop(self) -> None:
        """ stop 
        """
        pass

    def get_schedule(self) -> int:
        """ Get the schedule object

        Returns
        ---------
        The number of decoded images.
        """
        pass


