Ejemplo n.º 1
0
 FileSystemModel::FileSystemModel(QObject* parent)
     : QAbstractItemModel(parent)
 {
     connect(this, SIGNAL(updateModel()), SLOT(onUpdateModel()));
     m_startTime = 0;
 }
IntelligentSecurity::IntelligentSecurity(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::IntelligentSecurity)
{
    ui->setupUi(this);

#ifdef __linux__
    struct stat st = {0};

    if (stat(INSTALL_PATH.toStdString().c_str(), &st) == -1) {
        mkdir(INSTALL_PATH.toStdString().c_str(), 0744);
    }

    st = {0};

    if (stat(QString(INSTALL_PATH+QString("/data")).toStdString().c_str(),&st) == -1){
         mkdir(QString(INSTALL_PATH+QString("/data")).toStdString().c_str(),0744);
}
#else

#endif


    /*************************************************/
    /***** CREATING MENU FOR APP INDICATOR ***********/
    a_updateModel = new QAction(tr("&Update"),this);
    connect(a_updateModel, SIGNAL(triggered()), this, SLOT(onUpdateModel()));

    a_showConfiguration = new QAction(tr("&Configure"), this);
    connect(a_showConfiguration, SIGNAL(triggered()), this, SLOT(onShowConfiguration()));

    a_showAccessAttempts = new QAction(tr("&Show access attempts"), this);
    connect(a_showAccessAttempts, SIGNAL(triggered()), this, SLOT(onShowAccessAttempts()));

    a_showhideRecognizerWindows = new QAction(tr("&Show recognizer window"),this);
    connect(a_showhideRecognizerWindows, SIGNAL(triggered()), this, SLOT(onShowHideRecognizerWindows()));

    a_help = new QAction(tr("&Help"), this);
    connect(a_help, SIGNAL(triggered()), this, SLOT(onHelp()));

    a_quit = new QAction(tr("&Quit"), this);
    connect(a_quit, SIGNAL(triggered()), this, SLOT(onQuit()));


    trayIconMenu = new QMenu(this);
    trayIconMenu->addAction(a_updateModel);
    trayIconMenu->addAction(a_showConfiguration);
    trayIconMenu->addAction(a_showAccessAttempts);
    trayIconMenu->addAction(a_showhideRecognizerWindows);
    trayIconMenu->addAction(a_help);
    trayIconMenu->addAction(a_quit);

    trayIcon = new QSystemTrayIcon(QIcon(DEFAULT_PATH("IS_Indicator.png")), this);
    trayIcon->setContextMenu(trayIconMenu);
    trayIcon->show();
    /*************************************************/
    /*************************************************/

    faceRecognizer = new FaceRecognizer();
    faceRecognizer->Init();
    faceRecognizer->OpenVideoCapture(CV_CAP_ANY);

    QFile check(USER_PATH("IntelligentSecurity.cvs"));
    if(!check.open(QIODevice::ReadOnly | QIODevice::Text)) {
       this->onShowHideRecognizerWindows();
       faceRecognizer->showWindows();
       faceRecognizer->Train(1);
       faceRecognizer->SaveModel(USER_PATH("IntelligentSecurity.cvs"));
       cvDestroyAllWindows();
    } else {
        faceRecognizer->LoadModel(USER_PATH("IntelligentSecurity.cvs"));
    }


    if(!this->readConfiguration()) {
        string msg = "Now enter your details for customization and press OK.";
        NotificationManager::showNotification("Setting up", msg.c_str(),"/usr/share/icons/HighContrast/256x256/status/dialog-information.png");
        this->show();
        pVoice.Speak(msg);

    } else {
        timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(runFaceRecognizer()));
        timer->start(10);
    }

    pVoice.Init();
    workstation_locked = false;
    faceRecognizer->hideWindows();
}