本文整理汇总了C++中Album::push方法的典型用法代码示例。如果您正苦于以下问题:C++ Album::push方法的具体用法?C++ Album::push怎么用?C++ Album::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::push方法的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;
}
示例2: 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;
}
示例3: 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();
LabelSet::initialize( env["color-map"] );
std::vector<std::string> nameList = std::move( readlines( strf( "%s/%s", env["dataset"].c_str(),
env["list-file"].c_str())) );
std::vector<std::string> imgList = std::move( path::FFFL( env["dataset"], nameList, ".png" ) );
std::vector<std::string> labelList = std::move( path::FFFL( env["dataset"], nameList, "_L.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 ) ) );
}
Album<uchar> labelAlbum;
for ( auto& ele : labelList ) {
labelAlbum.push( std::move( cvFeat<BGR>::gen( ele ) ) );
}
Done( "Learning Album Loaded" );
Info( "Loading Forest ..." );
Forest<SimpleKernel<float> > forest( env["forest-name"] );
Done( "Forest Loaded." );
Info( "Start Label Training ..." );
/// Construct Bipartite Graph between l and m
/// and also the ground truth P
Info( "Initializing Optimization ... " );
// calculate M
int M = 0;
for ( auto& img :album ) {
M += ( img.rows - 14 ) * ( img.cols - 14 );
}
Bipartite m_to_l( M, forest.centers() );
double *P = new double[M * LabelSet::classes];
double *pP = P;
int m = 0;
for ( auto& img : album ) {
printf( "working on Image %d ...\n", img.id );
float feat[img.GetPatchDim()];
for ( int i=7; i<img.rows-7; i++ ) {
for ( int j=7; j<img.cols-7; j++ ) {
img.FetchPatch( i, j, feat );
auto res = std::move( forest.query_with_coef( feat ) );
int count = 0;
for ( auto& ele : res ) {
if ( count++ > 100 ) break;
m_to_l.add( m, ele.first, ele.second );
}
const uchar* color = labelAlbum(img.id)( i, j );
int classID = LabelSet::GetClass( color[0],
color[1],
color[2] );
for ( int k=0; k<LabelSet::classes; k++ ) {
if ( k == classID ) {
*(pP++) = 1.0;
} else {
*(pP++) = 0.0;
}
}
m++;
}
}
}
Done( "Initialized." );
double *q = new double[ forest.centers() * LabelSet::classes ];
double *qp = q;
for ( int i=0; i<forest.centers() * LabelSet::classes; i++ ) *(qp++) = LabelSet::inv;
//.........这里部分代码省略.........
示例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 );
}
//.........这里部分代码省略.........