sima ==== .. py:module:: sima Submodules ---------- .. toctree:: :maxdepth: 1 /pages/api_reference/python-autoapi/sima/gst_utils/index /pages/api_reference/python-autoapi/sima/mini_pipeline_base/index /pages/api_reference/python-autoapi/sima/operations/index /pages/api_reference/python-autoapi/sima/video_reader/index Classes ------- .. autoapisummary:: sima.SimaBoxRender sima.MLSoCSession sima.VideoReader sima.VideoWriter Functions --------- .. autoapisummary:: sima.resize sima.cvtColor sima.set_log_level Package Contents ---------------- .. py:function:: resize(image, target_width, target_height) -> numpy.ndarray Resize image to the specified width and height using EV74 kernel. :param image: The input image as a NumPy array. :type image: numpy.ndarray :param target_width: The desired width of the resized image. :type target_width: int :param target_height: The desired height of the resized image. :type target_height: int :returns: The resized image as a NumPy array. :rtype: numpy.ndarray .. py:function:: cvtColor(image, width: int, height: int, color_type: ColorConversionCodes) -> numpy.ndarray Convert the color space of an image using the EV74's Transform Color Conversion kernel. This operation is optimized for performance and leverages hardware acceleration for color conversion. :param image: The input image as a NumPy array. :type image: numpy.ndarray :param width: The width of the image. :type width: int :param height: The height of the image. :type height: int :param color_type: The color conversion code indicating the desired color transformation. :type color_type: ColorConversionCodes Available color conversion options: - sima.COLOR_BGRTORGB - sima.COLOR_RGBTOBGR - sima.COLOR_BGRTOGRAY - sima.COLOR_RGBTOGRAY - sima.COLOR_IYUVTOBGR - sima.COLOR_IYUVTONV12 - sima.COLOR_NV12TOBGR - sima.COLOR_BGRTONV12 - sima.COLOR_RGBTONV12 - sima.COLOR_NV12TORGB :returns: The image with the converted color space. :rtype: numpy.ndarray .. py:class:: SimaBoxRender A class for rendering bounding boxes on images using ARM A65 Core. .. py:attribute:: apu_obj :value: None .. py:method:: render(image: numpy.ndarray, boxes: spy.defines.BoundingBox, frame_width: int, frame_height: int, labelfile: str) -> numpy.ndarray :classmethod: Renders bounding boxes and labels on the given image. :param image: Input image. :type image: np.ndarray :param boxes: List of bounding boxes with attributes (_x, _y, _w, _h, _class_id). :type boxes: list[BoundingBox] :param frame_height: Height of the frame. :type frame_height: int :param frame_width: Width of the frame. :type frame_width: int :param label_map_file: Path to the label map file (used only for first-time initialization). :type label_map_file: str :returns: Image with rendered bounding boxes and labels. :rtype: np.ndarray .. py:function:: set_log_level(level: spy.logger.LogLevel) Set the log level for the PePPi component. This function configures the verbosity of logging for PePPi, controlling which log messages are recorded. Logs are written to the file located at: ``/var/log/simaai_peppi.log``. :param level: The desired logging level (e.g., DEBUG, INFO, WARNING, ERROR). :type level: LogLevel .. py:class:: MLSoCSession(model_file: str, pipeline: str, frame_width: int, frame_height: int, session_name: str = 'model1', ev_preproc=True) A class for interacting with the MLSoC for model inference. .. py:attribute:: pipeline .. py:attribute:: session_name :value: 'model1' .. py:attribute:: session_id :value: '_________Pipeline: Uninferable| Model: model1_________' .. py:attribute:: ev_preproc :value: True .. py:attribute:: parser_obj .. py:attribute:: model_file .. py:attribute:: tensor_shapes .. py:method:: create_plugin(plugin_class) .. py:method:: configure(model_external_params) -> bool Configures EV74, MLA components with external model parameters :param model_external_params: A dictionary containing external parameters for configuring the model and related components. :type model_external_params: dict .. py:method:: a65_preprocess(in_frame: numpy.ndarray) -> numpy.ndarray .. py:method:: preprocess(in_frame: numpy.ndarray) -> numpy.ndarray Preprocesses the input frame for model inference based on the EV74 configuration :param in_frame: The input frame as a NumPy array. :type in_frame: np.ndarray :returns: The preprocessed frame ready for model inference. :rtype: np.ndarray .. py:method:: run_model(frame: numpy.ndarray) -> Union[numpy.ndarray, List[numpy.ndarray]] Runs the model inference (Preprocess, MLA, and Postprocess) on a given frame. For the following models, the output is from SimaBoxDecode: - ``centernet`` - ``yolo`` - ``detr`` - ``effdet`` :param frame: Input frame as a NumPy array. :type frame: np.ndarray :returns: The output tensor after running the model and applying the appropriate postprocessing. - For the models mentioned above, the output is from SimaBoxDecode containing bounding boxes. - For other models, the output is from Detess Dequant. :rtype: np.ndarray .. py:method:: set_log_level(level: spy.logger.LogLevel) .. py:method:: get_configs() .. py:method:: get_inference_resolution() .. py:method:: release() .. py:class:: VideoReader(source: str = None, frame_width: int = 1280, frame_height: int = 720) A class for reading video from various sources, including ``pcie``, ``rtspsrc`` and ``filesrc``. .. py:method:: read() -> Tuple[int, numpy.ndarray] Reads a frame from the video source. .. py:method:: isOpened() -> bool Check whether the video source has been successfully opened. This method verifies that the underlying video reader or stream is properly initialized and ready for reading frames. :returns: True if the video source is open and accessible; False otherwise. :rtype: bool .. py:method:: get_cam_resolution() -> Tuple[int, int] Get frame width and frame height .. py:method:: release() Releases the VideoReader resources. .. py:method:: set_loop(val) .. py:property:: frame_num .. py:class:: VideoWriter(source: str = None, host_ip: str = None, port: int = None, frame_width: int = None, frame_height: int = None) A class for writing video stream to various destinations, including ``pcie``, ``rtspsrc`` and ``filesrc``. .. py:method:: write(frame, meta=None) Writes a frame to the video sink. .. py:method:: release() Releases the VideoWriter resources.