|
@@ -76,6 +76,7 @@ class SparseImageAcess: public ValueAccess
|
|
|
{
|
|
|
//MultiChannelImageT<SparseVectorInt> textonMap;
|
|
|
//TODO: implement access
|
|
|
+ return -1.0;
|
|
|
}
|
|
|
|
|
|
virtual string writeInfos()
|
|
@@ -1732,12 +1733,12 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
#ifdef WRITEGLOB
|
|
|
ofstream outstream("globtrain.feat");
|
|
|
|
|
|
- for(uint i = 0; i < textonMap.size(); i++)
|
|
|
+ for(int i = 0; i < textonMap.size(); i++)
|
|
|
{
|
|
|
set<int> usedclasses;
|
|
|
- for ( int x = 0; x < labels[i].rows(); x++ )
|
|
|
+ for ( uint x = 0; x < labels[i].rows(); x++ )
|
|
|
{
|
|
|
- for ( int y = 0; y < labels[i].cols(); y++ )
|
|
|
+ for ( uint y = 0; y < labels[i].cols(); y++ )
|
|
|
{
|
|
|
int classno = labels[i] ( x, y );
|
|
|
|
|
@@ -1759,7 +1760,6 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
}
|
|
|
|
|
|
outstream.close();
|
|
|
-
|
|
|
#endif
|
|
|
cout << "uniquenumber " << uniquenumber << endl;
|
|
|
//getchar();
|
|
@@ -1767,7 +1767,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
for ( int tree = 0; tree < nbTrees; tree++ )
|
|
|
{
|
|
|
int t = ( int ) forest[tree].size();
|
|
|
-
|
|
|
+
|
|
|
for ( int i = 0; i < t; i++ )
|
|
|
{
|
|
|
printf ( "tree[%i]: left: %i, right: %i", i, forest[tree][i].left, forest[tree][i].right );
|
|
@@ -1956,6 +1956,42 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
|
|
|
|
cout << forest[0][currentfeats.get ( xpos, ypos, 0 ) ].dist << endl;
|
|
|
|
|
|
+#ifdef WRITEGLOB
|
|
|
+ ofstream outstream("globtest.feat",ofstream::app);
|
|
|
+ outstream << 0 << endl;
|
|
|
+ integralTexton(integralTexton.width()-1, integralTexton.height()-1).store(outstream);
|
|
|
+ outstream.close();
|
|
|
+#endif
|
|
|
+
|
|
|
+ string cndir = conf->gS ( "SSContextTree", "cndir", "" );
|
|
|
+ int classes = ( int ) probabilities.numChannels;
|
|
|
+ vector<int> useclass ( classes, 1 );
|
|
|
+
|
|
|
+ std::vector< std::string > list;
|
|
|
+ StringTools::split ( currentFile, '/', list );
|
|
|
+
|
|
|
+ string orgname = list.back();
|
|
|
+ if ( cndir != "" )
|
|
|
+ {
|
|
|
+ useclass = vector<int> ( classes, 0 );
|
|
|
+ ifstream infile ( ( cndir + "/" + orgname + ".dat" ).c_str() );
|
|
|
+ while ( !infile.eof() && infile.good() )
|
|
|
+ {
|
|
|
+ int tmp;
|
|
|
+ infile >> tmp;
|
|
|
+ assert(tmp >= 0 && tmp < classes);
|
|
|
+ useclass[tmp] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int c = 0; c < classes; c++)
|
|
|
+ {
|
|
|
+ if(useclass[c] == 0)
|
|
|
+ {
|
|
|
+ probabilities.set(-numeric_limits< double >::max(), c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if ( pixelWiseLabeling )
|
|
|
{
|
|
|
//finales labeln:
|
|
@@ -1971,11 +2007,12 @@ void SemSegContextTree::semanticseg ( CachedExample *ce, NICE::Image & segresult
|
|
|
|
|
|
for ( uint i = 0; i < s; i++ )
|
|
|
{
|
|
|
- probabilities.data[labelmapback[i]][offset] = getMeanProb ( x, y, i, currentfeats );
|
|
|
+ int currentclass = labelmapback[i];
|
|
|
+ probabilities.data[currentclass][offset] = getMeanProb ( x, y, i, currentfeats );
|
|
|
|
|
|
- if ( probabilities.data[labelmapback[i]][offset] > maxvalue )
|
|
|
+ if ( probabilities.data[currentclass][offset] > maxvalue )
|
|
|
{
|
|
|
- maxvalue = probabilities.data[labelmapback[i]][offset];
|
|
|
+ maxvalue = probabilities.data[currentclass][offset];
|
|
|
maxindex = labelmapback[i];
|
|
|
}
|
|
|
|
|
@@ -2158,7 +2195,7 @@ void SemSegContextTree::restore ( std::istream & is, int format )
|
|
|
forest[t][n].feat = NULL;
|
|
|
if ( feattype >= 0 )
|
|
|
{
|
|
|
- for ( int o = 0; o < ops.size(); o++ )
|
|
|
+ for ( uint o = 0; o < ops.size(); o++ )
|
|
|
{
|
|
|
if ( ops[o]->getOps() == feattype )
|
|
|
{
|
|
@@ -2169,7 +2206,7 @@ void SemSegContextTree::restore ( std::istream & is, int format )
|
|
|
|
|
|
if ( forest[t][n].feat == NULL )
|
|
|
{
|
|
|
- for ( int o = 0; o < cops.size(); o++ )
|
|
|
+ for ( uint o = 0; o < cops.size(); o++ )
|
|
|
{
|
|
|
if ( cops[o]->getOps() == feattype )
|
|
|
{
|