Exemplo n.º 1
0
    void SimpleCascadedPoseRegression::Load(const std::string& fileName)
    {
        Reset();
        std::ifstream fin(fileName);
        int fernCount;
        fin >> fernCount;
        mRandomFerns.reserve(fernCount);
        for (int fernId = 0; fernId < fernCount; fernId++)
        {
            int predictionDim;
            fin >> predictionDim;
            int fernSize;
            fin >> fernSize;
            int predVecCount = predictionDim * pow(2, fernSize);
            std::vector<double> predictions(predVecCount);
            double dTemp;
            for (int predId = 0; predId < predVecCount; predId++)
            {
                fin >> dTemp;
                predictions.at(predId) = dTemp;
            }
            std::vector<int> featureIds(fernSize);
            int nTemp;
            for (int fernId = 0; fernId < fernSize; fernId++)
            {
                fin >> nTemp;
                featureIds.at(fernId) = nTemp;
            }
            std::vector<int> featureBases(fernSize);
            for (int fernId = 0; fernId < fernSize; fernId++)
            {
                fin >> nTemp;
                featureBases.at(fernId) = nTemp;
            }
            MagicML::RandomFern* pFern = new MagicML::RandomFern;
            pFern->Load(predictionDim, predictions, featureIds, featureBases);
            mRandomFerns.push_back(pFern);
        }
        
        fin >> mValidFeatureSize >> mImgPatchSize;
        int validPairSize = mValidFeatureSize * fernCount * 2;
        mValidFeaturePosPairs.reserve(validPairSize);
        int nTemp;
        for (int validId = 0; validId < validPairSize; validId++)
        {
            fin >> nTemp;
            mValidFeaturePosPairs.push_back(nTemp);
        }

        fin.close();
    }
Exemplo n.º 2
0
bool RestrictionCollector::AddRestriction(Restriction::Type type, vector<uint64_t> const & osmIds)
{
  vector<uint32_t> featureIds(osmIds.size());
  for (size_t i = 0; i < osmIds.size(); ++i)
  {
    auto const result = m_osmIdToFeatureId.find(osmIds[i]);
    if (result == m_osmIdToFeatureId.cend())
    {
      // It could happend near mwm border when one of a restriction lines is not included in mwm
      // but the restriction is included.
      return false;
    }

    // Only one feature id is found for |osmIds[i]|.
    featureIds[i] = result->second;
  }

  m_restrictions.emplace_back(type, featureIds);
  return true;
}