Commit be351d6a86d2b0946487169f26406752dcf866b3

Authored by Josh Klontz
1 parent e7b35d97

replacing useGUI flag with getenv("DISPLAY")

openbr/openbr_plugin.cpp
@@ -44,12 +44,6 @@ using namespace cv; @@ -44,12 +44,6 @@ using namespace cv;
44 44
45 Q_DECLARE_METATYPE(QLocalSocket::LocalSocketState) 45 Q_DECLARE_METATYPE(QLocalSocket::LocalSocketState)
46 46
47 -// Some globals used to transfer data to Context::messageHandler so that  
48 -// we can restart the process if we try and fail to create a QApplication.  
49 -static bool creating_qapp = false;  
50 -static int * argc_ptr = NULL;  
51 -static char ** argv_ptr = NULL;  
52 -  
53 /* File - public methods */ 47 /* File - public methods */
54 // Note that the convention for displaying metadata is as follows: 48 // Note that the convention for displaying metadata is as follows:
55 // [] for lists in which argument order does not matter (e.g. [FTO=false, Index=0]), 49 // [] for lists in which argument order does not matter (e.g. [FTO=false, Index=0]),
@@ -901,42 +895,28 @@ bool br::Context::checkSDKPath(const QString &sdkPath) @@ -901,42 +895,28 @@ bool br::Context::checkSDKPath(const QString &sdkPath)
901 // We create our own when the user hasn't 895 // We create our own when the user hasn't
902 static QCoreApplication *application = NULL; 896 static QCoreApplication *application = NULL;
903 897
904 -void br::Context::initialize(int &argc, char *argv[], QString sdkPath, bool use_gui) 898 +void br::Context::initialize(int &argc, char *argv[], QString sdkPath)
905 { 899 {
906 - for (int i=0; i < argc; i ++)  
907 - {  
908 - if (strcmp("-useGui", argv[i]) == 0) {  
909 - const char * val = i+1 < argc ? argv[i+1] : "";  
910 - if (strcmp(val, "false") ==0 || strcmp(val, "0") == 0)  
911 - use_gui = false;  
912 - break;  
913 - }  
914 - }  
915 -  
916 qInstallMessageHandler(messageHandler); 900 qInstallMessageHandler(messageHandler);
917 901
  902 +#ifdef _WIN32
  903 + bool useGui = true;
  904 +#else // not _WIN32
  905 + bool useGui = (getenv("DISPLAY") != NULL);
  906 +#endif // _WIN32
  907 +
918 // We take in argc as a reference due to: 908 // We take in argc as a reference due to:
919 // https://bugreports.qt-project.org/browse/QTBUG-5637 909 // https://bugreports.qt-project.org/browse/QTBUG-5637
920 // QApplication should be initialized before anything else. 910 // QApplication should be initialized before anything else.
921 // Since we can't ensure that it gets deleted last, we never delete it. 911 // Since we can't ensure that it gets deleted last, we never delete it.
922 if (QCoreApplication::instance() == NULL) { 912 if (QCoreApplication::instance() == NULL) {
923 #ifndef BR_EMBEDDED 913 #ifndef BR_EMBEDDED
924 - if (use_gui) {  
925 - // Set up variables to be used in the message handler if this fails.  
926 - // Just so you know, we  
927 - creating_qapp = true;  
928 - argc_ptr = &argc;  
929 - argv_ptr = argv;  
930 -  
931 - application = new QApplication(argc, argv);  
932 - creating_qapp = false;  
933 - }  
934 - else {  
935 - application = new QCoreApplication(argc, argv);  
936 - }  
937 -#else 914 + if (useGui) application = new QApplication(argc, argv);
  915 + else application = new QCoreApplication(argc, argv);
  916 +#else // not BR_EMBEDDED
  917 + useGui = false;
938 application = new QCoreApplication(argc, argv); 918 application = new QCoreApplication(argc, argv);
939 -#endif 919 +#endif // BR_EMBEDDED
940 } 920 }
941 921
942 QCoreApplication::setOrganizationName(COMPANY_NAME); 922 QCoreApplication::setOrganizationName(COMPANY_NAME);
@@ -959,8 +939,7 @@ void br::Context::initialize(int &amp;argc, char *argv[], QString sdkPath, bool use_ @@ -959,8 +939,7 @@ void br::Context::initialize(int &amp;argc, char *argv[], QString sdkPath, bool use_
959 939
960 Globals = new Context(); 940 Globals = new Context();
961 Globals->init(File()); 941 Globals->init(File());
962 - Globals->useGui = use_gui;  
963 - 942 + Globals->useGui = useGui;
964 943
965 Common::seedRNG(); 944 Common::seedRNG();
966 945
@@ -1029,26 +1008,6 @@ void br::Context::messageHandler(QtMsgType type, const QMessageLogContext &amp;conte @@ -1029,26 +1008,6 @@ void br::Context::messageHandler(QtMsgType type, const QMessageLogContext &amp;conte
1029 static QMutex generalLock; 1008 static QMutex generalLock;
1030 QMutexLocker locker(&generalLock); 1009 QMutexLocker locker(&generalLock);
1031 1010
1032 - // If we are trying to create a QApplication, and get a fatal, then restart the process  
1033 - // with useGui set to 0.  
1034 - if (creating_qapp && type == QtFatalMsg)  
1035 - {  
1036 - // re-launch process with useGui = 0  
1037 - std::cout << "Failed to initialize gui, restarting with -useGui 0" << std::endl;  
1038 - QStringList arguments;  
1039 - arguments.append("-useGui");  
1040 - arguments.append("0");  
1041 - for (int i=1; i < *argc_ptr; i++)  
1042 - {  
1043 - arguments.append(argv_ptr[i]);  
1044 - }  
1045 - // QProcess::execute blocks until the other process completes.  
1046 - QProcess::execute(argv_ptr[0], arguments);  
1047 - // have to unlock this for some reason  
1048 - locker.unlock();  
1049 - std::exit(0);  
1050 - }  
1051 -  
1052 QString txt; 1011 QString txt;
1053 if (type == QtDebugMsg) { 1012 if (type == QtDebugMsg) {
1054 if (Globals->quiet) return; 1013 if (Globals->quiet) return;
openbr/openbr_plugin.h
@@ -794,12 +794,11 @@ public: @@ -794,12 +794,11 @@ public:
794 * By default <tt>share/openbr/openbr.bib</tt> will be searched for relative to: 794 * By default <tt>share/openbr/openbr.bib</tt> will be searched for relative to:
795 * -# The working directory 795 * -# The working directory
796 * -# The executable's location 796 * -# The executable's location
797 - * \param use_gui Create a QApplication instead of a QCoreApplication.  
798 * \note Tiggers \em abort() on failure to locate <tt>share/openbr/openbr.bib</tt>. 797 * \note Tiggers \em abort() on failure to locate <tt>share/openbr/openbr.bib</tt>.
799 * \note <a href="http://qt-project.org/">Qt</a> users should instead call this <i>after</i> initializing QApplication. 798 * \note <a href="http://qt-project.org/">Qt</a> users should instead call this <i>after</i> initializing QApplication.
800 * \see finalize 799 * \see finalize
801 */ 800 */
802 - static void initialize(int &argc, char *argv[], QString sdkPath = "", bool use_gui = true); 801 + static void initialize(int &argc, char *argv[], QString sdkPath = "");
803 802
804 /*! 803 /*!
805 * \brief Call \em once at the end of the application to deallocate global variables. 804 * \brief Call \em once at the end of the application to deallocate global variables.
openbr/plugins/process.cpp
@@ -531,8 +531,6 @@ class ProcessWrapperTransform : public TimeVaryingTransform @@ -531,8 +531,6 @@ class ProcessWrapperTransform : public TimeVaryingTransform
531 baseKey = id.toString(); 531 baseKey = id.toString();
532 532
533 QStringList argumentList; 533 QStringList argumentList;
534 - argumentList.append("-useGui");  
535 - argumentList.append("0");  
536 argumentList.append("-algorithm"); 534 argumentList.append("-algorithm");
537 argumentList.append(transform); 535 argumentList.append(transform);
538 if (!Globals->path.isEmpty()) { 536 if (!Globals->path.isEmpty()) {
scripts/evalAgeRegression-PCSO.sh
@@ -4,7 +4,7 @@ if [ ! -f evalAgeRegression-PCSO.sh ]; then @@ -4,7 +4,7 @@ if [ ! -f evalAgeRegression-PCSO.sh ]; then
4 exit 4 exit
5 fi 5 fi
6 6
7 -export BR="../build/app/br/br -useGui 0" 7 +export BR=../build/app/br/br
8 export PCSO_DIR=/user/pripshare/Databases/FaceDatabases/PCSO/PCSO/ 8 export PCSO_DIR=/user/pripshare/Databases/FaceDatabases/PCSO/PCSO/
9 export ageAlg=AgeRegression 9 export ageAlg=AgeRegression
10 10
scripts/evalFaceRecognition-LFW.sh
@@ -20,7 +20,7 @@ if [ ! -e Algorithm_Dataset ]; then @@ -20,7 +20,7 @@ if [ ! -e Algorithm_Dataset ]; then
20 fi 20 fi
21 21
22 # Run the LFW test protocol 22 # Run the LFW test protocol
23 -br -useGui 0 -algorithm $ALGORITHM -path ../data/LFW/img/ -crossValidate 10 -pairwiseCompare ../data/LFW/sigset/test_image_restricted_target.xml ../data/LFW/sigset/test_image_restricted_query.xml ${ALGORITHM}_LFW.mtx -convert Output ${ALGORITHM}_lfw.mtx Algorithm_Dataset/${ALGORITHM}_LFW%1.eval 23 +br -algorithm $ALGORITHM -path ../data/LFW/img/ -crossValidate 10 -pairwiseCompare ../data/LFW/sigset/test_image_restricted_target.xml ../data/LFW/sigset/test_image_restricted_query.xml ${ALGORITHM}_LFW.mtx -convert Output ${ALGORITHM}_lfw.mtx Algorithm_Dataset/${ALGORITHM}_LFW%1.eval
24 24
25 # Plot results 25 # Plot results
26 -br -useGui 0 -plot Algorithm_Dataset/* 'lfw_results.pdf[smooth=Dataset,rocOptions[yLimits=(0,1)]]' 26 +br -plot Algorithm_Dataset/* 'lfw_results.pdf[smooth=Dataset,rocOptions[yLimits=(0,1)]]'
scripts/evalFaceRecognition-MEDS.sh
@@ -20,11 +20,11 @@ if [ ! -e Algorithm_Dataset ]; then @@ -20,11 +20,11 @@ if [ ! -e Algorithm_Dataset ]; then
20 fi 20 fi
21 21
22 if [ ! -e MEDS.mask ]; then 22 if [ ! -e MEDS.mask ]; then
23 - br -useGui 0 -makeMask ../data/MEDS/sigset/MEDS_frontal_target.xml ../data/MEDS/sigset/MEDS_frontal_query.xml MEDS.mask 23 + br -makeMask ../data/MEDS/sigset/MEDS_frontal_target.xml ../data/MEDS/sigset/MEDS_frontal_query.xml MEDS.mask
24 fi 24 fi
25 25
26 # Run Algorithm on MEDS 26 # Run Algorithm on MEDS
27 -br -useGui 0 -algorithm ${ALGORITHM} -path ../data/MEDS/img -compare ../data/MEDS/sigset/MEDS_frontal_target.xml ../data/MEDS/sigset/MEDS_frontal_query.xml ${ALGORITHM}_MEDS.mtx -eval ${ALGORITHM}_MEDS.mtx MEDS.mask Algorithm_Dataset/${ALGORITHM}_MEDS.csv 27 +br -algorithm ${ALGORITHM} -path ../data/MEDS/img -compare ../data/MEDS/sigset/MEDS_frontal_target.xml ../data/MEDS/sigset/MEDS_frontal_query.xml ${ALGORITHM}_MEDS.mtx -eval ${ALGORITHM}_MEDS.mtx MEDS.mask Algorithm_Dataset/${ALGORITHM}_MEDS.csv
28 28
29 # Plot results 29 # Plot results
30 -br -useGui 0 -plot Algorithm_Dataset/*_MEDS.csv MEDS 30 +br -plot Algorithm_Dataset/*_MEDS.csv MEDS
scripts/evalGenderClassification-PCSO.sh
@@ -9,7 +9,7 @@ export ALGORITHM=GenderClassification @@ -9,7 +9,7 @@ export ALGORITHM=GenderClassification
9 export PCSO_DIR=../data/PCSO/img 9 export PCSO_DIR=../data/PCSO/img
10 10
11 # Create a file list by querying the database 11 # Create a file list by querying the database
12 -$BR -useGui 0 -quiet -algorithm Identity -enroll "$PCSO_DIR/PCSO.db[query='SELECT File,Gender,PersonID FROM PCSO', subset=1:8000]" terminal.txt > Input.txt 12 +$BR -quiet -algorithm Identity -enroll "$PCSO_DIR/PCSO.db[query='SELECT File,Gender,PersonID FROM PCSO', subset=1:8000]" terminal.txt > Input.txt
13 13
14 # Enroll the file list and evaluate performance 14 # Enroll the file list and evaluate performance
15 -$BR -useGui 0 -algorithm $ALGORITHM -path $PCSO_DIR -enroll Input.txt Output.txt -evalClassification Output.txt Input.txt Gender  
16 \ No newline at end of file 15 \ No newline at end of file
  16 +$BR -algorithm $ALGORITHM -path $PCSO_DIR -enroll Input.txt Output.txt -evalClassification Output.txt Input.txt Gender
17 \ No newline at end of file 17 \ No newline at end of file
scripts/pedestrianBaselineLBP.sh
@@ -27,8 +27,7 @@ else @@ -27,8 +27,7 @@ else
27 TEST=testSmall.xml 27 TEST=testSmall.xml
28 fi 28 fi
29 29
30 -br -useGui 0 \  
31 - -algorithm "${ALG}" \ 30 +br -algorithm "${ALG}" \
32 -path $INRIA_PATH/img \ 31 -path $INRIA_PATH/img \
33 -train $INRIA_PATH/sigset/train.xml pedModel \ 32 -train $INRIA_PATH/sigset/train.xml pedModel \
34 -enroll $INRIA_PATH/sigset/$TEST pedResults.xml 33 -enroll $INRIA_PATH/sigset/$TEST pedResults.xml
scripts/trainAgeRegression-PCSO.sh
@@ -13,4 +13,4 @@ export ageAlg=AgeRegression @@ -13,4 +13,4 @@ export ageAlg=AgeRegression
13 13
14 export PCSO_DIR=/user/pripshare/Databases/FaceDatabases/PCSO/PCSO/ 14 export PCSO_DIR=/user/pripshare/Databases/FaceDatabases/PCSO/PCSO/
15 15
16 -$BR -useGui 0 -algorithm $ageAlg -path $PCSO_DIR/Images -train "$PCSO_DIR/PCSO.db[query='SELECT File,Age,PersonID FROM PCSO WHERE Age >= 17 AND AGE <= 68', subset=0:200]" ../share/openbr/models/algorithms/AgeRegression 16 +$BR -algorithm $ageAlg -path $PCSO_DIR/Images -train "$PCSO_DIR/PCSO.db[query='SELECT File,Age,PersonID FROM PCSO WHERE Age >= 17 AND AGE <= 68', subset=0:200]" ../share/openbr/models/algorithms/AgeRegression
scripts/trainFaceRecognition-PCSO.sh
@@ -14,7 +14,5 @@ export BR=../build/app/br/br @@ -14,7 +14,5 @@ export BR=../build/app/br/br
14 14
15 export PCSO_DIR=/user/pripshare/Databases/FaceDatabases/PCSO/PCSO/ 15 export PCSO_DIR=/user/pripshare/Databases/FaceDatabases/PCSO/PCSO/
16 16
17 -  
18 -  
19 -$BR -useGui 0 -algorithm FaceRecognition -path "$PCSO_DIR/Images/" -train "$PCSO_DIR/PCSO.db[query='SELECT File,PersonID as Label,PersonID FROM PCSO', subset=0:5:6000]" ../share/openbr/models/algorithms/FaceRecognition 17 +$BR -algorithm FaceRecognition -path "$PCSO_DIR/Images/" -train "$PCSO_DIR/PCSO.db[query='SELECT File,PersonID as Label,PersonID FROM PCSO', subset=0:5:6000]" ../share/openbr/models/algorithms/FaceRecognition
20 18
scripts/trainGenderClassification-PCSO.sh
@@ -13,4 +13,4 @@ export genderAlg=GenderClassification @@ -13,4 +13,4 @@ export genderAlg=GenderClassification
13 13
14 export PCSO_DIR=/user/pripshare/Databases/FaceDatabases/PCSO/PCSO/ 14 export PCSO_DIR=/user/pripshare/Databases/FaceDatabases/PCSO/PCSO/
15 15
16 -$BR -useGui 0 -algorithm $genderAlg -path $PCSO_DIR/Images -train "$PCSO_DIR/PCSO.db[query='SELECT File,Gender,PersonID FROM PCSO', subset=0:8000]" ../share/openbr/models/algorithms/GenderClassification 16 +$BR -algorithm $genderAlg -path $PCSO_DIR/Images -train "$PCSO_DIR/PCSO.db[query='SELECT File,Gender,PersonID FROM PCSO', subset=0:8000]" ../share/openbr/models/algorithms/GenderClassification