IVALab Python Libraries
Collection of code for computer vision and robotics with specific API.
Classes | Namespaces | Functions | Variables
BoW.py File Reference

Classes

class  CfgBoW
 Configuration setting specifier for ColorBoWMatcher class. More...
 
class  ColorBoWMatcher
 

Namespaces

 puzzle.piece.BoW
 Bag-of-Words style color matching system using OpenCV K-Means.
 
 puzzle.pieces.BoW
 

Functions

np.ndarray build_vocabulary (list[RGBMatrix] groups, int n_words=20, *int max_iter=100, float epsilon=1.0, int attempts=5, int random_seed=42)
 
list[Histogram] encode_all (list[RGBMatrix] groups, np.ndarray centroids, *bool normalize=True)
 
Histogram encode_histogram (RGBMatrix group, np.ndarray centroids, *bool normalize=True)
 
float histogram_distance (Histogram h1, Histogram h2, DistanceMetric metric="chi2")
 

Variables

int best = top[1] if top[0]["distance"] < 1e-6 else top[0]
 
 DistanceMetric = Literal["chi2", "intersection", "hellinger", "l2", "cosine"]
 Literal type enumerating supported histogram distance metrics. More...
 
 groups
 
 hist_img = matcher.histogram_image(group_idx=0)
 
 Histogram = np.ndarray
 A (n_words,) float32 numpy ndarray representing an L1-normalized BoW histogram. More...
 
 labels
 
 matcher = ColorBoWMatcher(n_words=20, metric="chi2")
 
 metric
 
 n_groups
 
 n_pixels_per_group
 
 n_true_colors
 
dictionary nonzero = {f"w{i}": f"{v:.3f}" for i, v in enumerate(hist) if v > 0}
 
 query_group = groups[0]
 
 results = matcher.query(query_group)
 
 RGBMatrix = np.ndarray
 A (3, N) numpy ndarray of dtype uint8 or float32 holding RGB pixel data. More...
 
 rng = np.random.default_rng(42)
 
 top = matcher.query(query_group, top_k=2)
 
 vocab_img = matcher.vocabulary_as_image(swatch_size=50)