o
    Wh                     @   s   d dl Z d dlmZ d dlZd dlZd dlmZ d dlm	Z	m
Z
mZmZ d dlmZmZ d dlmZ G dd dZG d	d
 d
eZG dd dZdS )    N)defaultdict)YOLO)
ASSETS_URLDEFAULT_CFG_DICTDEFAULT_SOL_DICTLOGGER)check_imshowcheck_requirements)	Annotatorc                   @   sT   e Zd ZdZdddZdddZdd	 Zd
d Zdd Zdd Z	dd Z
dd ZdS )BaseSolutiona  
    A base class for managing Ultralytics Solutions.

    This class provides core functionality for various Ultralytics Solutions, including model loading, object tracking,
    and region initialization.

    Attributes:
        LineString (shapely.geometry.LineString): Class for creating line string geometries.
        Polygon (shapely.geometry.Polygon): Class for creating polygon geometries.
        Point (shapely.geometry.Point): Class for creating point geometries.
        CFG (dict): Configuration dictionary loaded from a YAML file and updated with kwargs.
        region (List[Tuple[int, int]]): List of coordinate tuples defining a region of interest.
        line_width (int): Width of lines used in visualizations.
        model (ultralytics.YOLO): Loaded YOLO model instance.
        names (Dict[int, str]): Dictionary mapping class indices to class names.
        env_check (bool): Flag indicating whether the environment supports image display.
        track_history (collections.defaultdict): Dictionary to store tracking history for each object.

    Methods:
        extract_tracks: Apply object tracking and extract tracks from an input image.
        store_tracking_history: Store object tracking history for a given track ID and bounding box.
        initialize_region: Initialize the counting region and line segment based on configuration.
        display_output: Display the results of processing, including showing frames or saving results.

    Examples:
        >>> solution = BaseSolution(model="yolo11n.pt", region=[(0, 0), (100, 0), (100, 100), (0, 100)])
        >>> solution.initialize_region()
        >>> image = cv2.imread("image.jpg")
        >>> solution.extract_tracks(image)
        >>> solution.display_output(image)
    Fc           	         s  t d ddlm}m}m} ddlm} | _| _| _| _d _d _d _	g  _
g  _g  _d _d _d _t _t| t| i tt _ jdt   jd  _ jd d	vrj jd nd
 _ jd du ryd jd< t jd  _ jj _ jd  _ jd  _ jd  _ fdddD  _|rֈ jd du rd jd vrdnd} jdt  d|  ddl!m"} |t  d|  | jd< t#dd _$t%t& _'dS )a  
        Initializes the BaseSolution class with configuration settings and the YOLO model.

        Args:
            is_cli (bool): Enables CLI mode if set to True.
            **kwargs (Any): Additional configuration parameters that override defaults.
        zshapely>=2.0.0,<2.1.0r   )
LineStringPointPolygon)prepNu   Ultralytics Solutions: ✅ region
line_width)Nr      modelz
yolo11n.ptclasses	show_confshow_labelsc                    s   i | ]}| j | qS  )CFG).0kselfr   S/var/www/vscode/kcb/lib/python3.10/site-packages/ultralytics/solutions/solutions.py
<dictcomp>^   s    z)BaseSolution.__init__.<locals>.<dictcomp>)iouconfdevicemax_dethalftrackerr!   verbosesourcez-posezsolutions_ci_demo.mp4zsolution_ci_pose_demo.mp4z*source not provided. using default source /)safe_downloadT)warn)(r	   shapely.geometryr   r   r   shapely.preparedr   	annotatortracks
track_databoxesclss	track_ids
track_linemasksr_sr   r   updater   r   infor   r   r   r   namesr   r   r   track_add_argswarningr   ultralytics.utils.downloadsr(   r   	env_checkr   listtrack_history)	r   is_clikwargsr   r   r   r   d_sr(   r   r   r   __init__0   sR   





zBaseSolution.__init__Nc                 C   sD   |du rdn| d| j |  }| jr | jr| d|dS |S dS )a  
        Generates a formatted label for a bounding box.

        This method constructs a label string for a bounding box using the class index and confidence score.
        Optionally includes the track ID if provided. The label format adapts based on the display settings
        defined in `self.show_conf` and `self.show_labels`.

        Args:
            cls (int): The class index of the detected object.
            conf (float): The confidence score of the detection.
            track_id (int, optional): The unique identifier for the tracked object. Defaults to None.

        Returns:
            (str or None): The formatted label string if `self.show_labels` is True; otherwise, None.
        N  .2f)r7   r   r   )r   clsr    track_idnamer   r   r   adjust_box_labeln   s    $zBaseSolution.adjust_box_labelc                 C   s   | j jd|d| jd| j| _| jd jp| jd j| _t| jd dr3| jd j	dur3| jd j	nd| _	| jre| jj
dure| jj | _| jj  | _| jj
   | _| jj  | _dS | jd g g g g f\| _| _| _| _dS )aF  
        Applies object tracking and extracts tracks from an input image or frame.

        Args:
            im0 (np.ndarray): The input image or frame.

        Examples:
            >>> solution = BaseSolution()
            >>> frame = cv2.imread("path/to/image.jpg")
            >>> solution.extract_tracks(frame)
        T)r&   persistr   r   r3   Nzno tracks found!r   )r   trackr   r8   r-   obbr/   r.   hasattrr3   idxyxycpurE   tolistr0   intr1   r    confsr   r9   )r   im0r   r   r   extract_tracks   s    . zBaseSolution.extract_tracksc                 C   s^   | j | | _| j|d |d  d |d |d  d f t| jdkr-| jd dS dS )aS  
        Stores the tracking history of an object.

        This method updates the tracking history for a given object by appending the center point of its
        bounding box to the track line. It maintains a maximum of 30 points in the tracking history.

        Args:
            track_id (int): The unique identifier for the tracked object.
            box (List[float]): The bounding box coordinates of the object in the format [x1, y1, x2, y2].

        Examples:
            >>> solution = BaseSolution()
            >>> solution.store_tracking_history(1, [100, 200, 300, 400])
        r   r            N)r=   r2   appendlenpop)r   rF   boxr   r   r   store_tracking_history   s
   0z#BaseSolution.store_tracking_historyc                 C   sF   | j du r
g d| _ t| j dkr| | j | _dS | | j | _dS )zPInitialize the counting region and line segment based on configuration settings.N))     )8  r^   )r_   h  )r]   r`   rV   )r   rY   r   r   r4   r   r   r   r   initialize_region   s   


zBaseSolution.initialize_regionc                 C   sL   | j dr | jr"td| tdd@ tdkr$t  dS dS dS dS )aX  
        Display the results of the processing, which could involve showing frames, printing counts, or saving results.

        This method is responsible for visualizing the output of the object detection and tracking process. It displays
        the processed frame with annotations, and allows for user interaction to close the display.

        Args:
            plot_im (numpy.ndarray): The image or frame that has been processed and annotated.

        Examples:
            >>> solution = BaseSolution()
            >>> frame = cv2.imread("path/to/image.jpg")
            >>> solution.display_output(frame)

        Notes:
            - This method will only display output if the 'show' configuration is set to True and the environment
              supports image display.
            - The display can be closed by pressing the 'q' key.
        showzUltralytics SolutionsrU      qN)r   getr;   cv2imshowwaitKeyorddestroyAllWindows)r   plot_imr   r   r   display_output   s   zBaseSolution.display_outputc                 O   s   dS )z?Process method should be implemented by each Solution subclass.Nr   )r   argsr?   r   r   r   process   s    zBaseSolution.processc                 O   s.   | j |i |}| jd rtd|  |S )zEAllow instances to be called like a function with flexible arguments.r%   u   🚀 Results: )rn   r   r   r6   )r   rm   r?   resultr   r   r   __call__   s   
zBaseSolution.__call__)F)N)__name__
__module____qualname____doc__rA   rH   rT   r\   ra   rl   rn   rp   r   r   r   r   r      s    
 
>r   c                       s   e Zd ZdZd/ fdd	Zd0d
dZd1ddZdd Zedd Z	d2ddZ
d3ddZ	d3ddZ	d4ddZd d! Zd5d$d%Zd6d'd(Zd7d+d,Zd8d-d.Z  ZS )9SolutionAnnotatoraV  
    A specialized annotator class for visualizing and analyzing computer vision tasks.

    This class extends the base Annotator class, providing additional methods for drawing regions, centroids, tracking
    trails, and visual annotations for Ultralytics Solutions: https://docs.ultralytics.com/solutions/.
    and parking management.

    Attributes:
        im (np.ndarray): The image being annotated.
        line_width (int): Thickness of lines used in annotations.
        font_size (int): Size of the font used for text annotations.
        font (str): Path to the font file used for text rendering.
        pil (bool): Whether to use PIL for text rendering.
        example (str): An example attribute for demonstration purposes.

    Methods:
        draw_region: Draws a region using specified points, colors, and thickness.
        queue_counts_display: Displays queue counts in the specified region.
        display_analytics: Displays overall statistics for parking lot management.
        estimate_pose_angle: Calculates the angle between three points in an object pose.
        draw_specific_points: Draws specific keypoints on the image.
        plot_workout_information: Draws a labeled text box on the image.
        plot_angle_and_count_and_stage: Visualizes angle, step count, and stage for workout monitoring.
        plot_distance_and_line: Displays the distance between centroids and connects them with a line.
        display_objects_labels: Annotates bounding boxes with object class labels.
        sweep_annotator: Visualizes a vertical sweep line and optional label.
        visioneye: Maps and connects object centroids to a visual "eye" point.
        circle_label: Draws a circular label within a bounding box.
        text_label: Draws a rectangular label within a bounding box.

    Examples:
        >>> annotator = SolutionAnnotator(image)
        >>> annotator.draw_region([(0, 0), (100, 100)], color=(0, 255, 0), thickness=5)
        >>> annotator.display_analytics(
        ...     image, text={"Available Spots": 5}, txt_color=(0, 0, 0), bg_color=(255, 255, 255), margin=10
        ... )
    N	Arial.ttfFabcc                    s   t  |||||| dS )a  
        Initializes the SolutionAnnotator class with an image for annotation.

        Args:
            im (np.ndarray): The image to be annotated.
            line_width (int, optional): Line thickness for drawing on the image.
            font_size (int, optional): Font size for text annotations.
            font (str, optional): Path to the font file.
            pil (bool, optional): Indicates whether to use PIL for rendering text.
            example (str, optional): An example parameter for demonstration purposes.
        N)superrA   )r   imr   	font_sizefontpilexample	__class__r   r   rA     s   zSolutionAnnotator.__init__r   rc   r      c                 C   sV   t j| jtj|tjdgd||d |D ]}t | j|d |d f|d |d qdS )	a8  
        Draw a region or line on the image.

        Args:
            reg_pts (List[Tuple[int, int]]): Region points (for line 2 points, for region 4+ points).
            color (Tuple[int, int, int]): RGB color value for the region.
            thickness (int): Line thickness for drawing the region.
        )dtypeT)isClosedcolor	thicknessr   rU   r   N)rf   	polylinesry   nparrayint32circle)r   reg_ptsr   r   pointr   r   r   draw_region  s   $	&zSolutionAnnotator.draw_regionrc   rc   rc   r   r   r   c              
   C   s   dd |D }dd |D }t |t| }t |t| }tj|d| j| jdd }	|	d }
|	d }|
d }|d }||d  ||d  f}||d  ||d  f}t| j|||d	 ||
d  }||d  }tj| j|||fd| j|| jtj	d
 dS )a  
        Displays queue counts on an image centered at the points with customizable font size and colors.

        Args:
            label (str): Queue counts label.
            points (List[Tuple[int, int]]): Region points for center point calculation to display text.
            region_color (Tuple[int, int, int]): RGB queue region color.
            txt_color (Tuple[int, int, int]): RGB text display color.
        c                 S      g | ]}|d  qS )r   r   r   r   r   r   r   
<listcomp>-      z:SolutionAnnotator.queue_counts_display.<locals>.<listcomp>c                 S   r   )rU   r   r   r   r   r   r   .  r   r   	fontScaler   rU   r]   r   r   )r   r   r   lineTypeN)
sumrY   rf   getTextSizesftf	rectanglery   putTextLINE_AA)r   labelpointsregion_color	txt_colorx_valuesy_valuescenter_xcenter_y	text_size
text_widthtext_height
rect_widthrect_heightrect_top_leftrect_bottom_righttext_xtext_yr   r   r   queue_counts_display#  s0   

z&SolutionAnnotator.queue_counts_displayc                 C   s8  t |jd d }t |jd d }d}| D ]\}	}
|	 d|
 }t|d| j| jd }|d dk s;|d dk r=d}|jd |d  |d  | }||d  |d  | }||d  }||d  |d  }||d  |d  }||d  }t|||f||f|d	 tj||||fd| j|| jtj	d
 |}qdS )a  
        Display the overall statistics for parking lots, object counter etc.

        Args:
            im0 (np.ndarray): Inference image.
            text (Dict[str, Any]): Labels dictionary.
            txt_color (Tuple[int, int, int]): Display color for text foreground.
            bg_color (Tuple[int, int, int]): Display color for text background.
            margin (int): Gap between text and rectangle for better display.
        rU   g{Gz?r   g{Gz?z: r   )r   r   r   r   r   N)
rQ   shapeitemsrf   r   r   r   r   r   r   )r   rS   textr   bg_colormarginhorizontal_gapvertical_gaptext_y_offsetr   valuetxtr   r   r   rect_x1rect_y1rect_x2rect_y2r   r   r   display_analyticsK  s$   $z#SolutionAnnotator.display_analyticsc                 C   sn   t |d |d  |d |d  t | d |d  | d |d   }t|d t j }|dkr3|S d| S )a  
        Calculate the angle between three points for workout monitoring.

        Args:
            a (List[float]): The coordinates of the first point.
            b (List[float]): The coordinates of the second point (vertex).
            c (List[float]): The coordinates of the third point.

        Returns:
            (float): The angle in degrees between the three points.
        rU   r   g     f@r`   )mathatan2abspi)abcradiansangler   r   r   estimate_pose_angleh  s   Hz%SolutionAnnotator.estimate_pose_angler         ?c           	   	      s   pg d fddt |D }t|dd |dd D ]\}}tj| j||ddtjd	 q|D ]}tj| j||d
dtjd	 q3| jS )aD  
        Draw specific keypoints for gym steps counting.

        Args:
            keypoints (List[List[float]]): Keypoints data to be plotted, each in format [x, y, confidence].
            indices (List[int], optional): Keypoint indices to be plotted.
            radius (int, optional): Keypoint radius.
            conf_thresh (float, optional): Confidence threshold for keypoints.

        Returns:
            (np.ndarray): Image with drawn keypoints.

        Note:
            Keypoint format: [x, y] or [x, y, confidence].
            Modifies self.im in-place.
        )r   r      c                    s<   g | ]\}}|v r|d   krt |d t |d fqS )r   r   rU   )rQ   )r   ir   conf_threshindicesr   r   r     s   < z8SolutionAnnotator.draw_specific_kpts.<locals>.<listcomp>Nr   rU   r   r   r   )r   r   rc   )	enumerateziprf   linery   r   r   )	r   	keypointsr   radiusr   r   startendptr   r   r   draw_specific_kptsy  s   "z$SolutionAnnotator.draw_specific_kptsh         c              	   C   s   t |d| j| j\\}}}t | j|d |d | d f|d | d |d | d | d | j f|d t | j||d| j|| j |S )a  
        Draw workout text with a background on the image.

        Args:
            display_text (str): The text to be displayed.
            position (Tuple[int, int]): Coordinates (x, y) on the image where the text will be placed.
            color (Tuple[int, int, int], optional): Text background color.
            txt_color (Tuple[int, int, int], optional): Text foreground color.

        Returns:
            (int): The height of the text.
        r   rU   r   
   r   )rf   r   r   r   r   ry   r   )r   display_textpositionr   r   r   r   _r   r   r   plot_workout_information  s   ,z*SolutionAnnotator.plot_workout_informationc           	      C   s   d|dd| d| }}}|  |t|d t|d f||}|  |t|d t|d | d f||}|  |t|d t|d | | d f|| dS )	a  
        Plot the pose angle, count value, and step stage for workout monitoring.

        Args:
            angle_text (str): Angle value for workout monitoring.
            count_text (str): Counts value for workout monitoring.
            stage_text (str): Stage decision for workout monitoring.
            center_kpt (List[int]): Centroid pose index for workout monitoring.
            color (Tuple[int, int, int], optional): Text background color.
            txt_color (Tuple[int, int, int], optional): Text foreground color.
        rC   rD   zSteps : r   rU   r]   (   N)r   rQ   )	r   
angle_text
count_text
stage_text
center_kptr   r   angle_heightcount_heightr   r   r   plot_angle_and_count_and_stage  s   $$(z0SolutionAnnotator.plot_angle_and_count_and_stagerc   r   rc   c           
   
   C   s   d|d}t |d| j| j\\}}}t | jdd| d d| d f|d dd| d	 f}	t | j||	d| jd
| jt j t | j|d |d |d t 	| j|d d|d t 	| j|d d|d dS )a  
        Plot the distance and line between two centroids on the frame.

        Args:
            pixels_distance (float): Pixels distance between two bbox centroids.
            centroids (List[Tuple[int, int]]): Bounding box centroids data.
            line_color (Tuple[int, int, int], optional): Distance line color.
            centroid_color (Tuple[int, int, int], optional): Bounding box centroid color.
        zPixels Distance: rD   r   )      r   r]   r   r   r   r   rU   rV      N)
rf   r   r   r   r   ry   r   r   r   r   )
r   pixels_distance	centroids
line_colorcentroid_colorr   text_width_mtext_height_mr   text_positionr   r   r   plot_distance_and_line  s"   (z(SolutionAnnotator.plot_distance_and_linec              
   C   s   t j|d| j| jdd }||d d  }	||d d  }
|	| }|
|d  | }|	|d  | }|
| }t |t|t|ft|t|fttt|d t j||t|	t|
fd| jttt|| jt j	d dS )aA  
        Display the bounding boxes labels in parking management app.

        Args:
            im0 (np.ndarray): Inference image.
            text (str): Object/class name.
            txt_color (Tuple[int, int, int]): Display color for text foreground.
            bg_color (Tuple[int, int, int]): Display color for text background.
            x_center (float): The x position center point for bounding box.
            y_center (float): The y position center point for bounding box.
            margin (int): The gap between text and rectangle for better display.
        r   r   r   rU   r   r   N)
rf   r   r   r   r   rQ   tuplemapr   r   )r   rS   r   r   r   x_centery_centerr   r   r   r   r   r   r   r   r   r   r   display_objects_labels  s0   
z(SolutionAnnotator.display_objects_labelsr      r      c           	   	   C   s   t | j|df||f|| jd  |rit |t j| j| j\\}}}t | j||d  d |d |d  d f||d  d |d |d  d f|d t | j|||d  |d |d  ft j| j|| j dS dS )a  
        Draw a sweep annotation line and an optional label.

        Args:
            line_x (int): The x-coordinate of the sweep line.
            line_y (int): The y-coordinate limit of the sweep line.
            label (str, optional): Text label to be drawn in center of sweep line. If None, no label is drawn.
            color (Tuple[int, int, int]): RGB color for the line and label background.
            txt_color (Tuple[int, int, int]): RGB color for the label text.
        r   r   r   r   N)	rf   r   ry   r   r   FONT_HERSHEY_SIMPLEXr   r   r   )	r   line_xline_yr   r   r   r   r   r   r   r   r   sweep_annotator  s(   """z!SolutionAnnotator.sweep_annotator         c                 C   s~   t |d |d  d t |d |d  d f}t| j|| jd |d t| j|| jd |d t| j|||| j dS )a  
        Perform pinpoint human-vision eye mapping and plotting.

        Args:
            box (List[float]): Bounding box coordinates in format [x1, y1, x2, y2].
            center_point (Tuple[int, int]): Center point for vision eye view.
            color (Tuple[int, int, int]): Object centroid and line color.
            pin_color (Tuple[int, int, int]): Visioneye point color.
        r   r   rU   rV   r   N)rQ   rf   r   ry   r   r   )r   r[   center_pointr   	pin_colorcenter_bboxr   r   r   	visioneye=  s   0
zSolutionAnnotator.visioneyerB      r  r  c              
   C   s  t |dkrtdt | d |dd }t|d |d  d t|d |d  d }}tt|tj| jd | j	d }t|d d |d d  d	 d | }	t
| j||f|	|d
 ||d d  }
||d d  }tj| jt||
|ftj| jd | ||| j	tjd dS )a  
        Draw a label with a background circle centered within a given bounding box.

        Args:
            box (Tuple[float, float, float, float]): The bounding box coordinates (x1, y1, x2, y2).
            label (str): The text label to be displayed.
            color (Tuple[int, int, int]): The background color of the circle (B, G, R).
            txt_color (Tuple[int, int, int]): The color of the text (R, G, B).
            margin (int): The margin between the text and the circle border.
        rV   zLength of label is z:, only first 3 letters will be used for circle annotation.Nr   r   rU   g333333?g      ?r   r   )rY   r   r9   rQ   rf   r   strr   r   r   r   ry   r   get_txt_colorr   )r   r[   r   r   r   r   r   r   r   required_radiusr   r   r   r   r   circle_labelL  s&   2"(

zSolutionAnnotator.circle_labelc              
   C   s   t |d |d  d t |d |d  d }}t|tj| jd | jd }||d d  }	||d d  }
|	| }|
|d  | }|	|d  | }|
| }t| j||f||f|d tj| j||	|
ftj| jd | 	||| jtj
d dS )	a  
        Draw a label with a background rectangle centered within a given bounding box.

        Args:
            box (Tuple[float, float, float, float]): The bounding box coordinates (x1, y1, x2, y2).
            label (str): The text label to be displayed.
            color (Tuple[int, int, int]): The background color of the rectangle (B, G, R).
            txt_color (Tuple[int, int, int]): The color of the text (R, G, B).
            margin (int): The margin between the text and the rectangle border.
        r   r   rU   rV   g?r   r   N)rQ   rf   r   r   r   r   r   ry   r   r  r   )r   r[   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
text_labelr  s&   2

zSolutionAnnotator.text_label)NNrv   Frw   )Nr   r   )Nr   r   )Nr   r   )r   r   )r   r   )r   r   Nr   r   )r  r   )rB   r  r   r   )rB   r  r   r   )rq   rr   rs   rt   rA   r   r   r   staticmethodr   r   r   r   r   r   r  r
  r  r  __classcell__r   r   r~   r   ru      s&    &

(




$
(
"
&ru   c                   @   s    e Zd ZdZdd Zdd ZdS )SolutionResultsa  
    A class to encapsulate the results of Ultralytics Solutions.

    This class is designed to store and manage various outputs generated by the solution pipeline, including counts,
    angles, and workout stages.

    Attributes:
        plot_im (np.ndarray): Processed image with counts, blurred, or other effects from solutions.
        in_count (int): The total number of "in" counts in a video stream.
        out_count (int): The total number of "out" counts in a video stream.
        classwise_count (Dict[str, int]): A dictionary containing counts of objects categorized by class.
        queue_count (int): The count of objects in a queue or waiting area.
        workout_count (int): The count of workout repetitions.
        workout_angle (float): The angle calculated during a workout exercise.
        workout_stage (str): The current stage of the workout.
        pixels_distance (float): The calculated distance in pixels between two points or objects.
        available_slots (int): The number of available slots in a monitored area.
        filled_slots (int): The number of filled slots in a monitored area.
        email_sent (bool): A flag indicating whether an email notification was sent.
        total_tracks (int): The total number of tracked objects.
        region_counts (dict): The count of objects within a specific region.
        speed_dict (Dict[str, float]): A dictionary containing speed information for tracked objects.
        total_crop_objects (int): Total number of cropped objects using ObjectCropper class.
    c                 K   sp   d| _ d| _d| _i | _d| _d| _d| _d| _d| _d| _	d| _
d| _d| _i | _i | _d| _| j| dS )z
        Initialize a SolutionResults object with default or user-specified values.

        Args:
            **kwargs (Any): Optional arguments to override default attribute values.
        Nr           F)rk   in_count	out_countclasswise_countqueue_countworkout_countworkout_angleworkout_stager   available_slotsfilled_slots
email_senttotal_tracksregion_counts
speed_dicttotal_crop_objects__dict__r5   )r   r?   r   r   r   rA     s"   zSolutionResults.__init__c                 C   s4   dd | j  D }dddd | D  dS )z
        Return a formatted string representation of the SolutionResults object.

        Returns:
            (str): A string representation listing non-null attributes.
        c                 S   s0   i | ]\}}|d kr|di dddfvr||qS )rk   Nr   r  Fr   r   r   vr   r   r   r     s
    z+SolutionResults.__str__.<locals>.<dictcomp>zSolutionResults(z, c                 s   s"    | ]\}}| d | V  qdS )=Nr   r%  r   r   r   	<genexpr>  s     z*SolutionResults.__str__.<locals>.<genexpr>))r$  r   join)r   attrsr   r   r   __str__  s    zSolutionResults.__str__N)rq   rr   rs   rt   rA   r,  r   r   r   r   r    s    r  )r   collectionsr   rf   numpyr   ultralyticsr   ultralytics.utilsr   r   r   r   ultralytics.utils.checksr   r	   ultralytics.utils.plottingr
   r   ru   r  r   r   r   r   <module>   s    Q   <