File size: 806 Bytes
fa54254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import colorsys

# Define the categories
CATEGORIES = ["info", "table", "part", "surface-all", "GD&T", "zoom", "surface-trie", 
              "3D", "edge", "surface-check", "corner", "surface-ball", "info-table"]



# Generate distinct colors for each category
def generate_colors(n):
    colors = []
    for i in range(n):
        # Use HSV color space to generate evenly distributed distinct colors
        hue = i / n
        sat = 0.8 + (i % 3) * 0.1  # Vary saturation slightly
        val = 0.8 + (i % 2) * 0.1  # Vary value slightly
        
        # Convert to RGB
        rgb = colorsys.hsv_to_rgb(hue, sat, val)
        
        # Convert to BGR (for OpenCV) and scale to 0-255
        bgr = (int(rgb[2] * 255), int(rgb[1] * 255), int(rgb[0] * 255))
        colors.append(bgr)
    return colors