Example #1
0
bool EyeTrackerCalibration::calibrate(const CalibrationData & calibrationData)
{
    if(calibrationData.size() == 0)
        return false;

    size_t totalCalibrationPointsNum = 0;

    for(const auto & p: calibrationData)
        totalCalibrationPointsNum += p.eyePositions.size();

    if(totalCalibrationPointsNum < 10)
        return false;

    std::vector<cv::Point2d> eyePositions;
    std::vector<cv::Point2d> screenPositions;

    if(m_dataPreprocessingType == NoPreprocessing)
    {
        eyePositions.resize(totalCalibrationPointsNum);
        screenPositions.resize(totalCalibrationPointsNum);

        size_t i = 0;
        for(const auto & p: calibrationData)
        {
            const auto screenPos = p.screenPoint;
            for(const auto & eyePos: p.eyePositions)
            {
                eyePositions[i] = eyePos;
                screenPositions[i] = screenPos;
                ++i;
            }
        }
    }
    else if(m_dataPreprocessingType == MeanPoint)
    {
        eyePositions.resize(calibrationData.size());
        screenPositions.resize(calibrationData.size());

        size_t i = 0;
        for(const auto & p: calibrationData)
        {
            double mean_x = 0.0;
            double mean_y = 0.0;
            for(const auto & eyePos: p.eyePositions)
            {
                mean_x += eyePos.x;
                mean_y += eyePos.y;
            }
            mean_x /= p.eyePositions.size();
            mean_y /= p.eyePositions.size();

            eyePositions[i] = cv::Point2d(mean_x, mean_y);
            screenPositions[i] = p.screenPoint;
            i++;
        }
    }

    return estimateParameters(eyePositions, screenPositions);
}
Example #2
0
  bool MZTrafoModel::train( const CalibrationData& cd, MODELTYPE md, bool use_RANSAC, double rt_left /*= -std::numeric_limits<double>::max()*/, double rt_right /*= std::numeric_limits<double>::max() */ )
  {
    std::vector<double> obs_mz;
    std::vector<double> theo_mz;
    std::vector<double> weights;
    const CalibrationData* p_cd;
    CalibrationData cdm;
    Size i, ie; // CalibrationData's start-to-end interval
    if (cd.getNrOfGroups() > 0) // we have lock mass traces
    { // this is extra work, since we need to collect peak groups and compute the median
      cdm = cd.median(rt_left, rt_right);
      p_cd = &cdm;
      i = 0;
      ie = cdm.size();
    }
    else
    {
      i = std::distance(cd.begin(), lower_bound(cd.begin(), cd.end(), rt_left, RichPeak2D::RTLess()));
      ie = std::distance(cd.begin(), upper_bound(cd.begin(), cd.end(), rt_right, RichPeak2D::RTLess()));
      p_cd = &cd;
    }
    for (Size j = i; j != ie; ++j)
    {
      obs_mz.push_back(p_cd->getError(j)); // could be ppm or [Th], depending on cd::use_ppm_
      theo_mz.push_back(p_cd->getRefMZ(j));
      weights.push_back(p_cd->getWeight(j));
    }

    this->rt_ = (rt_left + rt_right) / 2;

    return (train(obs_mz, theo_mz, weights, md, use_RANSAC));
  }
Example #3
0
//----------------------------------------------------------------------------------------------------------------------
void SettingsDialog::setCalibrationData(const CalibrationData& calibrationData)
{
#ifdef TEST_ONLY
    QSettings settingsFile("tokenTest_Settings.ini", QSettings::IniFormat);
#else
    QSettings settingsFile("tokenGraver_Settings.ini", QSettings::IniFormat);
#endif
    for (int i = 0; i < calibrationData.size(); ++i) {
        settingsFile.setValue(QString("calibrationData") + QString::number(i), calibrationData[i]);
    }
}