package cz.vutbr.feec.utko.objectTracking.example;

import java.util.List;

import org.opencv.core.Point;

public class SizeMatcher implements IMatcher {
	private double multiplicator=0.2;	//0.2
	@Override
	public void setMultiplicator(double multiplicator) {
		this.multiplicator = multiplicator;
	}
	public double getMultiplicator() {
		return multiplicator;
	}
	public void match(List<Template> listOfTemplates,List<Template> listOfDetections,double[][] assignmentArray) {
		// TODO Auto-generated method stub
		for (Template detection : listOfDetections) {
			int IdGoodMatch = 200;
			int nearestSize=100000000;			
			int detectionSize= detection.getRect().height*detection.getRect().width;
			for (Template template : listOfTemplates) {
				int templateSize=template.getRect().height*template.getRect().width;
				int size=Math.abs(detectionSize-templateSize);
				if (size<nearestSize) {
					nearestSize=size;
					IdGoodMatch=listOfTemplates.indexOf(template);
				}
			}
				//detection.setIdOfSizeMatcher(IdGoodMatch);
				assignmentArray[listOfDetections.indexOf(detection)][IdGoodMatch]+=1*multiplicator;
				detection.setNearestSizeChange(nearestSize);
		}
	}

}
