Exemplo n.º 1
0
int main(int argc, char* argv[])
{
    using namespace smoothing;

    try {
        po::variables_map vm;
        auto description = process_arguments(argc, argv, vm);

        if (vm.count("help")) {
            std::cout << description;
            return 0;
        }
        auto conf = make_config(vm);
        assert(conf.matrix_type == 220 || conf.matrix_type == 221);

        cout << conf << endl;
        cin.ignore();

        const auto filename = vm["input-file"].as<string>();
        vector<cv::Mat> buf;
        cout << "tools::loadRAT(\"" << filename << "\",buf) ..." << endl;
        loadRAT(filename, buf);

        auto img = convert_opencv<Mat3c>(buf);

        ::release(buf);

        Pyramid pyramid{move(img), conf};

        pyramid.iterate();

        auto do_work = [&](auto param1, auto param2, auto lv) {
            global_smooth(pyramid, param1, param2, lv);
            auto export_name = vm["output-file"].as<std::string>();
            if (vm.count("batch")) {
                export_name += "_param1_" + util::fmt(param1, 3) + "_param2_" +
                               util::fmt(param2, 3) + "_top_" +
                               util::fmt(lv, 0);
            }
            cout << "Exporting RAT File " << export_name << " ..." << endl;
            expor::export_rat(export_name, pyramid.get_result(),
                              conf.matrix_type);
        };

        interface(pyramid, do_work);
        cout << endl << "end main: press enter" << endl;
        cin.ignore();
    }

    catch (const po::error& e) {
        std::cerr << e.what() << std::endl;
        return -1;
    }
    return 0;
}