本文整理汇总了C++中Album::SetPatchStride方法的典型用法代码示例。如果您正苦于以下问题:C++ Album::SetPatchStride方法的具体用法?C++ Album::SetPatchStride怎么用?C++ Album::SetPatchStride使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::SetPatchStride方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
//.........这里部分代码省略.........