func TestCorrMultiStrideNaive_vsDecimate(t *testing.T) { const ( numIn = 4 eps = 1e-9 ) for _, q := range strideCases { f := randMulti(q.ImSize.X, q.ImSize.Y, numIn) g := randMulti(q.TmplSize.X, q.TmplSize.Y, numIn) h, err := slide.CorrMulti(f, g) if err != nil { t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err) continue } want := slide.Decimate(h, q.K) got, err := slide.CorrMultiStrideNaive(f, g, q.K) if err != nil { t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err) continue } if err := errIfNotEqImage(want, got, eps); err != nil { t.Errorf("im %v, tmpl %v, stride %d: %v", q.ImSize, q.TmplSize, q.K, err) continue } } }
func evalImages(tmpl *rimg64.Multi, ims []string, dir string, sbin int) ([]float64, error) { var scores []float64 for i, file := range ims { log.Printf("neg: %d/%d: %s", i+1, len(ims), file) im, err := loadFeatImage(path.Join(dir, file), sbin) if err != nil { return nil, err } // Obtain response to sliding window. resp := slide.CorrMulti(im, tmpl) scores = append(scores, resp.Elems...) } return scores, nil }