diff --git a/CV-Toolbox.pro b/CV-Toolbox.pro index fb88f35..dbf55b9 100644 --- a/CV-Toolbox.pro +++ b/CV-Toolbox.pro @@ -86,16 +86,15 @@ FORMS += \ pages/thresholding_page.ui +INCLUDEPATH += C:\Users\youss\Documents\libraries\opencv\build\include -INCLUDEPATH += C:\opencv\build\include - -LIBS += C:\opencv\release\bin\libopencv_core470.dll -LIBS += C:\opencv\release\bin\libopencv_highgui470.dll -LIBS += C:\opencv\release\bin\libopencv_imgcodecs470.dll -LIBS += C:\opencv\release\bin\libopencv_imgproc470.dll -LIBS += C:\opencv\release\bin\libopencv_features2d470.dll -LIBS += C:\opencv\release\bin\libopencv_calib3d470.dll -LIBS += C:\opencv\release\bin\libopencv_objdetect470.dll +LIBS += C:\Users\youss\Documents\libraries\opencv\release\bin\libopencv_core470.dll +LIBS += C:\Users\youss\Documents\libraries\opencv\release\bin\libopencv_highgui470.dll +LIBS += C:\Users\youss\Documents\libraries\opencv\release\bin\libopencv_imgcodecs470.dll +LIBS += C:\Users\youss\Documents\libraries\opencv\release\bin\libopencv_imgproc470.dll +LIBS += C:\Users\youss\Documents\libraries\opencv\release\bin\libopencv_features2d470.dll +LIBS += C:\Users\youss\Documents\libraries\opencv\release\bin\libopencv_calib3d470.dll +LIBS += C:\Users\youss\Documents\libraries\opencv\release\bin\libopencv_objdetect470.dll # Default rules for deployment. diff --git a/Plot/plotter.cpp b/Plot/plotter.cpp index 43f541d..776ed4c 100644 --- a/Plot/plotter.cpp +++ b/Plot/plotter.cpp @@ -47,8 +47,60 @@ void plotter::plotROC(QCustomPlot* graph,std::pair,std::vecto graph->addGraph(); plot->setData(FPRs,TPRs); - graph->yAxis->setRange(0,1.5); - graph->xAxis->setRange(0,1.5); + graph->yAxis->setRange(0,1); + graph->xAxis->setRange(0,1); + graph->xAxis->setLabel("False positive Rate"); + graph->yAxis->setLabel("True Positive Rate"); + QCPItemLine *line = new QCPItemLine(graph); + line->start->setCoords(0,0); + line->end->setCoords(1,1); + QPen pen2(Qt::red); + pen2.setStyle(Qt::DashLine); + line->setPen(pen2); + + + graph->replot(); +} + +void plotter::plotAllROC(QCustomPlot *graph, std::vector, std::vector > > ROC, std::unordered_map LabelToPerson) +{ + graph->clearPlottables(); + for(int i = 0; i < ROC.size(); i++){ + QVector FPRs; + for (const auto& value : ROC[i].first) { + FPRs.append(value); + } + + QVector TPRs; + for (const auto& value : ROC[i].second) { + TPRs.append(value); + } + + int red = QRandomGenerator::global()->bounded(256); + int green = QRandomGenerator::global()->bounded(256); + int blue = QRandomGenerator::global()->bounded(256); + + QColor plotColor = QColor(red, green, blue); + + QCPGraph *plot = new QCPGraph(graph->xAxis, graph->yAxis); + QPen pen(plotColor); + plot->setPen(pen); + plot->setData(FPRs,TPRs); + plot->setName(QString::fromStdString(LabelToPerson[i])); +} + + + graph->yAxis->setRange(0,1); + graph->xAxis->setRange(0,1); + graph->xAxis->setLabel("False positive Rate"); + graph->yAxis->setLabel("True Positive Rate"); + QCPItemLine *line = new QCPItemLine(graph); + line->start->setCoords(0,0); + line->end->setCoords(1,1); + QPen pen2(Qt::red); + pen2.setStyle(Qt::DashLine); + line->setPen(pen2); + graph->legend->setVisible(true); graph->replot(); } diff --git a/Plot/plotter.h b/Plot/plotter.h index 1392b1f..793889e 100644 --- a/Plot/plotter.h +++ b/Plot/plotter.h @@ -7,6 +7,7 @@ class plotter public: static void plotHist(QCustomPlot* graph, QVector& data, Qt::GlobalColor color); static void plotROC(QCustomPlot* graph,std::pair,std::vector>ROC); + static void plotAllROC(QCustomPlot* graph,std::vector,std::vector>> ROC, std::unordered_map LabelToPerson); }; #endif // PLOTTER_H diff --git a/pages/page11.cpp b/pages/page11.cpp index 02ebcd7..54b4810 100644 --- a/pages/page11.cpp +++ b/pages/page11.cpp @@ -105,7 +105,9 @@ void page11::readImages(std::string folderPath, cv::Mat& images, std::vectorfirst)); } + comboItems.sort(); ui->comboBox_2->addItems(comboItems); + ui->comboBox_2->addItem("All"); } images.convertTo(images, CV_32F); @@ -213,9 +215,24 @@ void page11::on_testUploadBtn_clicked() void page11::on_comboBox_2_currentIndexChanged(int index) { - if(!testFolderPath.isEmpty()){ - plotter::plotROC(ui->widget,ROC[index]); + if(!testFolderPath.isEmpty() ){ + if(ui->comboBox_2->currentText().toStdString() != "All"){ + std::pair, std::vector> curve = ROC[fr->personToLabelmapper[ui->comboBox_2->currentText().toStdString()]]; + plotter::plotROC(ui->widget,curve); + + double area = 0.0; + int n = curve.first.size(); + + for (int i = 1; i < n; ++i) { + double base = curve.second[i] - curve.second[i - 1]; + double height = (curve.first[i] + curve.first[i - 1]) / 2.0; + area += base * height; + } + ui->aucLabel->setText(QString::fromStdString("AUC = " + std::to_string((1 + area)*100 ) + "%"));} + else { + plotter::plotAllROC(ui->widget, ROC, fr->labelToPersonMapper); + } } // fr->personToLabelmapper } diff --git a/pages/page11.ui b/pages/page11.ui index 50b7a47..2314032 100644 --- a/pages/page11.ui +++ b/pages/page11.ui @@ -85,6 +85,13 @@ + + + + AUC = + + +