//
// Created by Martin Gargalovič on   04. 8. 2021.
//

#include <iostream>

#include <opencv2/core.hpp>
#include <opencv2/core/types.hpp>

#include "arcSegment.h"


std::tuple<double, double, int, double, double, double, int, double, bool>
basic_input_parse(int arc, char *argv[]) {
    double sigma = std::stod(argv[1]);
    double scale = std::stod(argv[2]);
    int polarity = std::stoi(argv[3]);
    double inliersRatio = std::stod(argv[4]);
    double Tr = std::stod(argv[5]);
    double eps = std::stod(argv[6]);
    int searchSize = std::stoi(argv[7]);
    double Tcover = std::stod(argv[8]);
    bool show = std::stoi(argv[9]);
    return std::tie(sigma, scale, polarity, inliersRatio, Tr, eps, searchSize,Tcover,show);
}


int main(int argc, char *argv[]) {

    if (argc < 12) {
        std::cerr << "The detector requires 11 arguments.\n See Arc-support/README.md for required arguments and their ranges" << std::endl;
        return -1;
    }


    cv::Mat image;
    double sigma = 0;
    double scale = 1;
    int polarity = 0;
    double inliersRatio = 0.8;
    double Tr = 0.6;
    double eps = 1.25;
    int searchSize = 16;
    double Tcover = M_PI * 0.8;
    bool show = false;
    std::string out = argv[10];


    std::tie(sigma, scale, polarity, inliersRatio, Tr, eps, searchSize, Tcover,show) = basic_input_parse(argc, argv);

    for (int i = 11; i < argc; ++i) {
        std::string path = argv[i];

        arcSegment(path, scale, polarity, sigma, inliersRatio, Tr, eps,
                   searchSize, Tcover,show, out);
    }
    return 0;
}
