#include "TestThreeDDistortionModel.hpp"

#include <QtTest>

#include <DoQuBook/PluginLoader.hpp>
#include <DoQuBook/DegradationModel.hpp>
#include <DoQuBook/ApplicationContext.hpp>

#include <DoQuBook/DoQuBookApp.hpp>
#include <DoQuBook/AlgorithmPerformancesPredictor.hpp>
#include <DoQuBook/ImageComparator.hpp>

#include <QVariant>
#include <QDate>
#include <QDebug>
#include <QApplication>
#include <cv.h>
#include <highgui.h>
#include <QDir>

#include <boost/random/uniform_int.hpp>
#include <boost/random.hpp>
#include <boost/algorithm/string.hpp>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
/**
  * \mainpage
  *  params["nb"] type : double (required)
  *  params["nbp"] type : double (required)
  *  params["m"] type : double (defaut = 33)
  *  params["n"] type : double (defaut = 33)
  *  params["l"] type : double (defaut = 34)
  *
  */
#include <cxcore.hpp>
using namespace DoQuBook;
using namespace cv;
using namespace boost;

TestThreeDDistortionModel::TestThreeDDistortionModel()
{
  ApplicationContext::instance()->deactivateInternetPlugins();
}

int TestThreeDDistortionModel::testPlugin(){
    int argc; char** argv;
    QApplication app(argc, argv);    
    //QString imgPath = "/media/Donnees/DATA_PhD/Bdx_Degradation/data/DIBCO_ALL/DIBCO2009_Test_images-handwritten/H02.png";//3000
    //QString imgPath = "/media/Donnees/DATA_PhD/Bdx_Degradation/data/DIBCO_ALL/DIBCO11-handwritten_GT/HW1_GT.png";//1500
    QString imgPath = "/media/Donnees/DATA_PhD/Bdx_Degradation/data/DIBCO_ALL/DIBCO11-handwritten/HW7.png";//1000
    //QString imgPath = "/media/Donnees/DATA_PhD/Bdx_Degradation/data/DIBCO_ALL/DIBCO11-handwritten/HW3.png";//750
    QString meshFolder= "/home/kvcuong/WorkingSpace/model-degradation/3DdistortionModel/test/datas/";
    int pageId = 7;
    int pageSide =2;

    QString mesh_path = meshFolder;
    mesh_path.append("livre0");
    mesh_path.append(QString::number(pageId));
    mesh_path.append("_v1_p");
    mesh_path.append(QString::number(pageSide));
    mesh_path.append("_NOR_TEX.obj");

    QVariantMap params;
    params["Image path"] = imgPath;
    params["Mesh path"] = mesh_path;

    QImage image(imgPath);
    ThreeDDistortionModel *distortion = new ThreeDDistortionModel();
    distortion->degradate(image,params);
    return app.exec();
}
//QTEST_MAIN(TestThreeDDistortionModel)


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

    QApplication app(argc, argv);

    QString imgPath = "/media/Donnees/DATA_PhD/Bdx_Degradation/data/DIBCO_ALL/DIBCO11-handwritten/HW7.png";//1000

    QVariantMap params;
    params["Image index"] = "1";
    params["Mesh index"] = "1";

    QImage image(imgPath);
    ThreeDDistortionModel *distortion = new ThreeDDistortionModel();
    distortion->degradate(image,params);
    return app.exec();

}

