diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 00000000..bfa46e76
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,36 @@
+# This is a basic workflow to help you get started with Actions
+
+name: Publish Docker image
+
+# Controls when the action will run. Triggers the workflow on push or pull request
+# events but only for the noetic-devel branch
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ push_to_registry:
+ name: Push Docker image to Docker Hub
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out the repo
+ uses: actions/checkout@v2
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
+ with:
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ - name: Push to Docker Hub
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ tags: jderobot/detection-metrics:noetic
+ context: DetectionMetrics/Dockerfile/
+ file: DetectionMetrics/Dockerfile/Dockerfile
diff --git a/.gitignore b/.gitignore
index 73d0fc3f..9ad8053f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,4 @@
-.vscode
+.clang_complete
-.mypy_cache
-__pycache__
-
-.venv
-dist
-poetry.lock
-
-local/*
\ No newline at end of file
+# Py byte files
+*.py[cod]
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..2a23ee56
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,99 @@
+language: cpp
+
+os:
+ - linux
+ - osx
+
+sudo: required
+dist: xenial
+
+compiler:
+ - gcc
+ - clang
+
+cache:
+ pip: true
+ directories:
+ - $HOME/opencv/
+ - $HOME/darknet/
+
+matrix:
+ include:
+ - env: TO_TEST=WITH_ROS_AND_ICE
+
+addons:
+ apt:
+ sources:
+ - sourceline: "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main"
+ key_url: "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x421C365BD9FF1F717815A3895523BAEEB01FA116"
+ - sourceline: "deb http://zeroc.com/download/Ice/3.6/ubuntu16.04 stable main"
+ key_url: "http://keyserver.ubuntu.com/pks/lookup?search=0x5E6DA83306132997&fingerprint=on&hash=on&op=get"
+ packages:
+ - rapidjson-dev
+ - libssl-dev
+ - libboost-dev
+ - libboost-filesystem-dev
+ - libboost-system-dev
+ - libboost-program-options-dev
+ - libgoogle-glog-dev
+ - libyaml-cpp-dev
+ - qt5-default
+ - libqt5svg5-dev
+ - libqt5opengl5-dev
+ - ros-kinetic-roscpp
+ - ros-kinetic-cv-bridge
+ - ros-kinetic-image-transport
+ - zeroc-ice-all-runtime
+ - zeroc-ice-all-dev
+ - doxygen
+ - doxygen-doc
+ - doxygen-latex
+ - doxygen-gui
+ - graphviz
+
+ homebrew:
+ update: true
+ brewfile: true
+
+before_install:
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/qt/bin:$PATH" ; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://www.python.org/ftp/python/2.7.15/python-2.7.15-macosx10.6.pkg ; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo installer -pkg python-2.7.15-macosx10.6.pkg -target / ; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" ; fi
+ - if [[ ( "$TRAVIS_OS_NAME" == "linux" ) && ( "$TO_TEST" == "WITH_ROS_AND_ICE" ) ]]; then source /opt/ros/kinetic/setup.bash ; fi
+ - sudo pip install numpy
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash -x install_opencv.sh ; fi
+ - ./install_darknet.sh
+
+before_script:
+ - cd DetectionMetrics
+ - mkdir build
+ - cd build
+ - cmake ..
+
+script: make -j2
+
+after_success:
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then travis_wait bash ../package.sh ; fi # To run the script in the same shell so as to setup environment variables
+ - ls -lh out/* # Assuming you have some files in out/ that you would like to upload
+ - wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
+ - travis_wait bash upload.sh out/*
+ - cd $TRAVIS_BUILD_DIR && rm -rf DetectionMetrics/build
+ - wget https://jderobot.org/resources/assets/jderobot.png
+ - doxygen
+ - echo "" > html/.nojekyll
+
+deploy:
+ provider: pages
+ skip-cleanup: true
+ local_dir: $TRAVIS_BUILD_DIR/html
+ github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
+ on:
+ branch: master
+ condition: ( "$TO_TEST" == "WITH_ROS_AND_ICE" ) # Publish only in the 4th job
+
+branches:
+ except:
+ - # Do not build tags that we create when we upload to GitHub Releases
+ - /^(?i:continuous)$/
+ - gh-pages
diff --git a/Brewfile b/Brewfile
new file mode 100644
index 00000000..6914f7d2
--- /dev/null
+++ b/Brewfile
@@ -0,0 +1,11 @@
+tap "homebrew/bundle"
+brew "boost"
+brew "boost-python"
+brew "cmake"
+brew "gcc"
+brew "glog"
+brew "libyaml"
+brew "qt"
+brew "rapidjson"
+brew "opencv"
+brew "yaml-cpp"
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e2c0b8ec..4c048180 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,7 +2,7 @@
Thanks for your interest on contributing!
-This file contains a set of rules to contributing to the project and the
+This file contains a set of rules to contributing to the project and the
rest of the projects developed by JdeRobot.
If you have any doubt about how to contribute contact one of the maintainers
of the project. They will be pleased to tell you how you can contribute with your
@@ -19,7 +19,7 @@ Please report any unacceptable behavior to any of [the maintainers](#i-have-a-qu
## Prerequisites before contributing
-In order to contribute to JdeRobot projects, please read carefully the project README.md/webpage (if available) before
+In order to contribute to JdeRobot projects, please read carefully the project README.md/webpage (if available) before
starting contributing to understand the purpose of the project and where you can contribute.
@@ -40,24 +40,22 @@ The two following points are different depending on the permissions you have to
write a good description of the changes made and refer to the issue solved to make things easier to the maintainers. Include any additional resource that would be interesting (references, screenshots...). Link the PR with the issue
* **Testing and merging pull requests**
-Your pull request will be automatically tested by Travis CI. If any jobs have failed, you should fix them.
+Your pull request will be automatically tested by Travis CI. If any jobs have failed, you should fix them.
To rerun the automatic builds just push changes to your branch on GitHub. No need to close that pull request and open a new one!
Once all the builders are "green", one of DetectionMetrics's developers will review your code. Reviewer could ask you to modify your pull request.
Please provide timely response for reviewers (within weeks, not months), otherwise you submission could be postponed or even rejected.
-
+
* **[If you have write permission] Don't accept your own pull requests:** Wait for a project maintainer to accept the changes you made. They will probably comment the pull request with some feedback and will consider if it can be merge to the master branch.
Be proactive and kind!
## I have a question
If you have any question related to how to contribute to the project or anything related to the organization,
-you can contact the main project maintainers sending them an email. Indicate the project you are talking about in the
+you can contact the main project maintainers sending them an email. Indicate the project you are talking about in the
subject of the email, please.
Emails:
-
-
diff --git a/DetectionMetrics/CMakeLists.txt b/DetectionMetrics/CMakeLists.txt
new file mode 100644
index 00000000..1da7f017
--- /dev/null
+++ b/DetectionMetrics/CMakeLists.txt
@@ -0,0 +1,75 @@
+ cmake_minimum_required(VERSION 2.8)
+
+project(samplerGenerator C CXX)
+
+
+#check compiller
+
+include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+
+message ("-- version: ${CMAKE_CXX_COMPILER_VERSION}")
+if(COMPILER_SUPPORTS_CXX11)
+ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++11)
+ MESSAGE("-- C++11 support enabled")
+else()
+ message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
+endif()
+
+IF (NOT CMAKE_BUILD_TYPE)
+ MESSAGE("-- SETTING BUILD TYPE TO RELEASE")
+ SET(CMAKE_BUILD_TYPE RELEASE)
+ENDIF()
+
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fPIC")
+set(CMAKE_MACOSX_RPATH 1)
+
+#automated opencv
+include(FindPkgConfig)
+
+## FIND_PACKAGE(JdeRobot REQUIRED)
+
+ include(Deps/glog/CMakeLists.txt)
+ include(Deps/ice/CMakeLists.txt)
+ include(Deps/numpy/CMakeLists.txt)
+ include(Deps/yaml-cpp/CMakeLists.txt)
+ include(Deps/ros/CMakeLists.txt)
+ include(Deps/opencv/CMakeLists.txt)
+ include(Deps/qt/CMakeLists.txt)
+
+FIND_PACKAGE(Boost REQUIRED program_options filesystem)
+
+set(DetectionMetrics_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/DetectionMetricsLib)
+SET( INTERFACES_CPP_DIR ${CMAKE_CURRENT_BINARY_DIR}/libs/interfaces/cpp/jderobot ${CMAKE_CURRENT_BINARY_DIR}/libs/interfaces/cpp)
+
+if(ZeroCIce_FOUND)
+ add_definitions(-DICE)
+endif()
+if(roscpp_FOUND)
+ add_definitions(-DJDERROS)
+endif()
+if(OpenCV_FOUND)
+ SET(ENABLE_DNN_CAFFE ON)
+ add_definitions(-DENABLE_DNN_CAFFE)
+endif(OpenCV_FOUND)
+
+ add_subdirectory(libs)
+ if (QT_FOUND)
+ add_subdirectory(DetectionMetricsLib)
+ add_subdirectory(DatasetEvaluationApp)
+ endif(QT_FOUND)
+ add_subdirectory(SampleGenerationApp)
+ add_subdirectory(Tools)
+
+if(roscpp_FOUND)
+ add_subdirectory(DetectionMetricsROS)
+endif()
+ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ClassMappingHierarchy.xml
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/ClassMappingHierarchy.xml
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Tools)
+
+ IF (BUILD_TEST)
+ add_subdirectory(test)
+ENDIF()
diff --git a/DetectionMetrics/ClassMappingHierarchy.xml b/DetectionMetrics/ClassMappingHierarchy.xml
new file mode 100644
index 00000000..74627644
--- /dev/null
+++ b/DetectionMetrics/ClassMappingHierarchy.xml
@@ -0,0 +1,99 @@
+
+
+
+ flying vehicle
+
+
+ airplane
+
+
+
+ plane
+
+
+
+ aircraft
+
+
+
+ aeroplane
+
+
+
+
+
+ table
+
+
+ dining table
+
+
+
+ diningtable
+
+
+
+
+
+
+ plant
+
+
+ pottedplant
+
+
+ potted plant
+
+
+
+
+
+ appliance
+
+
+ tv
+
+
+ tvmonitor
+
+
+ tv monitor
+
+
+ television
+
+
+
+
+ vehicle
+
+
+ motorbike
+
+
+ motorcycle
+
+
+ bike
+
+
+ motor bike
+
+
+ motor cycle
+
+
+
+
+ furniture
+
+
+ sofa
+
+
+ couch
+
+
+
+
+
diff --git a/DetectionMetrics/DatasetEvaluationApp/CMakeLists.txt b/DetectionMetrics/DatasetEvaluationApp/CMakeLists.txt
new file mode 100644
index 00000000..34ffcf64
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/CMakeLists.txt
@@ -0,0 +1,54 @@
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set (SOURCES main.cpp
+ mainwindow
+ gui/Appcfg
+ gui/appconfig
+ gui/ListViewConfig
+ gui/TabHandler.cpp gui/TabHandler.h
+ SamplerGeneratorHandler/Converter
+ SamplerGeneratorHandler/SamplerGenerationHandler
+ gui/Utils
+ SamplerGeneratorHandler/Detector
+ SamplerGeneratorHandler/Evaluator
+ SamplerGeneratorHandler/Deployer
+ SamplerGeneratorHandler/Viewer
+ # gui/pop_up
+ )
+
+
+include_directories(
+ ${OpenCV_INCLUDE_DIRS}
+ ${config_INCLUDE_DIRS}
+ ${comm_INCLUDE_DIRS}
+ ${utils_INCLUDE_DIRS}
+ ${ros_INCLUDE_DIRS}
+ ${PYTHON_INCLUDE_DIRS}
+ ${INTERFACES_CPP_DIR}
+ ${jderobottypes_INCLUDE_DIRS}
+ ${GLOG_INCLUDE_DIRS}
+ ${Boost_INCLUDE_DIR}
+ ${QT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_LIST_DIR}
+ ${DetectionMetrics_INCLUDE_DIR}
+)
+
+
+add_executable(DatasetEvaluationApp ${SOURCES})
+
+
+TARGET_LINK_LIBRARIES(DatasetEvaluationApp
+ DetectionMetrics
+ ${OpenCV_LIBRARIES}
+ ${JderobotInterfaces_LIBRARIES}
+ ${EXTRA_LIBS}
+ ${Boost_LIBRARIES}
+ ${QT_LIBRARIES}
+ ${PYTHON_LIBRARIES}
+ ${GLOG_LIBRARIES}
+ ${PYTHON_LIBRARIES}
+ ssl
+ crypto
+ )
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Converter.cpp b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Converter.cpp
new file mode 100644
index 00000000..704fae91
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Converter.cpp
@@ -0,0 +1,91 @@
+//
+// Created by frivas on 19/02/17.
+//
+
+#include
+#include
+#include "Converter.h"
+#include "SamplerGenerationHandler.h"
+#include
+void SampleGeneratorHandler::Converter::process(QListView *datasetList, QListView *namesList, QListView *readerImpList,
+ QListView *filterClasses, QListView *writerImpList, QListView* writerNamesList, bool useWriterNames,
+ const std::string& datasetPath, const std::string& namesPath, const std::string &outputPath,
+ bool splitActive, double splitRatio,bool writeImages) {
+
+
+ GenericDatasetReaderPtr reader = SamplerGenerationHandler::createDatasetReaderPtr(datasetList, namesList,
+ readerImpList, filterClasses,
+ datasetPath, namesPath, writeImages); // Images Required for dataset if and
+ // only if write images is true
+
+
+ if (!reader)
+ return;
+
+
+ std::vector writerImp;
+ Utils::getListViewContent(writerImpList,writerImp,"");
+ std::vector writerNames;
+
+ if (useWriterNames) {
+ if (! Utils::getListViewContent(writerNamesList,writerNames,namesPath+"/")){
+ LOG(WARNING)<<"Select the dataset names related to the Output dataset, or unchechk mapping if you want a custom names file to be generated";
+ return;
+ }
+}
+
+
+ if (splitActive){
+ DatasetReaderPtr readerTest(new DatasetReader(writeImages));
+ DatasetReaderPtr readerTrain(new DatasetReader(writeImages));
+
+ std::string testPath = outputPath + "/test";
+ std::string trainPath = outputPath + "/train";
+
+ int ratio=int(splitRatio*10);
+
+ Sample sample;
+ auto readerPtr = reader->getReader();
+ int counter=0;
+ while (readerPtr->getNextSample(sample)){
+ if (counter addSample(sample);
+ }
+ else{
+ readerTest->addSample(sample);
+ }
+ counter++;
+ counter= counter % 10;
+ }
+
+ LOG(INFO) << "Train: " << std::endl;
+ readerTrain->printDatasetStats();
+ LOG(INFO) << "Test: " << std::endl;
+ readerTest->printDatasetStats();
+
+ if (useWriterNames) {
+ GenericDatasetWriterPtr writerTest( new GenericDatasetWriter(testPath,readerTest,writerImp[0],writerNames[0]));
+ GenericDatasetWriterPtr writerTrain( new GenericDatasetWriter(trainPath,readerTrain,writerImp[0], writerNames[0]));
+ writerTest->getWriter()->process(writeImages);
+ writerTrain->getWriter()->process(writeImages);
+
+ } else {
+ GenericDatasetWriterPtr writerTest( new GenericDatasetWriter(testPath,readerTest,writerImp[0]));
+ GenericDatasetWriterPtr writerTrain( new GenericDatasetWriter(trainPath,readerTrain,writerImp[0]));
+ writerTest->getWriter()->process(writeImages);
+ writerTrain->getWriter()->process(writeImages);
+ }
+ }
+ else{
+ auto readerPtr = reader->getReader();
+ if (useWriterNames) {
+ GenericDatasetWriterPtr writer( new GenericDatasetWriter(outputPath,readerPtr,writerImp[0], writerNames[0]));
+
+ writer->getWriter()->process(writeImages);
+ } else {
+ GenericDatasetWriterPtr writer( new GenericDatasetWriter(outputPath,readerPtr,writerImp[0]));
+
+ writer->getWriter()->process(writeImages);
+ }
+ }
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Converter.h b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Converter.h
new file mode 100644
index 00000000..dde3d94e
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Converter.h
@@ -0,0 +1,20 @@
+//
+// Created by frivas on 19/02/17.
+//
+
+#ifndef SAMPLERGENERATOR_CONVERTER_H
+#define SAMPLERGENERATOR_CONVERTER_H
+
+#include
+
+namespace SampleGeneratorHandler {
+ class Converter {
+ public:
+ static void process(QListView* datasetList,QListView* namesList,QListView* readerImpList, QListView* filterClasses, QListView* writerImpList,
+ QListView* writerNamesList, bool useWriterNames, const std::string& datasetPath, const std::string& namesPath, const std::string& outputPath, bool splitActive, double splitRatio, bool writeImages);
+ };
+
+}
+
+
+#endif //SAMPLERGENERATOR_CONVERTER_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Deployer.cpp b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Deployer.cpp
new file mode 100644
index 00000000..1ecf1d66
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Deployer.cpp
@@ -0,0 +1,99 @@
+//
+// Created by frivas on 27/03/17.
+//
+
+#include
+#include
+#include
+#include
+#include
+#include "Deployer.h"
+#include "SamplerGenerationHandler.h"
+#include "gui/Appcfg.hpp"
+
+void
+SampleGeneratorHandler::Deployer::process(QListView *deployImpList, QListView *weightsList, QListView *netConfigList,
+ QListView *inferencerImpList, QListView *inferencerNamesList,
+ bool* stopButton, double* confidence_threshold, QGroupBox* deployer_params, QGroupBox* camera_params, QGroupBox* inferencer_params, const std::string &weightsPath, const std::string &cfgPath,
+ const std::string &inferencerNamesPath, const std::string &inputInfo, const std::string &outputFolder,bool labelling) {
+
+ GenericLiveReaderPtr reader;
+
+ try {
+
+ reader = SamplerGenerationHandler::createLiveReaderPtr( inferencerNamesList,deployImpList, deployer_params,
+ camera_params, inputInfo,inferencerNamesPath);
+
+ } catch(const std::invalid_argument& ex) {
+ LOG(WARNING)<< "Error Creating Generic Live Reader\nError Message: " << ex.what();
+ return;
+
+ }
+
+ std::vector weights;
+ if (! Utils::getListViewContent(weightsList,weights,weightsPath+ "/")){
+ LOG(WARNING)<<"Select the weightsList";
+ return;
+ }
+ std::vector netConfiguration;
+ if (! Utils::getListViewContent(netConfigList,netConfiguration,cfgPath+ "/")){
+ LOG(WARNING)<<"Select the netConfiguration";
+ return;
+ }
+
+ std::vector inferencerImp;
+ if (! Utils::getListViewContent(inferencerImpList,inferencerImp,"")){
+ LOG(WARNING)<<"Select the inferencer type";
+ return;
+ }
+
+ std::vector inferencerNames;
+ if (! Utils::getListViewContent(inferencerNamesList,inferencerNames,inferencerNamesPath + "/")){
+ LOG(WARNING)<<"Select the class names";
+ return;
+ }
+
+
+ std::map* inferencerParamsMap = new std::map();
+ try {
+ if(! Utils::getInferencerParamsContent(inferencer_params, *inferencerParamsMap)) {
+ inferencerParamsMap = NULL;
+ }
+
+ }
+ catch(std::exception& ex) {
+ LOG(WARNING)<< ex.what();
+ return;
+ }
+
+ if (!outputFolder.empty()) {
+
+ auto boostPath= boost::filesystem::path(outputFolder);
+ if (boost::filesystem::exists(boostPath)){
+ boost::filesystem::directory_iterator end_itr;
+ boost::filesystem::directory_iterator itr(boostPath);
+ for (; itr != end_itr; ++itr)
+ {
+ if (boost::filesystem::is_regular_file(itr->path()) && (itr->path().extension()==".png" || itr->path().extension()==".json") ) {
+ break;
+ }
+ }
+ if (itr != end_itr)
+ QMessageBox::warning(deployer_params, QObject::tr("Output Directory isn't Empty"), QObject::tr("Output Director contains png or json files which might be overwritten"));
+ }
+
+ }
+ DatasetReaderPtr data_reader=reader->getReader();
+ data_reader->SetClassNamesFile(&inferencerNames[0]);
+ LOG(INFO) << "netConfigList : " << netConfiguration[0] << " ; weights : " << weights[0] << " ; inferencerNames : " << inferencerNames[0] << " ; inferencerImp : " << inferencerImp[0] << std::endl;
+ GenericInferencerPtr inferencer(new GenericInferencer(netConfiguration[0],weights[0],inferencerNames[0],inferencerImp[0], inferencerParamsMap));
+ if(labelling){
+ Labelling massInferencer(data_reader,inferencer->getInferencer(),outputFolder, stopButton, confidence_threshold, true);
+ massInferencer.process(false);
+ }
+ else{
+ MassInferencer massInferencer(data_reader,inferencer->getInferencer(),outputFolder, stopButton, confidence_threshold, true);
+ massInferencer.process(false);
+ }
+
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Deployer.h b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Deployer.h
new file mode 100644
index 00000000..1717a384
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Deployer.h
@@ -0,0 +1,21 @@
+//
+// Created by frivas on 27/03/17.
+//
+
+#ifndef SAMPLERGENERATOR_DEPLOYER_H
+#define SAMPLERGENERATOR_DEPLOYER_H
+
+#include
+#include
+#include
+
+namespace SampleGeneratorHandler {
+ class Deployer {
+ public:
+ static void process(QListView *deployImpList,QListView* weightsList, QListView* netConfigList, QListView* inferencerImpList, QListView* inferencerNamesList,
+ bool* stopButton, double* confidence_threshold, QGroupBox* deployer_params, QGroupBox* camera_params, QGroupBox* inferencer_params, const std::string& weightsPath, const std::string& cfgPath,
+ const std::string& inferencerNamesPath,const std::string& inputInfo,const std::string& outputFolder,bool labelling);
+ };
+}
+
+#endif //SAMPLERGENERATOR_DEPLOYER_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Detector.cpp b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Detector.cpp
new file mode 100644
index 00000000..a815f20f
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Detector.cpp
@@ -0,0 +1,79 @@
+//
+// Created by frivas on 20/02/17.
+//
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "Detector.h"
+#include "SamplerGenerationHandler.h"
+
+void SampleGeneratorHandler::Detector::process(QListView* datasetList,QListView* namesList,QListView* readerImpList, const std::string& datasetPath,
+ QListView* weightsList, QListView* netConfigList, QListView* inferencerImpList, QListView* inferencerNamesList,
+ QGroupBox* inferencer_params, const std::string& weightsPath, const std::string& cfgPath, const std::string& outputPath,
+ const std::string& namesPath, bool useDepth, bool singleEvaluation) {
+
+ GenericDatasetReaderPtr reader = SamplerGenerationHandler::createDatasetReaderPtr(datasetList, namesList,
+ readerImpList, NULL, datasetPath,
+ namesPath, true);
+
+ if (!reader)
+ return;
+ std::vector weights;
+ if (! Utils::getListViewContent(weightsList,weights,weightsPath+ "/")){
+ LOG(WARNING)<<"Select the weightsList";
+ return;
+ }
+
+ std::vector netConfiguration;
+ if (! Utils::getListViewContent(netConfigList,netConfiguration,cfgPath+ "/")){
+ LOG(WARNING)<<"Select the netConfiguration";
+ return;
+ }
+
+ std::vector inferencerImp;
+ if (! Utils::getListViewContent(inferencerImpList,inferencerImp,"")){
+ LOG(WARNING)<<"Select the inferencer type";
+ return;
+ }
+
+ std::vector inferencerNames;
+ if (! Utils::getListViewContent(inferencerNamesList,inferencerNames,namesPath + "/")){
+ LOG(WARNING)<<"Select the inferencer type";
+ return;
+ }
+
+ std::map* inferencerParamsMap = new std::map();
+ try {
+ if(! Utils::getInferencerParamsContent(inferencer_params, *inferencerParamsMap)) {
+ inferencerParamsMap = NULL;
+ }
+
+ } catch(std::exception& ex) {
+ LOG(WARNING)<< ex.what();
+ return;
+ }
+
+ std::vector writerImp;
+ Utils::getListViewContent(readerImpList,writerImp,"");
+
+
+ std::vector writerNames;
+ if (! Utils::getListViewContent(namesList,writerNames,namesPath+"/")){
+ LOG(WARNING)<<"Select the dataset names related to the Output dataset, or unchechk mapping if you want a custom names file to be generated";
+ return;
+ }
+
+ DatasetReaderPtr readerDetection (new DatasetReader(true));
+
+ GenericInferencerPtr inferencer(new GenericInferencer(netConfiguration[0],weights[0],inferencerNames[0],inferencerImp[0], inferencerParamsMap));
+ MassInferencer massInferencer(reader->getReader(),inferencer->getInferencer(),std::string(), true);
+ massInferencer.process(useDepth, readerDetection);
+
+ GenericDatasetWriterPtr writer(new GenericDatasetWriter(outputPath,readerDetection,writerImp[0], writerNames[0]));
+
+ writer->getWriter()->process(false);
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Detector.h b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Detector.h
new file mode 100644
index 00000000..8891d33c
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Detector.h
@@ -0,0 +1,25 @@
+//
+// Created by frivas on 20/02/17.
+//
+
+#ifndef SAMPLERGENERATOR_DETECTOR_H
+#define SAMPLERGENERATOR_DETECTOR_H
+
+
+#include
+
+
+namespace SampleGeneratorHandler {
+
+ class Detector {
+ public:
+ static void process(QListView* datasetList,QListView* namesList,QListView* readerImpList, const std::string& datasetPath,
+ QListView* weightsList, QListView* netConfigList, QListView* inferencerImpList, QListView* inferencerNamesList,
+ QGroupBox* inferencer_params, const std::string& weightsPath, const std::string& cfgPath, const std::string& outputPath,
+ const std::string& namesPath, bool useDepth, bool singleEvaluation
+ );
+ };
+
+}
+
+#endif //SAMPLERGENERATOR_DETECTOR_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Evaluator.cpp b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Evaluator.cpp
new file mode 100644
index 00000000..a209b852
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Evaluator.cpp
@@ -0,0 +1,61 @@
+//
+// Created by frivas on 20/02/17.
+//
+
+#include
+#include
+#include "Evaluator.h"
+#include "SamplerGenerationHandler.h"
+
+void
+SampleGeneratorHandler::Evaluator::process(QListView *datasetListGT, QListView *namesListGT, QListView *readerImpListGT,
+ QListView *datasetListDetect, QListView *namesListDetect,
+ QListView *readerImpListDetect, QListView *filterClasses,
+ const std::string &datasetPath, const std::string &namesGTPath,
+ const std::string &inferencesPath, const std::string &namesPath,
+ bool overWriterPersonClasses,bool enableMixEvaluation,
+ bool isIouTypeBbox) {
+
+ GenericDatasetReaderPtr readerGT = SamplerGenerationHandler::createDatasetReaderPtr(datasetListGT, namesListGT,
+ readerImpListGT, filterClasses,
+ datasetPath,
+ namesPath, false);
+ GenericDatasetReaderPtr readerDetection = SamplerGenerationHandler::createDatasetReaderPtr(datasetListDetect,
+ namesListDetect,
+ readerImpListDetect,
+ filterClasses,
+ inferencesPath,
+ namesPath, false);
+
+
+ if (!readerGT || !readerDetection)
+ return;
+
+
+ DetectionsEvaluatorPtr evaluator(new DetectionsEvaluator(readerGT->getReader(),readerDetection->getReader()));
+
+
+ if (overWriterPersonClasses){
+ readerGT->getReader()->overWriteClasses("person-falling","person");
+ readerGT->getReader()->overWriteClasses("person-fall","person");
+ readerGT->getReader()->printDatasetStats();
+ }
+
+ if(enableMixEvaluation) {
+ evaluator->addValidMixClass("person", "person-falling");
+ evaluator->addValidMixClass("person", "person-fall");
+ }
+ evaluator->evaluate(isIouTypeBbox);
+ evaluator->accumulateResults();
+
+
+
+ std::string mywriterFile("evaluation_results.csv");
+
+ StatsWriter writer(readerGT->getReader(), mywriterFile);
+
+ writer.writeInferencerResults("Detection Dataset", evaluator);
+
+ writer.saveFile();
+
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Evaluator.h b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Evaluator.h
new file mode 100644
index 00000000..ae2ccce7
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Evaluator.h
@@ -0,0 +1,25 @@
+//
+// Created by frivas on 20/02/17.
+//
+
+#ifndef SAMPLERGENERATOR_EVALUATOR_H
+#define SAMPLERGENERATOR_EVALUATOR_H
+
+
+#include
+
+
+namespace SampleGeneratorHandler {
+ class Evaluator {
+ public:
+ static void process(QListView* datasetListGT,QListView* namesListGT,QListView* readerImpListGT,
+ QListView* datasetListDetect,QListView* namesListDetect,QListView* readerImpListDetect,
+ QListView* filterClasses, const std::string& datasetPath, const std::string& namesGTPath,
+ const std::string& inferencesPath, const std::string& namesPath,bool overWriterPersonClasses,
+ bool enableMixEvaluation, bool isIouTypeBbox
+ );
+ };
+
+}
+
+#endif //SAMPLERGENERATOR_EVALUATOR_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Label.cpp b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Label.cpp
new file mode 100644
index 00000000..65712bb6
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Label.cpp
@@ -0,0 +1,89 @@
+//
+// Created by frivas on 27/03/17.
+//
+
+#include
+#include
+#include
+#include
+#include "Deployer.h"
+#include "SamplerGenerationHandler.h"
+#include "gui/Appcfg.hpp"
+
+void
+SampleGeneratorHandler::Deployer::process(QListView *deployImpList, QListView *weightsList, QListView *netConfigList,
+ QListView *inferencerImpList, QListView *inferencerNamesList,
+ bool* stopButton, double* confidence_threshold, QGroupBox* deployer_params, QGroupBox* camera_params, QGroupBox* inferencer_params, const std::string &weightsPath, const std::string &cfgPath,
+ const std::string &inferencerNamesPath, const std::string &inputInfo, const std::string &outputFolder) {
+
+ GenericLiveReaderPtr reader;
+
+ try {
+
+ reader = SamplerGenerationHandler::createLiveReaderPtr( inferencerNamesList,
+ deployImpList, deployer_params, camera_params, inputInfo,inferencerNamesPath);
+
+ } catch(const std::invalid_argument& ex) {
+ LOG(WARNING)<< "Error Creating Generic Live Reader\nError Message: " << ex.what();
+ return;
+
+ }
+
+ std::vector weights;
+ if (! Utils::getListViewContent(weightsList,weights,weightsPath+ "/")){
+ LOG(WARNING)<<"Select the weightsList";
+ return;
+ }
+
+ std::vector netConfiguration;
+ if (! Utils::getListViewContent(netConfigList,netConfiguration,cfgPath+ "/")){
+ LOG(WARNING)<<"Select the netConfiguration";
+ return;
+ }
+
+ std::vector inferencerImp;
+ if (! Utils::getListViewContent(inferencerImpList,inferencerImp,"")){
+ LOG(WARNING)<<"Select the inferencer type";
+ return;
+ }
+
+ std::vector inferencerNames;
+ if (! Utils::getListViewContent(inferencerNamesList,inferencerNames,inferencerNamesPath + "/")){
+ LOG(WARNING)<<"Select the inferencer type";
+ return;
+ }
+
+ std::map* inferencerParamsMap = new std::map();
+ try {
+ if(! Utils::getInferencerParamsContent(inferencer_params, *inferencerParamsMap)) {
+ inferencerParamsMap = NULL;
+ }
+
+ } catch(std::exception& ex) {
+ LOG(WARNING)<< ex.what();
+ return;
+ }
+
+ if (!outputFolder.empty()) {
+
+ auto boostPath= boost::filesystem::path(outputFolder);
+ if (boost::filesystem::exists(boostPath)){
+ boost::filesystem::directory_iterator end_itr;
+ boost::filesystem::directory_iterator itr(boostPath);
+ for (; itr != end_itr; ++itr)
+ {
+ if (boost::filesystem::is_regular_file(itr->path()) && (itr->path().extension()==".png" || itr->path().extension()==".json") ) {
+ break;
+ }
+ }
+ if (itr != end_itr)
+ QMessageBox::warning(deployer_params, QObject::tr("Output Directory isn't Empty"), QObject::tr("Output Director contains png or json files which might be overwritten"));
+ }
+
+ }
+ DatasetReaderPtr data_reader=reader->getReader();
+ data_reader->SetClassNamesFile(&inferencerNames[0]);
+ GenericInferencerPtr inferencer(new GenericInferencer(netConfiguration[0],weights[0],inferencerNames[0],inferencerImp[0], inferencerParamsMap));
+ MassInferencer massInferencer(data_reader,inferencer->getInferencer(),outputFolder, stopButton, confidence_threshold, true);
+ massInferencer.process(false);
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Label.h b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Label.h
new file mode 100644
index 00000000..7ec0bdbb
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Label.h
@@ -0,0 +1,21 @@
+//
+// Created by frivas on 27/03/17.
+//
+
+#ifndef SAMPLERGENERATOR_DEPLOYER_H
+#define SAMPLERGENERATOR_DEPLOYER_H
+
+#include
+#include
+#include
+
+namespace SampleGeneratorHandler {
+ class Deployer {
+ public:
+ static void process(QListView *deployImpList,QListView* weightsList, QListView* netConfigList, QListView* inferencerImpList, QListView* inferencerNamesList,
+ bool* stopButton, double* confidence_threshold, QGroupBox* deployer_params, QGroupBox* camera_params, QGroupBox* inferencer_params, const std::string& weightsPath, const std::string& cfgPath,
+ const std::string& inferencerNamesPath,const std::string& inputInfo,const std::string& outputFolder);
+ };
+}
+
+#endif //SAMPLERGENERATOR_DEPLOYER_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/SamplerGenerationHandler.cpp b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/SamplerGenerationHandler.cpp
new file mode 100644
index 00000000..8afa1a0a
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/SamplerGenerationHandler.cpp
@@ -0,0 +1,102 @@
+//
+// Created by frivas on 19/02/17.
+//
+
+#include
+#include
+#include "SamplerGenerationHandler.h"
+
+GenericDatasetReaderPtr SampleGeneratorHandler::SamplerGenerationHandler::createDatasetReaderPtr(
+ const QListView *datasetList,
+ const QListView *namesList,
+ const QListView *readerImpList,
+ const QListView *filterClasses,
+ const std::string &datasetPath, const std::string &namesPath, const bool imagesRequired) {
+ std::vector datasetsToShow;
+
+ if (! Utils::getListViewContent(datasetList,datasetsToShow,datasetPath + "/")){
+ LOG(WARNING)<<"Select at least one dataset to read";
+ return GenericDatasetReaderPtr();
+ }
+
+ std::vector names;
+ if (! Utils::getListViewContent(namesList,names,namesPath+"/")){
+ LOG(WARNING)<<"Select the dataset names related to the input dataset";
+ return GenericDatasetReaderPtr();
+ }
+
+ std::vector readerImplementation;
+ if (! Utils::getListViewContent(readerImpList,readerImplementation,"")){
+ LOG(WARNING)<<"Select the reader implementation";
+ return GenericDatasetReaderPtr();
+ }
+
+ std::vector classesToFilter;
+ if (filterClasses)
+ Utils::getListViewContent(filterClasses,classesToFilter,"");
+
+
+ GenericDatasetReaderPtr reader;
+ if (datasetsToShow.size()>1) {
+ reader = GenericDatasetReaderPtr(
+ new GenericDatasetReader(datasetsToShow,names[0], readerImplementation[0], imagesRequired));
+ }
+ else {
+ reader = GenericDatasetReaderPtr(
+ new GenericDatasetReader(datasetsToShow[0],names[0], readerImplementation[0], imagesRequired));
+ }
+
+
+ if (classesToFilter.size()){
+ reader->getReader()->filterSamplesByID(classesToFilter);
+ }
+
+ return reader;
+}
+
+GenericLiveReaderPtr SampleGeneratorHandler::SamplerGenerationHandler::createLiveReaderPtr(const QListView *namesList,
+ const QListView *readerImpList,
+ const QGroupBox *deployer_params,
+ const QGroupBox *camera_params,
+ const std::string &infoPath,
+ const std::string &namesPath) {
+
+ std::vector names;
+ if (! Utils::getListViewContent(namesList,names,namesPath+"/")){
+ LOG(WARNING)<<"Select the dataset names related to the input dataset";
+ return GenericLiveReaderPtr();
+ }
+
+ std::vector readerImplementation;
+ if (! Utils::getListViewContent(readerImpList,readerImplementation,"")){
+ LOG(WARNING)<<"Select the reader implementation";
+ return GenericLiveReaderPtr();
+ }
+
+ int cameraID;
+ if(! Utils::getCameraParamsContent(camera_params, cameraID)) {
+ LOG(WARNING)<<"Invalid Camera ID passed";
+ return GenericLiveReaderPtr();
+ }
+
+ std::map* deployer_params_map = new std::map();
+
+ try {
+
+ if(! Utils::getDeployerParamsContent(deployer_params, *deployer_params_map)) {
+ deployer_params_map = NULL;
+ }
+
+ } catch(std::exception& ex) {
+ LOG(WARNING)<< ex.what();
+ return GenericLiveReaderPtr();
+ }
+
+ GenericLiveReaderPtr reader;
+
+ reader = GenericLiveReaderPtr(
+ new GenericLiveReader(infoPath, names[0], readerImplementation[0], deployer_params_map, cameraID));
+
+
+ return reader;
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/SamplerGenerationHandler.h b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/SamplerGenerationHandler.h
new file mode 100644
index 00000000..1d97761f
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/SamplerGenerationHandler.h
@@ -0,0 +1,35 @@
+//
+// Created by frivas on 19/02/17.
+//
+
+#ifndef SAMPLERGENERATOR_SAMPLERGENERATIONHANDLER_H
+#define SAMPLERGENERATOR_SAMPLERGENERATIONHANDLER_H
+
+#include
+#include
+#include
+#include
+#include
+
+namespace SampleGeneratorHandler {
+
+ class SamplerGenerationHandler {
+ public:
+ static GenericDatasetReaderPtr createDatasetReaderPtr(const QListView *datasetList, const QListView *namesList,
+ const QListView *readerImpList,
+ const QListView *filterClasses,
+ const std::string &datasetPath,
+ const std::string &namesPath,
+ const bool imagesRequired);
+
+ static GenericLiveReaderPtr createLiveReaderPtr(const QListView *namesList,
+ const QListView *readerImpList,
+ const QGroupBox *deployer_params,
+ const QGroupBox *camera_params,
+ const std::string &infoPath,
+ const std::string &namesPath);
+ };
+
+}
+
+#endif //SAMPLERGENERATOR_SAMPLERGENERATIONHANDLER_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Viewer.cpp b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Viewer.cpp
new file mode 100644
index 00000000..96dd608b
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Viewer.cpp
@@ -0,0 +1,44 @@
+//
+// Created by frivas on 18/02/17.
+//
+
+#include
+#include
+#include
+#include "Viewer.h"
+#include "SamplerGenerationHandler.h"
+#include
+#include
+
+namespace SampleGeneratorHandler {
+
+ void Viewer::process(QListView* datasetList,QListView* namesList,QListView* readerImpList,QListView* filterClasses, bool showDepth, const std::string& datasetPath, const std::string& namesPath) {
+
+ try {
+ GenericDatasetReaderPtr reader = SamplerGenerationHandler::createDatasetReaderPtr(datasetList, namesList,
+ readerImpList, filterClasses,
+ datasetPath, namesPath, true);
+ if (!reader){
+ return;
+ }
+
+ std::string windowName="viewer";
+ Sample sample;
+
+ std::vector readerImplementation;
+ Utils::getListViewContent(readerImpList,readerImplementation,"");
+
+
+ while (reader->getReader()->getNextSample(sample)){
+ LOG(INFO) << "number of elements: " << sample.getRectRegions()->getRegions().size() << std::endl;
+
+ if (!sample.show(readerImplementation[0], windowName, 0, showDepth))
+ break;
+
+ }
+ } catch (std::invalid_argument e) {
+ LOG(INFO) << "Invalid argument!" << std::endl;
+ }
+ }
+
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Viewer.h b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Viewer.h
new file mode 100644
index 00000000..df8cb737
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/SamplerGeneratorHandler/Viewer.h
@@ -0,0 +1,18 @@
+//
+// Created by frivas on 18/02/17.
+//
+
+#ifndef SAMPLERGENERATOR_VIEWER_H
+#define SAMPLERGENERATOR_VIEWER_H
+
+#include
+
+namespace SampleGeneratorHandler {
+ class Viewer {
+ public:
+ static void process(QListView* datasetList,QListView* namesList,QListView* readerImpList, QListView* filterClasses, bool showDepth, const std::string& datasetPath, const std::string& namesPath);
+ };
+
+}
+
+#endif //SAMPLERGENERATOR_VIEWER_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/gui/Appcfg.cpp b/DetectionMetrics/DatasetEvaluationApp/gui/Appcfg.cpp
new file mode 100644
index 00000000..3b6da5dc
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/gui/Appcfg.cpp
@@ -0,0 +1,21 @@
+#include "Appcfg.hpp"
+#include
+
+// Classic constructor
+Appcfg::Appcfg(int argc, char **argv){
+ this->a = new QApplication(argc,argv);
+ this->w = new appconfig();
+ Appcfg::exec();
+}
+
+// Starts the GUI
+void Appcfg::exec(){
+ this->w->show();
+ this->a->exec();
+}
+
+/* Returns the YAML node which has information regarding the required parameters
+ to start the suite */
+YAML::Node Appcfg::get_node(){
+ return this->w->return_node();
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/gui/Appcfg.hpp b/DetectionMetrics/DatasetEvaluationApp/gui/Appcfg.hpp
new file mode 100644
index 00000000..66e0a9e2
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/gui/Appcfg.hpp
@@ -0,0 +1,30 @@
+#ifndef APP_CONFIG
+#define APP_CONFIG
+
+// This is just for initialization of things required to start GUI
+// For more refer to "appconfig" class
+#include "appconfig.h"
+#include
+
+class Appcfg {
+public:
+ // constructor
+ Appcfg(int argc , char **argv);
+ // To start the GUI
+ void exec();
+ // Yaml node that stores all the required parameters to start DetectionMetrics
+ YAML::Node get_node();
+
+private:
+ QApplication *a;
+ appconfig *w;
+};
+
+#endif
+// int main(int argc, char *argv[])
+// {
+// QApplication a(argc, argv);
+// MainWindow w;
+// w.show();
+// return a.exec();
+// }
diff --git a/DetectionMetrics/DatasetEvaluationApp/gui/ListViewConfig.cpp b/DetectionMetrics/DatasetEvaluationApp/gui/ListViewConfig.cpp
new file mode 100644
index 00000000..9d313723
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/gui/ListViewConfig.cpp
@@ -0,0 +1,197 @@
+//
+// Created by frivas on 18/02/17.
+//
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "ListViewConfig.h"
+
+bool ListViewConfig::configureDatasetInput(QMainWindow* mainWindow, QListView *qlistView, const std::string &path,bool multipleSelection) {
+
+ /*
+ Check if the paths provided in the config file exists ,else output the
+ path that does not exist.
+ */
+ if (!boost::filesystem::exists(boost::filesystem::path(path))){
+ LOG(WARNING)<< "path: " + path + " does not exist";
+ return false;
+ }
+
+ QStringListModel *model;
+ model = new QStringListModel(mainWindow);
+ QStringList List;
+
+ std::vector filesID;
+
+ getPathContentDatasetInput(path,filesID);
+
+ std::vector filteredFilesID;
+ for (int i = 0; i < filesID.size(); i = i + 1) {
+ std::size_t found_json = filesID[i].find(".json");
+ std::size_t found_txt = filesID[i].find(".txt");
+ std::size_t found_xml = filesID[i].find(".xml");
+ std::size_t found_csv = filesID[i].find(".csv");
+ std::size_t found_file = filesID[i].find(".");
+ if (found_json != std::string::npos || found_txt != std::string::npos || found_xml != std::string::npos || found_csv != std::string::npos || found_file == std::string::npos) {
+ filteredFilesID.push_back(filesID[i]);
+ }
+ }
+ filesID = filteredFilesID;
+
+ std::sort(filesID.begin(),filesID.end());
+
+ for (auto it = filesID.begin(), end = filesID.end(); it != end; ++it){
+ std::string::size_type i = it->find(path);
+
+ if (i != std::string::npos)
+ it->erase(i, path.length());
+
+ List << QString::fromStdString(*it);
+ }
+
+ model->setStringList(List);
+
+ qlistView->setModel(model);
+ if (multipleSelection)
+ qlistView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ return true;
+}
+
+void ListViewConfig::getPathContentDatasetInput(const std::string &path, std::vector& content) {
+
+ boost::filesystem::directory_iterator end_itr;
+ boost::filesystem::path boostPath(path);
+ std::size_t path_last;
+
+ for (boost::filesystem::directory_iterator itr(boostPath); itr!=end_itr; ++itr) {
+ std::vector possibleContent;
+ if (boost::filesystem::is_directory(*itr)){
+ //check if yolo (should contain a *.txt
+ bool isOwnFormat=false;
+ bool takeParent=true;
+ boost::filesystem::path boostPath2(itr->path());
+ for (boost::filesystem::directory_iterator itr2(boostPath2); itr2!=end_itr; ++itr2) {
+ if (itr2->path().string().find(".txt") != std::string::npos) {
+ possibleContent.push_back(itr2->path().string());
+ } else if(itr2->path().string().find(".json") != std::string::npos) {
+ possibleContent.push_back(itr2->path().string());
+ } else if(itr2->path().string().find(".csv") != std::string::npos) {
+ possibleContent.push_back(itr2->path().string());
+ } else if(itr2->path().string().find(".xml") != std::string::npos) {
+ //Only Take Parent and break this will prevent displaying multiple xml files
+ break;
+ //possibleContent.push_back(itr2->path().string());
+ } else if ((itr2->path().string().find("png") != std::string::npos) || (itr2->path().string().find("json") != std::string::npos)) {
+ isOwnFormat=true;
+ takeParent=false;
+ break;
+ } else {
+ takeParent=false;
+ }
+ }
+ if (takeParent) {
+ possibleContent.push_back(itr->path().string());
+ }
+
+ if (possibleContent.size() != 0) {
+ for (auto it = possibleContent.begin(), end = possibleContent.end(); it != end; ++it){
+ content.push_back(*it);
+ }
+ } else if (isOwnFormat) {
+ content.push_back(itr->path().string());
+ } else{
+ getPathContentDatasetInput(itr->path().string(),content);
+ }
+ }
+ }
+}
+
+bool ListViewConfig::configureInputByFile(QMainWindow *mainWindow, QListView *qlistView, const std::string &path, const std::string &pathIdentifier, bool multipleSelection) {
+ if (!boost::filesystem::exists(boost::filesystem::path(path))){
+ LOG(WARNING) << "path: " + path + " does not exist";
+ return false;
+ }
+
+ QStringListModel *model;
+ model = new QStringListModel(mainWindow);
+ QStringList List;
+ std::vector filesID;
+ getPathContentOnlyFiles(path,filesID);
+
+ // Filter weights files
+ if (pathIdentifier == "weightsPath") {
+ std::vector filteredFilesID;
+ for (int i = 0; i < filesID.size(); i = i + 1) {
+ std::size_t found_pb = filesID[i].find(".pb");
+ std::size_t found_h5 = filesID[i].find(".h5");
+ std::size_t found_pth = filesID[i].find(".pth");
+ std::size_t found_weights = filesID[i].find(".weights");
+ if (found_pb != std::string::npos || found_h5 != std::string::npos || found_pth != std::string::npos || found_weights != std::string::npos) {
+ filteredFilesID.push_back(filesID[i]);
+ }
+ }
+ filesID = filteredFilesID;
+ }
+
+ std::sort(filesID.begin(),filesID.end());
+ for (auto it = filesID.begin(), end = filesID.end(); it != end; ++it){
+ std::string::size_type i = it->find(path);
+
+ if (i != std::string::npos)
+ it->erase(i, path.length());
+
+ List << QString::fromStdString(*it);
+ }
+
+ model->setStringList(List);
+
+ qlistView->setModel(model);
+ if (multipleSelection)
+ qlistView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ return true;
+}
+
+
+/*
+ Get all the files(Only) present in a given PATH.
+*/
+void ListViewConfig::getPathContentOnlyFiles(const std::string &path, std::vector &content) {
+ boost::filesystem::directory_iterator end_itr; // An iterator to iterate through directories.
+ boost::filesystem::path boostPath(path);
+
+ for (boost::filesystem::directory_iterator itr(boostPath); itr!=end_itr; ++itr)
+ {
+ /*
+ Check if the current path is a directory, if yes then recursively call
+ this function until you reach a file.
+ */
+ if (boost::filesystem::is_directory(*itr)) {
+ getPathContentOnlyFiles(itr->path().string(),content);
+ } else {
+ // If not a directory then push the file(path) into "content".
+ content.push_back(itr->path().string());
+ }
+ }
+}
+
+bool ListViewConfig::configureInputByData(QMainWindow *mainWindow, QListView *qlistView, const std::vector& data,bool multipleSelection) {
+ QStringListModel *model;
+ model = new QStringListModel(mainWindow);
+ QStringList List;
+
+ for (auto it = data.begin(), end = data.end(); it != end; ++it){
+ List << QString::fromStdString(*it);
+ }
+
+ model->setStringList(List);
+
+ qlistView->setModel(model);
+ if (multipleSelection)
+ qlistView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ return true;
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/gui/ListViewConfig.h b/DetectionMetrics/DatasetEvaluationApp/gui/ListViewConfig.h
new file mode 100644
index 00000000..17653b7e
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/gui/ListViewConfig.h
@@ -0,0 +1,27 @@
+//
+// Created by frivas on 18/02/17.
+//
+
+#ifndef SAMPLERGENERATOR_LISTVIEWCONFIG_H
+#define SAMPLERGENERATOR_LISTVIEWCONFIG_H
+
+#include
+#include
+#include
+
+
+class ListViewConfig {
+public:
+ static bool configureDatasetInput(QMainWindow* mainWindow, QListView* qlistView, const std::string& path, bool multipleSelection);
+ static bool configureInputByFile(QMainWindow* mainWindow, QListView* qlistView, const std::string& path, const std::string& pathIdentifier, bool multipleSelection);
+ static bool configureInputByData(QMainWindow* mainWindow, QListView* qlistView, const std::vector& data,bool multipleSelection);
+
+
+
+private:
+ static void getPathContentDatasetInput(const std::string& path, std::vector& content);
+ static void getPathContentOnlyFiles(const std::string& path, std::vector& content);
+
+};
+
+#endif //SAMPLERGENERATOR_LISTVIEWCONFIG_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/gui/TabHandler.cpp b/DetectionMetrics/DatasetEvaluationApp/gui/TabHandler.cpp
new file mode 100644
index 00000000..ba7888fa
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/gui/TabHandler.cpp
@@ -0,0 +1,30 @@
+//
+// Created by frivas on 19/02/17.
+//
+
+#include
+#include
+#include "TabHandler.h"
+#include "ListViewConfig.h"
+
+// Contructor function(will be called whenever this object is created).
+TabHandler::TabHandler() {
+ fillContexts();
+}
+
+
+// Add "viewer" && "converter" to "contexts".
+void TabHandler::fillContexts() {
+ this->contexts.push_back("viewer");
+ this->contexts.push_back("converter");
+}
+
+// Get the context of the handler provided index.
+std::string TabHandler::getStringContext(int index) {
+ return this->contexts[index];
+}
+
+// To get all the elements present in the "contexts"
+std::vector TabHandler::getAllContexts() {
+ return this->contexts;
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/gui/TabHandler.h b/DetectionMetrics/DatasetEvaluationApp/gui/TabHandler.h
new file mode 100644
index 00000000..ae00f186
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/gui/TabHandler.h
@@ -0,0 +1,33 @@
+//
+// Created by frivas on 19/02/17.
+//
+
+#ifndef SAMPLERGENERATOR_TABHANDLER_H
+#define SAMPLERGENERATOR_TABHANDLER_H
+
+
+#include
+#include
+#include
+#include
+
+class TabHandler {
+public:
+ // Constructor function.
+ TabHandler();
+ // Get the context provided index.
+ std::string getStringContext(int index);
+ // Get entire an entire vector of elements present in context.
+ std::vector getAllContexts();
+
+private:
+ // A vector of strings to store different elements like "viewer","converter",etc.
+ std::vector contexts;
+ // Fill "contexts" with certain elements.
+ void fillContexts();
+};
+
+
+typedef boost::shared_ptr TabHandlerPtr;
+
+#endif //SAMPLERGENERATOR_TABHANDLER_H
diff --git a/DetectionMetrics/DatasetEvaluationApp/gui/Utils.cpp b/DetectionMetrics/DatasetEvaluationApp/gui/Utils.cpp
new file mode 100644
index 00000000..1fa117b9
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/gui/Utils.cpp
@@ -0,0 +1,92 @@
+//
+// Created by frivas on 19/02/17.
+//
+
+#include "Utils.h"
+#include
+bool Utils::getListViewContent(const QListView *list, std::vector &content, const std::string &prefix) {
+ content.clear();
+
+ if (list->model() == 0) {
+ return false;
+ }
+
+
+ QModelIndexList selectedList =list->selectionModel()->selectedIndexes();
+ for (auto it = selectedList.begin(), end = selectedList.end(); it != end; ++it){
+ content.push_back(prefix + it->data().toString().toStdString());
+ }
+
+ return content.size() != 0;
+}
+
+bool Utils::getDeployerParamsContent(const QGroupBox* deployer_params, std::map& deployer_params_map) {
+ deployer_params_map.clear();
+
+ if (!deployer_params->isEnabled())
+ return false;
+
+
+ QList allLineEdits = deployer_params->findChildren();
+
+ QList::iterator i;
+ for (i = allLineEdits.begin(); i != allLineEdits.end(); ++i) {
+ if ((*i)->text().toStdString().empty())
+ throw std::invalid_argument("Please Enter All the Parameters");
+ }
+
+ deployer_params_map["Server"] = deployer_params->findChild("radioButton_deployer_ros")->isChecked() ? "ROS" : "Ice";
+ deployer_params_map["Proxy"] = deployer_params->findChild("lineEdit_deployer_proxy")->text().toStdString();
+ deployer_params_map["Format"] = deployer_params->findChild("lineEdit_deployer_format")->text().toStdString();
+ deployer_params_map["Topic"] = deployer_params->findChild("lineEdit_deployer_topic")->text().toStdString();
+ deployer_params_map["Name"] = deployer_params->findChild("lineEdit_deployer_name")->text().toStdString();
+
+
+ return true;
+
+}
+
+bool Utils::getInferencerParamsContent(const QGroupBox* inferencer_params, std::map& inferencer_params_map) {
+
+ inferencer_params_map.clear();
+
+ if (!inferencer_params->isEnabled())
+ return false;
+
+ std::string prefix = inferencer_params->objectName().toStdString();
+ size_t pos = prefix.find_first_of("_");
+ prefix = prefix.substr(0, pos);
+
+ QList allLineEdits = inferencer_params->findChildren();
+
+ QList::iterator i;
+ for (i = allLineEdits.begin(); i != allLineEdits.end(); ++i) {
+ if ((*i)->text().toStdString().empty())
+ throw std::invalid_argument("Please Enter All the Parameters");
+ }
+
+
+ //inferencer_params_map["conf_thresh"] = inferencer_params->findChild((prefix + "_lineEdit_confidence_thresh").c_str())->text().toStdString();
+ inferencer_params_map["scaling_factor"] = inferencer_params->findChild((prefix + "_lineEdit_inferencer_scaling_factor").c_str())->text().toStdString();
+ inferencer_params_map["inpWidth"] = inferencer_params->findChild((prefix + "_lineEdit_inferencer_input_width").c_str())->text().toStdString();
+ inferencer_params_map["inpHeight"] = inferencer_params->findChild((prefix + "_lineEdit_inferencer_input_height").c_str())->text().toStdString();
+ inferencer_params_map["mean_sub_blue"] = inferencer_params->findChild((prefix + "_lineEdit_mean_sub_blue").c_str())->text().toStdString();
+ inferencer_params_map["mean_sub_green"] = inferencer_params->findChild((prefix + "_lineEdit_mean_sub_green").c_str())->text().toStdString();
+ inferencer_params_map["mean_sub_red"] = inferencer_params->findChild((prefix + "_lineEdit_mean_sub_red").c_str())->text().toStdString();
+ inferencer_params_map["useRGB"] = inferencer_params->findChild((prefix + "_checkBox_use_rgb").c_str())->isChecked() ? "true" : "false";
+
+ return true;
+
+}
+
+bool Utils::getCameraParamsContent(const QGroupBox* camera_params, int& cameraID) {
+
+ cameraID = camera_params->findChild("deployer_camera_spinBox")->value();
+ LOG(INFO) << cameraID << '\n';
+ if (cameraID < -1) {
+ return false;
+ }
+
+ return true;
+
+}
diff --git a/DetectionMetrics/DatasetEvaluationApp/gui/Utils.h b/DetectionMetrics/DatasetEvaluationApp/gui/Utils.h
new file mode 100644
index 00000000..37b87942
--- /dev/null
+++ b/DetectionMetrics/DatasetEvaluationApp/gui/Utils.h
@@ -0,0 +1,25 @@
+//
+// Created by frivas on 19/02/17.
+//
+
+#ifndef SAMPLERGENERATOR_UTILS_H
+#define SAMPLERGENERATOR_UTILS_H
+
+
+#include
+#include
+#include
+#include
+#include