Esempio n. 1
0
void Clip::load(const QString &fileName, const char* format) {
    QString ffmpegExe = settings->ffmpegExecutable();
    if(ffmpegExe.isEmpty()) {
        return;
    }
    // Get resolution from ffmpeg (so we don't have to ask videoplayer)
    QString command = "\"" + ffmpegExe + "\"" + " -i " + "\"" + fileName + "\"";
    QProcess process;
    process.start(command);
    process.waitForFinished(100);
    QByteArray out = process.readAllStandardError();
    process.close();

    QRegExp expResolution("[0-9]+x[0-9]+");
    QRegExp expWidth("[0-9]+\\B");
    QRegExp expHeight("\\B+[0-9]+$");
    expResolution.indexIn(out);
    QString res = expResolution.cap();
    expWidth.indexIn(res);
    expHeight.indexIn(res);
    QString wt = expWidth.cap();
    QString ht = expHeight.cap();

    path = fileName;
    extension = format;
    srcWidth = wt.toInt();
    srcHeight = ht.toInt();
    grad = 0;
    frame = QRect(0,0,srcWidth, srcHeight);
}
Esempio n. 2
0
   void BackToBackExponential::function1D(double* out, const double* xValues, const size_t nData)const
   {
     /*
       const double& I = getParameter("I");
       const double& a = getParameter("A");
       const double& b = getParameter("B");
       const double& x0 = getParameter("X0");
       const double& s = getParameter("S");
     */
 
     const double I = getParameter(0);
     const double a = getParameter(1);
     const double b = getParameter(2);
     const double x0 = getParameter(3);
     const double s = getParameter(4);
 
     // find the reasonable extent of the peak ~100 fwhm
     double extent = expWidth();
     if ( s > extent ) extent = s;
     extent *= 100;
 
     double s2 = s*s;
     double normFactor = a * b / (a + b) / 2;
     //Needed for IntegratePeaksMD for cylinder profile fitted with b=0
     if (normFactor == 0.0) normFactor = 1.0;
     for (size_t i = 0; i < nData; i++) {
       double diff=xValues[i]-x0;
       if ( fabs(diff) < extent )
        {
         double val = 0.0;
         double arg1 = a/2*(a*s2+2*diff);
         val += exp(  arg1 + gsl_sf_log_erfc((a*s2+diff)/sqrt(2*s2)) ); //prevent overflow
         double arg2 = b/2*(b*s2-2*diff);
         val += exp( arg2 + gsl_sf_log_erfc((b*s2-diff)/sqrt(2*s2)) ); //prevent overflow
         out[i] = I*val*normFactor;
        }
       else
         out[i] = 0.0;
      }
    }