The following code is detecting only one bbox. I want all bboxes to detected
def detect_patches(img, hex_colors, min_area=100):
    def hex_to_bgr(hex_color):
        hex_color = hex_color.lstrip('#')
        r, g, b = int(hex_color[0:2], 16), int(hex_color[2:4], 16), int(hex_color[4:6], 16)
        return (b, g, r)
    
    # Convert to multiple color spaces for robust detection
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
    
    combined_mask = np.zeros(img.shape[:2], dtype=np.uint8)
    
    for hex_color in hex_colors:
        bgr_color = hex_to_bgr(hex_color)
        
        if hex_color.lower() == '#ff0000':  # Red
            # Method 1: HSV ranges for red
            mask_hsv1 = cv2.inRange(hsv, np.array([0, 70, 50]), np.array([10, 255, 255]))
            mask_hsv2 = cv2.inRange(hsv, np.array([170, 70, 50]), np.array([180, 255, 255]))
            
            # Method 2: LAB color space (better for red)
            mask_lab = cv2.inRange(lab, np.array([20, 150, 0]), np.array([255, 255, 255]))
            
            # Method 3: Direct BGR thresholding
            mask_bgr = cv2.inRange(img, np.array([0, 0, 150]), np.array([100, 100, 255]))
            
            # Combine all methods
            mask = cv2.bitwise_or(mask_hsv1, mask_hsv2)
            mask = cv2.bitwise_or(mask, mask_lab)
            mask = cv2.bitwise_or(mask, mask_bgr)
            
        elif hex_color.lower() == '#de9600':  # Orange
            mask = cv2.inRange(hsv, np.array([10, 100, 100]), np.array([25, 255, 255]))
            
        elif hex_color.lower() == '#ffcb39':  # Yellow
            mask = cv2.inRange(hsv, np.array([20, 100, 100]), np.array([35, 255, 255]))
            
        elif hex_color.lower() == '#21c34a':  # Light green
            mask = cv2.inRange(hsv, np.array([35, 100, 50]), np.array([85, 255, 255]))
            
        else:
            # Generic color detection
            color_bgr = np.uint8([[bgr_color]])
            color_hsv = cv2.cvtColor(color_bgr, cv2.COLOR_BGR2HSV)[0][0]
            h, s, v = color_hsv
            
            lower = np.array([max(0, h-10), 50, 50])
            upper = np.array([min(180, h+10), 255, 255])
            mask = cv2.inRange(hsv, lower, upper)
        
        combined_mask = cv2.bitwise_or(combined_mask, mask)
    
    # Morphology - preserve large patches
    kernel = np.ones((5, 5), np.uint8)
    mask_final = cv2.morphologyEx(combined_mask, cv2.MORPH_CLOSE, kernel, iterations=1)
    mask_final = cv2.morphologyEx(mask_final, cv2.MORPH_OPEN, np.ones((3, 3), np.uint8), iterations=1)
    
    # Find contours
    contours, _ = cv2.findContours(mask_final, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    
    # Results
    result_img = img.copy()
    hot_boxes = []
    
    for contour in contours:
        area = cv2.contourArea(contour)
        if area < min_area:
            continue
        x, y, w, h = cv2.boundingRect(contour)
        hot_boxes.append((x, y, w, h))
        cv2.rectangle(result_img, (x, y), (x + w, y + h), (0, 255, 0), 2)
    return hot_boxes, result_img


# Usage:
hex_colors = [
    "#ff0000",  # red
    "#de9600",  # orange  
    "#ffcb39",  # yellow
    "#21c34a",  # light green
    "#008a21",  # green
    "#016b6d",  # teal
]

# Try version 1
hot_boxes, result_img = detect_patches(img, hex_colors, min_area=10)