#include "seam_compensator.h"

// ---------- Constructor ---------- //
SeamCompensator::SeamCompensator(std::string seam_find_type,
	cv::Ptr<cv::detail::ExposureCompensator> &compensator,
	int exposure_compensator_type) {

	if (seam_find_type == "no") {
		seam_finder = new cv::detail::NoSeamFinder();
	}
	else if (seam_find_type == "voronoi") {
		seam_finder = new cv::detail::VoronoiSeamFinder();
	}
	else if (seam_find_type == "gc_color") {
		seam_finder = new cv::detail::GraphCutSeamFinder(cv::detail::GraphCutSeamFinderBase::COST_COLOR);
	}
	else if (seam_find_type == "gc_colorgrad") {
		seam_finder = new cv::detail::GraphCutSeamFinder(cv::detail::GraphCutSeamFinderBase::COST_COLOR_GRAD);
	}
	else if (seam_find_type == "dp_color") {
		seam_finder = new cv::detail::DpSeamFinder(cv::detail::DpSeamFinder::COLOR);
	}
	else if (seam_find_type == "dp_colorgrad") {
		seam_finder = new cv::detail::DpSeamFinder(cv::detail::DpSeamFinder::COLOR_GRAD);
	}

	compensator = cv::detail::ExposureCompensator::createDefault(exposure_compensator_type);
}

int SeamCompensator::seam_compensate(std::vector<cv::Point> &corners,
	std::vector<cv::Mat> &images_warped,
	std::vector<cv::Mat> &masks_warped,
	cv::Ptr<cv::detail::ExposureCompensator> &compensator,
	std::vector<cv::Mat> &images_warped_temp) {

	compensator->feed(corners, images_warped, masks_warped);
	seam_finder->find(images_warped_temp, corners, masks_warped);

	return 0;
}
