//Function executed at each frame
bool segmentationEvaluationModule::run() {
    if(firstTime)
    {
        firstTime = false;
        QByteArray string8bit = this->RoiFileName.toLocal8Bit();
#ifdef __OPENCV3__
        this->RoiPixelLevel = cv::imread(string8bit.data(), cv::IMREAD_GRAYSCALE );
#else
        this->RoiPixelLevel = cv::imread(string8bit.data(), CV_LOAD_IMAGE_GRAYSCALE );
#endif
    }

    if(m_data->postedBestParameters) { //If the best parameters are posted, the job is done
        if(m_setROI) {
            QImage roi, scaledImg;
            ImageTransforms::ImageROI(*m_data->fgImage, roi, m_dx, m_dy, m_w, m_h);
            scaledImg = roi.scaledToWidth(m_wscale, Qt::SmoothTransformation);
            QImage im = ImageTransforms::toGrayscale(scaledImg);
            ImageTransforms::binarize(im);
            getCurrentResults(&im);
        } else
            getCurrentResults(m_data->fgImage);
        return true;
    }

    if(m_data->cycleActivated && m_data->firstOfCycle) { //Store previous data and init cycle and
        NN++;
        if(!first) { //Store previous data
            writeToLog();
            m_data->bestParametersSet = bestParameters;
        }
        previousParameters = m_data->tunedParametersSet;
        if(m_data->tuningEnded) {
            pauseApp();
            m_data->postedBestParameters = true;
        }
        first = false;
        mean_blob = N = mTP = mTN = mFP = mFN = sdTP = sdTN = sdFP = sdFN = 0;
        accTP = accTN = accFP = accFN = 0;
    }


    if(    m_data->fgImage == NULL || m_data->fgImage->isNull()
        || m_data->groundtruthImage == NULL || m_data->groundtruthImage->isNull())
        return true;

    if(m_setROI) {
        QImage roi, scaledImg;
        ImageTransforms::ImageROI(*m_data->fgImage, roi, m_dx, m_dy, m_w, m_h);
        scaledImg = roi.scaledToWidth(m_wscale, Qt::SmoothTransformation);
        QImage im = ImageTransforms::toGrayscale(scaledImg);
        ImageTransforms::binarize(im);
        getCurrentResults(&im);
    } else
        getCurrentResults(m_data->fgImage);

    //Store stats
    accTP += TP; accTN += TN; accFP += FP; accFN += FN;
    N++; //number of frames in the cycle

    mean_blob = MathFunctions::incrementalMean(mean_blob, m_data->blobs.size(), N);
    mTP = MathFunctions::incrementalMean(mTP, TP, N);
    sdTP = MathFunctions::incrementalSigma(mTP, sdTP, TP, N);
    mTN = MathFunctions::incrementalMean(mTN, TN, N);
    sdTN = MathFunctions::incrementalSigma(mTN, sdTN, TN, N);
    mFP = MathFunctions::incrementalMean(mFP, FP, N);
    sdFP = MathFunctions::incrementalSigma(mFP, sdFP, FP, N);
    mFN = MathFunctions::incrementalMean(mFN, FN, N);
    sdFN = MathFunctions::incrementalSigma(mFN, sdFN, FN, N);


    return true;
}
Пример #2
0
QX::QX(QWidget *parent, Qt::WFlags f)
        : QWidget(parent)
{
    Q_UNUSED(f);

    BuildMenu();
    favouritesAction->setChecked(true);

    lineEdit = new QLineEdit("xterm", this);

    bOk = new QPushButton(this);
    bOk->setMinimumWidth(100);
    bOk->setText("Run");
    connect(bOk, SIGNAL(clicked()), this, SLOT(okClicked()));

    lw = new QListWidget(this);
    connect(lw, SIGNAL(clicked(QModelIndex)), this, SLOT(listClicked()));

    lAppname = new QLabel(this);
    bResume = new QPushButton(this);
    bTerminate = new QPushButton(this);
    lAppname->setVisible(false);
    lAppname->setAlignment(Qt::AlignCenter);
    bResume->setVisible(false);
    bTerminate->setVisible(false);
    connect(bResume, SIGNAL(clicked()), this, SLOT(resumeClicked()));
    connect(bTerminate, SIGNAL(clicked()), this, SLOT(terminateClicked()));

    //------------------------------------------

    grid=new QGridLayout(this);
    grid->addWidget(lineEdit,0,0);
    grid->addWidget(bOk,0,1);
    grid->addWidget(lw,1,0,1,2);
    grid->addWidget(lAppname,2,0,1,2);
    grid->addWidget(bResume,3,0,1,2);
    grid->addWidget(bTerminate,4,0,1,2);

    LoadFavourites();
    scanner = new DesktopScanner();
    FillApps(favouritesAction->isChecked());

    //==========================================

    appRunScr = new AppRunningScreen();
    connect(appRunScr, SIGNAL(deactivated()), this, SLOT(pauseApp()));
    connect(appRunScr, SIGNAL(keyPress(QKeyEvent *)), this, SLOT(keyPress(QKeyEvent *)));
    connect(appRunScr, SIGNAL(keyRelease(QKeyEvent *)), this, SLOT(keyRelease(QKeyEvent *)));

    process = NULL;
    xprocess = NULL;
    rotHelper = new RotateHelper(this, 0);
    wmTimer = new QTimer(this);
    connect(wmTimer, SIGNAL(timeout()), this, SLOT(processWmEvents()));
    screen = QX::ScreenMain;

    if(getenv("DISPLAY") == NULL)
        setenv("DISPLAY", "0:0", true);

#if QTOPIA
    powerConstraint = QtopiaApplication::Disable;

    // Start the "QX" service that handles application switching.
    new QxService(this);
#endif

    showScreen(QX::ScreenMain);
}