Parcourir la source

Final version 1.0 of csl and adding official test directory

Rémi Synave il y a 1 an
Parent
commit
cf72506e0a
40 fichiers modifiés avec 73 ajouts et 26 suppressions
  1. 51 23
      csl/Experiment.cpp
  2. 3 3
      csl/Experiment.hpp
  3. BIN
      officialTestDirectory/img01.jpg
  4. 1 0
      officialTestDirectory/img01_algo.json
  5. BIN
      officialTestDirectory/img02.jpg
  6. 1 0
      officialTestDirectory/img02_algo.json
  7. BIN
      officialTestDirectory/img03.jpg
  8. 1 0
      officialTestDirectory/img03_algo.json
  9. BIN
      officialTestDirectory/img04.jpg
  10. 1 0
      officialTestDirectory/img04_algo.json
  11. BIN
      officialTestDirectory/img05.jpg
  12. 1 0
      officialTestDirectory/img05_algo.json
  13. BIN
      officialTestDirectory/img06.jpg
  14. 1 0
      officialTestDirectory/img06_algo.json
  15. BIN
      officialTestDirectory/img07.jpg
  16. 1 0
      officialTestDirectory/img07_algo.json
  17. BIN
      officialTestDirectory/img08.jpg
  18. 1 0
      officialTestDirectory/img08_algo.json
  19. BIN
      officialTestDirectory/img09.jpg
  20. 1 0
      officialTestDirectory/img09_algo.json
  21. BIN
      officialTestDirectory/img10.jpg
  22. 1 0
      officialTestDirectory/img10_algo.json
  23. BIN
      officialTestDirectory/img11.jpg
  24. 1 0
      officialTestDirectory/img11_algo.json
  25. BIN
      officialTestDirectory/img12.jpg
  26. 1 0
      officialTestDirectory/img12_algo.json
  27. BIN
      officialTestDirectory/img13.jpg
  28. 1 0
      officialTestDirectory/img13_algo.json
  29. BIN
      officialTestDirectory/img14.jpg
  30. 1 0
      officialTestDirectory/img14_algo.json
  31. BIN
      officialTestDirectory/img15.jpg
  32. 1 0
      officialTestDirectory/img15_algo.json
  33. BIN
      officialTestDirectory/img16.jpg
  34. 1 0
      officialTestDirectory/img16_algo.json
  35. BIN
      officialTestDirectory/img17.jpg
  36. 1 0
      officialTestDirectory/img17_algo.json
  37. BIN
      officialTestDirectory/img18.jpg
  38. 1 0
      officialTestDirectory/img18_algo.json
  39. BIN
      officialTestDirectory/img19.jpg
  40. 1 0
      officialTestDirectory/img19_algo.json

+ 51 - 23
csl/Experiment.cpp

@@ -11,6 +11,10 @@
 #include <QVBoxLayout>
 #include <QHBoxLayout>
 #include <QPushButton>
+#include <QTextStream>
+#include <QJsonObject>
+#include <QJsonArray>
+#include <QJsonDocument>
 
 #include <QDebug>
 
@@ -25,6 +29,8 @@ Experiment::Experiment ():QMainWindow()
   filenames = NULL;
   filenames_json = NULL;
   suffix = NULL;
+  choice = NULL;
+  algo_side='X';
 
   setWindowTitle (tr ("DSL - Draw Strength Line"));
 
@@ -93,17 +99,14 @@ Experiment::Experiment ():QMainWindow()
   progressBar->setFixedHeight(20);
   progressBar->setRange(0, maxProgressBar);
   progressBar->setValue(0);
-  // connect(progressBar, SIGNAL(valueChanged(int)), this, SLOT(progressBarValueChanged(int)));
   layoutV->addWidget(progressBar);
 
   timer = new QTimer(central);
   timer->setSingleShot(false);
   timer->setInterval(time);
-  // connect(timer, SIGNAL(timeout()), this, SLOT(ticTimer()));
   
   setFixedSize (screenWidth, screenHeight);
 
-  /*timer->start();*/
 }
 
 void
@@ -123,14 +126,16 @@ Experiment::open ()
       bool ok;
       suffix = new QString(QInputDialog::getText(this, tr("Your ID"),
 						 tr("ID to use :"), QLineEdit::Normal,
-						 "_"+QDir::home().dirName(), &ok));
+						 QDir::home().dirName(), &ok));
       
       if(ok)
 	{
 	  delete filenames;
 	  delete filenames_json;
+	  delete choice;
 	  filenames = new QStringList();
 	  filenames_json = new QStringList();
+	  choice = new QStringList();
 	  
 	  QDirIterator it(*directoryname, {"*.jpg", "*.png"}, QDir::Files);
 	  while (it.hasNext()) {
@@ -169,27 +174,33 @@ Experiment::open ()
 }
 
 void Experiment::leftImage(){
-  qDebug() << "Clic sur image gauche" << Qt::endl;
-  progressBar->setValue(0);
+  if((algo_side != 'L') && (algo_side != 'R'))
+    {
+      qDebug() << "Something went wrong";
+      QApplication::quit();
+    }
+  if(algo_side == 'L')
+    choice->append(QString("algo"));
+  else
+    choice->append(QString("random"));
+  
   openNext();
 }
 
 void Experiment::rightImage(){
-  qDebug() << "Clic sur image droite" << Qt::endl;
-  progressBar->setValue(0);
+  if((algo_side != 'L') && (algo_side != 'R'))
+    {
+      qDebug() << "Something went wrong";
+      QApplication::quit();
+    }
+  if(algo_side == 'R')
+    choice->append(QString("algo"));
+  else
+    choice->append(QString("random"));
+  
   openNext();
 }
 
-/*void Experiment::progressBarValueChanged(int value){
-  if(value == maxProgressBar ){
-    qDebug() << "That's all folks !" << Qt::endl;
-    QApplication::quit();
-  }
-  }*/
-
-/*void Experiment::ticTimer(){
-  progressBar->setValue(progressBar->value()+time);
-  }*/
 
 void
 Experiment::openNext (){
@@ -200,6 +211,26 @@ Experiment::openNext (){
   if(openedImage >= filenames->size())
     {
       qDebug() << "That's all folks !" << Qt::endl;
+
+      /* Saving result file*/
+      QJsonObject root;
+      QJsonArray choices;
+      
+      for (int i = 0; i < choice->size (); i++){
+	QJsonObject choiceOnImage;
+	choiceOnImage["index"] = i;
+	choiceOnImage["image"] = QString(filenames->at(i));
+	choiceOnImage["choice"] = QString(choice->at(i));
+	choices.push_back(choiceOnImage);
+      }
+      
+      root["choices"] = choices;
+      
+      QByteArray ba = QJsonDocument(root).toJson();
+      QFile fout((*suffix)+QString::fromStdString (".json"));
+      fout.open(QIODevice::WriteOnly);
+      fout.write(ba);
+      
       QApplication::quit();
     }
   else
@@ -212,20 +243,17 @@ Experiment::openNext (){
       if((std::rand()%2) == 0)
 	{
 	  waLeft->loadSL (filenames_json->at(openedImage).toStdString ());
+	  algo_side='L';
 	  for(int i = 0 ; i < waLeft->getNumberOfLines() ; i++)
 	    waRight->addRandomSL();
 	}
       else
 	{
 	  waRight->loadSL (filenames_json->at(openedImage).toStdString ());
+	  algo_side='R';
 	  for(int i = 0 ; i < waRight->getNumberOfLines() ; i++)
 	    waLeft->addRandomSL();
 	}
-      /*waLeft->loadImage (image.toStdString ());
-	waRight->loadImage (image.toStdString ());
-	waLeft->loadSL(leftSL.toStdString());
-	waRight->loadSL(rightSL.toStdString());
-	waRight->addRandomSL();*/
       waLeft->setReadOnly(true);
       waRight->setReadOnly(true);
       waLeft->repaint();

+ 3 - 3
csl/Experiment.hpp

@@ -21,7 +21,9 @@ private:
   const int spaceInBetween = 20;
   const int time = 100;
   const int maxProgressBar = 100;
+  const QString *suffix_IA = new QString("_algo");
   int screenWidth, screenHeight;
+  char algo_side;
 
   QMenu *fileMenu;
 
@@ -39,8 +41,8 @@ private:
   QStringList *filenames;
   QStringList *filenames_json;
   int openedImage;
-  QString *suffix_IA = new QString("_algo");
   QString *suffix;
+  QStringList *choice;
 
   void createActions ();
   void createMenus ();
@@ -50,8 +52,6 @@ private slots:
   void open ();
   void leftImage();
   void rightImage();
-  // void progressBarValueChanged(int value);
-  // void ticTimer();
   
 public:
   Experiment ();

BIN
officialTestDirectory/img01.jpg


+ 1 - 0
officialTestDirectory/img01_algo.json

@@ -0,0 +1 @@
+{"lines": [[[213.8477730119137, 0.0], [800.0, 511.8941407599615]], [[131.549539170507, 526.0], [407.5864055299539, 0.0]], [[0.0, 425.071259469697], [800.0, 442.0068655303031]]]}

BIN
officialTestDirectory/img02.jpg


+ 1 - 0
officialTestDirectory/img02_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 679.8369013323934], [2858.0, 490.4210623423443]], [[0.0, 1005.8400000000001], [1796.4571428571428, 0.0]], [[1063.6306818181818, 0.0], [2858.0, 830.9309210526317]]]}

BIN
officialTestDirectory/img03.jpg


+ 1 - 0
officialTestDirectory/img03_algo.json

@@ -0,0 +1 @@
+{"lines": [[[594.9910298583885, 0.0], [626.137051215179, 1500.0]], [[0.0, 195.47069823931076], [1125.0, 1421.576320275452]]]}

BIN
officialTestDirectory/img04.jpg


+ 1 - 0
officialTestDirectory/img04_algo.json

@@ -0,0 +1 @@
+{"lines": [[[36.705417051384075, 668.0], [317.8942956811409, 0.0]], [[0.0, 409.57529979966705], [540.0, 215.4590101768647]]]}

BIN
officialTestDirectory/img05.jpg


+ 1 - 0
officialTestDirectory/img05_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 471.15994536961483], [450.0, 151.6272126793054]], [[44.282808416407626, 0.0], [450.0, 536.1862976001888]], [[0.0, 465.4093215811966], [450.0, 499.3302617521367]]]}

BIN
officialTestDirectory/img06.jpg


+ 1 - 0
officialTestDirectory/img06_algo.json

@@ -0,0 +1 @@
+{"lines": [[[17.118454744954306, 1893.0], [1894.0, 714.2326270614549]], [[958.3228260869563, 1893.0], [1894.0, 100.56562499999927]], [[0.0, 1738.992346903097], [1894.0, 1685.4487504995004]]]}

BIN
officialTestDirectory/img07.jpg


+ 1 - 0
officialTestDirectory/img07_algo.json

@@ -0,0 +1 @@
+{"lines": [[[341.3426088340558, 1024.0], [429.3895947815535, 0.0]], [[0.0, 81.5071593989661], [698.0, 577.4797931841931]]]}

BIN
officialTestDirectory/img08.jpg


+ 1 - 0
officialTestDirectory/img08_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 643.0071192232957], [1280.0, 659.6988426209015]], [[0.0, 887.3711018711019], [1280.0, 204.81808731808724]], [[0.0, 152.53076923076924], [1280.0, 1002.0692307692308]]]}

BIN
officialTestDirectory/img09.jpg


+ 1 - 0
officialTestDirectory/img09_algo.json

@@ -0,0 +1 @@
+{"lines": [[[9.38541666666697, 504.0], [795.0, 261.7054054054054]], [[0.0, 498.6704779411765], [795.0, 472.79106617647057]], [[0.0, 63.090789473684225], [711.69580078125, 504.0]]]}

BIN
officialTestDirectory/img10.jpg


+ 1 - 0
officialTestDirectory/img10_algo.json

@@ -0,0 +1 @@
+{"lines": [[[40.94010204134467, 0.0], [825.6246202155223, 566.0]]]}

BIN
officialTestDirectory/img11.jpg


+ 1 - 0
officialTestDirectory/img11_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 50.047659643701934], [1000.0, 339.72935823985034]], [[25.187978840435562, 627.0], [651.9030709852107, 0.0]], [[0.0, 204.4875], [896.8750000000001, 0.0]], [[209.8129734848485, 0.0], [519.4720643939394, 627.0]], [[0.0, 90.93939243583142], [943.9700739390782, 627.0]]]}

BIN
officialTestDirectory/img12.jpg


+ 1 - 0
officialTestDirectory/img12_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 1301.0302073125588], [2048.0, 181.55225546274687]], [[0.0, 1213.9697747720788], [2048.0, 1244.2336884313843]], [[37.317700340212554, 0.0], [1977.517279362473, 1348.0]]]}

BIN
officialTestDirectory/img13.jpg


+ 1 - 0
officialTestDirectory/img13_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 86.4630946490397], [2000.0, 211.78375633779325]]]}

BIN
officialTestDirectory/img14.jpg


+ 1 - 0
officialTestDirectory/img14_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 719.032926997688], [1620.0, 536.1015247893761]]]}

BIN
officialTestDirectory/img15.jpg


+ 1 - 0
officialTestDirectory/img15_algo.json

@@ -0,0 +1 @@
+{"lines": [[[215.01562499999997, 0.0], [990.0, 481.3487068965516]]]}

BIN
officialTestDirectory/img16.jpg


+ 1 - 0
officialTestDirectory/img16_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 286.42083333333335], [543.188519021739, 742.0]], [[0.0, 282.48070175438596], [990.0, 685.4995372045746]], [[0.0, 716.8688419117647], [733.6339285714286, 0.0]]]}

BIN
officialTestDirectory/img17.jpg


+ 1 - 0
officialTestDirectory/img17_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 216.06534090909093], [990.0, 570.2017045454545]], [[0.0, 690.3772385491797], [990.0, 173.4589805443095]], [[0.0, 720.0328947368422], [990.0, 563.8223684210526]]]}

BIN
officialTestDirectory/img18.jpg


+ 1 - 0
officialTestDirectory/img18_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 258.1541666666667], [990.0, 381.8208333333333]], [[151.9903846153846, 0.0], [862.7596153846154, 742.0]]]}

BIN
officialTestDirectory/img19.jpg


+ 1 - 0
officialTestDirectory/img19_algo.json

@@ -0,0 +1 @@
+{"lines": [[[0.0, 335.2728051852759], [990.0, 487.20170242816926]], [[56.92499999999973, 661.0], [990.0, 367.92426470588236]]]}