Beispiel #1
0
func (self *MaskIndex) FindBestMatchedMasks(img *cv.BinaryImage, chType int, widthWeight int) []*Result {
	h := img.FeatureEncode()
	ids, ok := self.index[h]
	if !ok {
		return nil
	}

	results := ResultSorter{}
	for _, i := range ids {
		mk := self.masks[i]
		if !mk.MatchChType(chType) {
			continue
		}
		sim := mk.Match(img, 0, 0)
		sim *= float64(img.Width)
		sim /= float64(img.Width + widthWeight)
		results = append(results, NewResult(mk.Label, sim))
	}
	sort.Sort(results)
	return results
}
Beispiel #2
0
func (self *MaskIndex) QueryMask(img *cv.BinaryImage) ([]int, bool) {
	h := img.FeatureEncode()
	ret, ok := self.index[h]
	return ret, ok
}