package ac.essex.ooechs.facedetection.util;

import ac.essex.ooechs.imaging.commons.fast.IntegralImage;
import ac.essex.ooechs.adaboost.AdaBoostSample;

import java.io.File;

/**
 * <p/>
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version,
 * provided that any use properly credits the author.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details at http://www.gnu.org
 * </p>
 *
 * @author Olly Oechsle, University of Essex, Date: 12-Jun-2008
 * @version 1.0
 */
public class IntegralTrainingImage extends AdaBoostSample {

    private File f;
    private IntegralImage image;
    
    public int classID;
    public double weight = 1;

    public IntegralTrainingImage(File f, int classID) {
        super(null);
        this.f = f;
        this.classID = classID;
    }

    public int getLabel() {
        return classID;
    }

    public Object getData() {
        return getImage();
    }

    public IntegralImage getImage() {
        try {
            if (image == null) {
                image = new IntegralImage(f);
                image.setPixelLoaderNull();
            }
            return image;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public void clearImage() {
        image = null;
    }

    public String getName() {
        return f.getName();
    }

}
