当前位置: 首页>>代码示例>>C++>>正文


C++ Album::size方法代码示例

本文整理汇总了C++中Album::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Album::size方法的具体用法?C++ Album::size怎么用?C++ Album::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Album的用法示例。


在下文中一共展示了Album::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int argc, char **argv )
{

  if ( argc < 2 ) {
    Error( "Missing configuration file in options. (testing.conf)" );
    exit( -1 );
  }

  srand( 345645631 );


  env.parse( argv[1] );
  env.Summary();


  std::vector<std::string> imgList = std::move( readlines( strf( "%s/%s", env["dataset"].c_str(),
                                                                 env["list-file"].c_str())) );
  imgList = std::move( path::FFFL( env["dataset"], imgList, ".png" ) );
  
  for ( auto& ele : imgList ) {
    printf( "%s\n", ele.c_str() );
  }


  Info( "Loading Learning Album ..." );
  Album<float> album;
  for ( auto& ele : imgList ) {
    album.push( std::move( cvFeat<HOG>::gen( ele ) ) );
  }
  Done( "Learning Album Loaded" );
  
  
  Info( "Loading Forest ..." );
  Forest<SimpleKernel<float> > forest( env["forest-name"] );
  
  Info( "Learning ..." );
  
  forest.PrepareWeitghts();
  
  float feat[album(0).GetPatchDim()];

  for ( int k=0; k<album.size(); k++ ) {
    for ( int i=0; i<album(k).rows; i++ ) {
      for ( int j=0; j<album(k).cols; j++ ) {
        album(k).FetchPatch( i, j, feat );
        forest.learn( feat );
      }
    }
    Info( "%d / %d learned.", k + 1, album.size() );
  }
  
  forest.writeWeights( env["forest-name"] );
  
  return 0;
}
开发者ID:breakds,项目名称:PatTk,代码行数:55,代码来源:Learning.cpp

示例2: GetClassInvDistribution

void GetClassInvDistribution( Album<int> &lblAlbum,
                              double *classWeight )
{
  int counts[LabelSet::classes];
  memset( counts, 0, sizeof(int) * LabelSet::classes );

  int n = lblAlbum.size();
  int j = 0;
  for ( auto& lblImg : lblAlbum ) {
    int area = lblImg.rows * lblImg.cols;
    for ( int i=0; i<area; i++ ) {
      counts[*lblImg(i)]++;
    }
    progress( ++j, n, "calculating inverse weights" );
  }
  printf( "\n" );

  int s = sum_vec( counts, LabelSet::classes );

  for ( int i=0; i<LabelSet::classes; i++ ) {
    classWeight[i] = static_cast<double>(s) / counts[i];
  }


  double t = sum_vec( classWeight, LabelSet::classes ) / static_cast<double>( LabelSet::classes );
  for ( int i=0; i<LabelSet::classes; i++ ) {
    classWeight[i] /= t;
  }
}
开发者ID:breakds,项目名称:PatTk,代码行数:29,代码来源:TreeQuality.cpp

示例3: main

int main( int argc, char **argv )
{

  if ( argc < 2 ) {
    Error( "Missing configuration file in options. (training.conf)" );
    exit( -1 );
  }
  
  srand( 345645631 );

  env.parse( argv[1] );
  env.Summary();
  
  std::vector<std::string> imgList = std::move( readlines( strf( "%s/%s", env["dataset"].c_str(),
                                                                 env["list-file"].c_str())) );
  imgList =  std::move( path::FFFL( env["dataset"], imgList, ".png" ) );

  for ( auto& ele : imgList ) {
    printf( "%s\n", ele.c_str() );
  }


  Info( "Loading Training Album ..." );

  Album<float> album;
  for ( auto& ele : imgList ) {
    album.push( std::move( cvFeat<HOG>::gen( ele ) ) );
  }
  Done( "Training Album Loaded" );
  
  std::vector<FeatImage<float>::PatchProxy> l;
  
  for ( int k=0; k<album.size(); k++ ) {
    auto& ref = album(k);
    for ( int i=7; i<ref.rows-7; i++ ) {
      for ( int j=7; j<ref.cols-7; j++ ) {
        l.push_back( ref.Spawn( i, j ) );
      }
    }
  }


  timer::tic();
  Forest<SimpleKernel<float> > forest( env["forest-size"], l, env["proportion-of-data-per-tree"].toDouble() );
  Done( "Tree built within %.5lf sec.", timer::utoc() );

  forest.write( env["forest-name"] );

  return 0;
}
开发者ID:breakds,项目名称:PatTk,代码行数:50,代码来源:Training.cpp

示例4: main

int main( int argc, char **argv )
{

  if ( argc < 2 ) {
    Error( "Missing configuration file in arguments. (treeQ.conf)" );
    exit( -1 );
  }

  // srand( 7325273 );
  srand(time(NULL));

  env.parse( argv[1] );
  env.Summary();

  LabelSet::initialize( env["color-map"] );

  /* ---------- Build/Load Forest ---------- */
  std::vector<std::string> imgList = std::move( readlines( strf( "%s/%s", env["dataset"].c_str(),
                                                                 env["list-file"].c_str())) );
  auto lblList = std::move( path::FFFL( env["dataset"], imgList, "_L.png" ) );
  imgList =  std::move( path::FFFL( env["dataset"], imgList, ".png" ) );

  Album<float> album;
  {
    int i = 0;
    int n = static_cast<int>( imgList.size() );
    for ( auto& ele : imgList ) {
      album.push( std::move( cvFeat<HOG>::gen( ele ) ) );
      progress( ++i, n, "Loading Album" );
    }
  }
  printf( "\n" );



  
  Album<int> lblAlbum;
  {
    int i = 0;
    int n = static_cast<int>( lblList.size() );
    for ( auto& ele : lblList ) {
      lblAlbum.push( std::move( cvFeat<HARD_LABEL_MAP>::gen( ele ) ) );
      progress( ++i, n, "Loading Label Album" );
    }
  }
  printf( "\n" );
  lblAlbum.SetPatchSize( env["lbl-size"] );
  lblAlbum.SetPatchStride( 1 );


  

  
  /* ---------- Load Forest ---------- */
  Info( "Loading Forest .." );
  timer::tic();
  Forest<EntropyKernel<float> > forest( env["forest-dir"] );
  printf( "tree loaded: %.3lf sec\n", timer::utoc() );
  printf( "maxDepth: %d\n", forest.maxDepth() );

  
  /* ---------- Collective Entropy ---------- */
  if ( env.find( "entropy-output" ) ) {
    WITH_OPEN( out, env["entropy-output"].c_str(), "w" );
    int label[lblAlbum(0).GetPatchDim()];
    int count[LabelSet::classes];
    for ( int i=0; i<forest.centers(); i++ ) {
      memset( count, 0, sizeof(int) * LabelSet::classes );
      for ( auto& ele : forest(i).store ) {
        lblAlbum(ele.id).FetchPatch( ele.y, ele.x, label );
        for ( int j=0; j<lblAlbum(0).GetPatchDim(); j++ ) {
          count[label[j]]++;
        }
      }
      double ent = entropy( count, LabelSet::classes );
      fprintf( out, "%.8lf\n", ent );
      if ( 0 == i % 100 ) progress( i+1, forest.centers(), "Calculating Entropy" );
    }
    printf( "\n" );
    END_WITH( out );
  }


  /* ---------- Center Entropy ---------- */
  if ( env.find( "center-entropy-output" ) ) {
    WITH_OPEN( out, env["center-entropy-output"].c_str(), "w" );
    int count[LabelSet::classes];
    for ( int i=0; i<forest.centers(); i++ ) {
      memset( count, 0, sizeof(int) * LabelSet::classes );
      for ( auto& ele : forest(i).store ) {
        count[*lblAlbum(ele.id)(ele.y, ele.x)]++;
      }
      double ent = entropy( count, LabelSet::classes );
      fprintf( out, "%.8lf\n", ent );
      if ( 0 == i % 100 ) progress( i+1, forest.centers(), "Calculating Entropy" );
    }
    printf( "\n" );
    END_WITH( out );
  }

//.........这里部分代码省略.........
开发者ID:breakds,项目名称:PatTk,代码行数:101,代码来源:TreeQuality.cpp


注:本文中的Album::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。