示例#1
0
文件: Schema.cpp 项目: foogywoo/drone
Schema::Schema(MetaGear * parentMetaGear) :
_needSynch(true),  
_parentMetaGear(parentMetaGear),
_locked(false)
{
  ASSERT_ERROR_MESSAGE(_parentMetaGear!=0, "Schema with a null parent metagear");
}
示例#2
0
void TupleDataSet::reset() {
  ASSERT_ERROR_MESSAGE( example, "Example is NULL, maybe you forgot to call init()?" );
  unsigned int dummy;
  file->rewind();
  file->read(&dummy, sizeof(unsigned int), 1);
  file->read(&dummy, sizeof(unsigned int), 1);

  observation.loadData(file);

  currentExampleIndex = -1;
}
示例#3
0
void XFileDataSet::reset() {
  ASSERT_ERROR_MESSAGE( example, "Example is NULL, maybe you forgot to call init()?" );

  file->rewind();
  int x;
  file->read(&x, sizeof(int), 1);
  ASSERT_WARNING( x == nExamples );
  file->read(&x, sizeof(int), 1);
  ASSERT_WARNING( x == dim );

  currentExampleIndex = -1;
}
示例#4
0
// Loads all the features and put them into the _selFeatures vector
void Gear_FaceTrack::readFeaturesCascade(const std::string& baseName)
{
  Feature tmpFeature;
  std::vector<Feature> tmpBlocFeatures;
  int i;
  int nFeatures;
  char fileName[2000];
  int fileCounter;
  int sizeCounter = 0;

  float resizingFactor = 1.25;

  // Precomputing now all the sizes
  int smallestSize = 3, biggestSize = 8;
  float scale;
  int tmpWindowSize;
  int tmpShifting;
  std::vector< Feature > tmpPrecFeatures;
  std::vector< Feature >::iterator fIt;

  ASSERT_ERROR_MESSAGE(_pCascadeFeatures, "Cascade should be empty! Restart the application");

  _pCascadeFeatures = new Cascade[biggestSize - smallestSize + 1];

  scale = pow((double)resizingFactor, smallestSize);
  // Computing the window sizes
  for (i = smallestSize; i <= biggestSize; ++i)
  {
    // First compute the window size
    tmpWindowSize = static_cast<int>((float)_winSize * scale + 0.499);
    tmpShifting = static_cast<int>((float)_deltaS * scale + 0.499);
    _precWinSizes.push_back( PrecompWindows(tmpWindowSize, tmpShifting) );
    scale *= resizingFactor;
  }

  fileCounter = 1;
  while(true)
  {
    sprintf(fileName, "%s_%d.dat", baseName.c_str(), fileCounter++);

    std::ifstream inFile(fileName, std::ios::binary | std::ios::in);
    if (!inFile.is_open())
    {   
      std::cout << "!!!!!!!!!" << std::endl;
      break;
    }

    inFile.seekg(0, std::ios::end);
    int tmp = sizeof(Feature);
    nFeatures = inFile.tellg() / sizeof(Feature);
    inFile.seekg(0);

    tmpBlocFeatures.clear();
    for (i = 0; i < nFeatures; ++i)
    {
#if NEW_VERSION
      inFile.read( (char *)&tmpFeature, sizeof(Feature) );
#else
//       char tmpData[150];
//       inFile.read( (char*)tmpData, 150);

      //*((double *)(&tmpData[10]));
      
      char tmpSkipping;
      inFile.read( (char *)&tmpFeature._type, sizeof(FeatureType) );
      inFile.read( (char *)&tmpFeature._cutPoint, sizeof(float) );
      inFile.read( (char *)&tmpFeature._class, sizeof(bool) );
      inFile.read( &tmpSkipping, sizeof(char) );
      inFile.read( &tmpSkipping, sizeof(char) );
      inFile.read( &tmpSkipping, sizeof(char) );
      inFile.read( (char *)&tmpFeature._x, sizeof(int) );
      inFile.read( (char *)&tmpFeature._y, sizeof(int) );
      inFile.read( (char *)&tmpFeature._xSize, sizeof(int) );
      inFile.read( (char *)&tmpFeature._ySize, sizeof(int) );
      inFile.read( &tmpSkipping, sizeof(char) );
      inFile.read( &tmpSkipping, sizeof(char) );
      inFile.read( &tmpSkipping, sizeof(char) );
      inFile.read( &tmpSkipping, sizeof(char) );
      inFile.read( (char *)&tmpFeature._alpha, sizeof(double) );
#endif
      tmpBlocFeatures.push_back(tmpFeature);
    }
    inFile.close();

    scale = pow((double)resizingFactor, smallestSize);
    sizeCounter = 0;

    for (i = smallestSize; i <= biggestSize; ++i, ++sizeCounter)
    {
      // Now the features

      // For each feature found
      for (fIt = tmpBlocFeatures.begin(); fIt != tmpBlocFeatures.end(); ++fIt)
      {
        tmpFeature = *fIt;
        tmpFeature._x = static_cast<int>((float)tmpFeature._x * scale + 0.499);
        tmpFeature._y = static_cast<int>((float)tmpFeature._y * scale + 0.499);
        tmpFeature._xSize = static_cast<int>((float)tmpFeature._xSize * scale + 0.499);
        tmpFeature._ySize = static_cast<int>((float)tmpFeature._ySize * scale + 0.499);

        tmpPrecFeatures.push_back(tmpFeature);
      }

      _pCascadeFeatures[sizeCounter].push_back(tmpPrecFeatures);
      tmpPrecFeatures.clear();
      scale *= resizingFactor;
    }

  }

//   std::cout << "precomputed win sizes: " << std::endl;
  
//   for (std::vector< PrecompWindows >::iterator it = _precWinSizes.begin(); it != _precWinSizes.end(); ++it)
//     std::cout << it->winSize << " " << it->shifting << std::endl;
//   std::cout << "=========== " << std::endl;
}