|
@@ -678,6 +678,8 @@ SemSegContextTree::~SemSegContextTree()
|
|
|
|
|
|
double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<double> > &feats, std::vector<NICE::MultiChannelImageT<int> > ¤tfeats, std::vector<NICE::MultiChannelImageT<double> > &integralImgs, const std::vector<NICE::MatrixT<int> > &labels, int node, Operation *&splitop, double &splitval, const int &tree )
|
|
double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<double> > &feats, std::vector<NICE::MultiChannelImageT<int> > ¤tfeats, std::vector<NICE::MultiChannelImageT<double> > &integralImgs, const std::vector<NICE::MatrixT<int> > &labels, int node, Operation *&splitop, double &splitval, const int &tree )
|
|
{
|
|
{
|
|
|
|
+ Timer t;
|
|
|
|
+ t.start();
|
|
int imgCount = 0, featdim = 0;
|
|
int imgCount = 0, featdim = 0;
|
|
|
|
|
|
try
|
|
try
|
|
@@ -747,7 +749,6 @@ double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<dou
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
//cout << "size: " << selFeats.size() << endl;
|
|
//cout << "size: " << selFeats.size() << endl;
|
|
//getchar();
|
|
//getchar();
|
|
|
|
|
|
@@ -844,7 +845,7 @@ double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<dou
|
|
featsel.push_back( op );
|
|
featsel.push_back( op );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
#pragma omp parallel for private(mapit)
|
|
#pragma omp parallel for private(mapit)
|
|
for ( int f = 0; f < featsPerSplit; f++ )
|
|
for ( int f = 0; f < featsPerSplit; f++ )
|
|
{
|
|
{
|
|
@@ -945,6 +946,7 @@ double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<dou
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//getchar();
|
|
//getchar();
|
|
//splitop->writeInfos();
|
|
//splitop->writeInfos();
|
|
//cout<< "ig: " << bestig << endl;
|
|
//cout<< "ig: " << bestig << endl;
|
|
@@ -954,6 +956,8 @@ double SemSegContextTree::getBestSplit( std::vector<NICE::MultiChannelImageT<dou
|
|
if(featsel[i] != splitop)
|
|
if(featsel[i] != splitop)
|
|
delete featsel[i];
|
|
delete featsel[i];
|
|
}*/
|
|
}*/
|
|
|
|
+
|
|
|
|
+
|
|
#ifdef debug
|
|
#ifdef debug
|
|
cout << "globent: " << globent << " bestig " << bestig << " splitval: " << splitval << endl;
|
|
cout << "globent: " << globent << " bestig " << bestig << " splitval: " << splitval << endl;
|
|
|
|
|
|
@@ -1241,7 +1245,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- int depth = 0;
|
|
|
|
|
|
+ depth = 0;
|
|
|
|
|
|
for ( int t = 0; t < nbTrees; t++ )
|
|
for ( int t = 0; t < nbTrees; t++ )
|
|
{
|
|
{
|
|
@@ -1262,6 +1266,9 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
|
|
|
while ( !allleaf && depth < maxDepth )
|
|
while ( !allleaf && depth < maxDepth )
|
|
{
|
|
{
|
|
|
|
+#ifdef DEBUG
|
|
|
|
+ cout << "depth: " << depth << endl;
|
|
|
|
+#endif
|
|
allleaf = true;
|
|
allleaf = true;
|
|
vector<MultiChannelImageT<int> > lastfeats = currentfeats;
|
|
vector<MultiChannelImageT<int> > lastfeats = currentfeats;
|
|
|
|
|
|
@@ -1287,7 +1294,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
if ( !forest[tree][i].isleaf && forest[tree][i].left < 0 )
|
|
if ( !forest[tree][i].isleaf && forest[tree][i].left < 0 )
|
|
{
|
|
{
|
|
#if 0
|
|
#if 0
|
|
- timer.stop();
|
|
|
|
|
|
+ timer.stop();
|
|
cout << "time 1: " << timer.getLast() << endl;
|
|
cout << "time 1: " << timer.getLast() << endl;
|
|
timer.start();
|
|
timer.start();
|
|
#endif
|
|
#endif
|
|
@@ -1296,7 +1303,14 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
double bestig = getBestSplit( allfeats, lastfeats, integralImgs, labels, i, splitfeat, splitval, tree );
|
|
double bestig = getBestSplit( allfeats, lastfeats, integralImgs, labels, i, splitfeat, splitval, tree );
|
|
#if 0
|
|
#if 0
|
|
timer.stop();
|
|
timer.stop();
|
|
- cout << "time 2: " << timer.getLast() << endl;
|
|
|
|
|
|
+ double tl = timer.getLast();
|
|
|
|
+
|
|
|
|
+ if(tl > 10.0)
|
|
|
|
+ {
|
|
|
|
+ cout << "time 2: " << tl << endl;
|
|
|
|
+ cout << "slow split: " << splitfeat->writeInfos() << endl;
|
|
|
|
+ getchar();
|
|
|
|
+ }
|
|
timer.start();
|
|
timer.start();
|
|
#endif
|
|
#endif
|
|
forest[tree][i].feat = splitfeat;
|
|
forest[tree][i].feat = splitfeat;
|
|
@@ -1322,6 +1336,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
cout << "time 3: " << timer.getLast() << endl;
|
|
cout << "time 3: " << timer.getLast() << endl;
|
|
timer.start();
|
|
timer.start();
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
#pragma omp parallel for
|
|
#pragma omp parallel for
|
|
for ( int iCounter = 0; iCounter < imgcounter; iCounter++ )
|
|
for ( int iCounter = 0; iCounter < imgcounter; iCounter++ )
|
|
{
|
|
{
|
|
@@ -1342,6 +1357,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
feat.integralImg = &integralImgs[iCounter];
|
|
feat.integralImg = &integralImgs[iCounter];
|
|
double val = splitfeat->getVal( feat, x, y );
|
|
double val = splitfeat->getVal( feat, x, y );
|
|
|
|
|
|
|
|
+#pragma omp critical
|
|
if ( val < splitval )
|
|
if ( val < splitval )
|
|
{
|
|
{
|
|
currentfeats[iCounter].set( x, y, left, tree );
|
|
currentfeats[iCounter].set( x, y, left, tree );
|
|
@@ -1352,17 +1368,19 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
{
|
|
{
|
|
currentfeats[iCounter].set( x, y, right, tree );
|
|
currentfeats[iCounter].set( x, y, right, tree );
|
|
forest[tree][right].dist[labelmap[labels[iCounter]( x, y )]]++;
|
|
forest[tree][right].dist[labelmap[labels[iCounter]( x, y )]]++;
|
|
|
|
+ forest[tree][right].featcounter++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
#if 0
|
|
#if 0
|
|
timer.stop();
|
|
timer.stop();
|
|
cout << "time 4: " << timer.getLast() << endl;
|
|
cout << "time 4: " << timer.getLast() << endl;
|
|
timer.start();
|
|
timer.start();
|
|
#endif
|
|
#endif
|
|
- forest[tree][right].featcounter = forest[tree][i].featcounter - forest[tree][left].featcounter;
|
|
|
|
|
|
+// forest[tree][right].featcounter = forest[tree][i].featcounter - forest[tree][left].featcounter;
|
|
|
|
|
|
double lcounter = 0.0, rcounter = 0.0;
|
|
double lcounter = 0.0, rcounter = 0.0;
|
|
|
|
|
|
@@ -1448,9 +1466,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
timer.start();
|
|
timer.start();
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
-
|
|
|
|
- //TODO: features neu berechnen!
|
|
|
|
-
|
|
|
|
|
|
+
|
|
//compute integral image
|
|
//compute integral image
|
|
int channels = classes + allfeats[0].channels();
|
|
int channels = classes + allfeats[0].channels();
|
|
#if 0
|
|
#if 0
|
|
@@ -1473,8 +1489,7 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
timer.stop();
|
|
timer.stop();
|
|
cout << "time for part1: " << timer.getLast() << endl;
|
|
cout << "time for part1: " << timer.getLast() << endl;
|
|
timer.start();
|
|
timer.start();
|
|
-#endif
|
|
|
|
-
|
|
|
|
|
|
+#endif
|
|
|
|
|
|
#pragma omp parallel for
|
|
#pragma omp parallel for
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
for ( int i = 0; i < imgcounter; i++ )
|
|
@@ -1489,10 +1504,6 @@ void SemSegContextTree::train( const MultiDataset *md )
|
|
|
|
|
|
#endif
|
|
#endif
|
|
depth++;
|
|
depth++;
|
|
-
|
|
|
|
-#ifdef DEBUG
|
|
|
|
- cout << "depth: " << depth << endl;
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef DEBUG
|
|
#ifdef DEBUG
|
|
@@ -1588,7 +1599,7 @@ void SemSegContextTree::semanticseg( CachedExample *ce, NICE::Image & segresult,
|
|
|
|
|
|
currentfeats.setAll( 0 );
|
|
currentfeats.setAll( 0 );
|
|
|
|
|
|
- int depth = 0;
|
|
|
|
|
|
+ depth = 0;
|
|
|
|
|
|
while ( !allleaf )
|
|
while ( !allleaf )
|
|
{
|
|
{
|
|
@@ -1680,10 +1691,10 @@ void SemSegContextTree::semanticseg( CachedExample *ce, NICE::Image & segresult,
|
|
else
|
|
else
|
|
{
|
|
{
|
|
//final labeling using segmentation
|
|
//final labeling using segmentation
|
|
- //TODO: segmentation
|
|
|
|
Matrix regions;
|
|
Matrix regions;
|
|
int regionNumber = segmentation->segRegions( img, regions );
|
|
int regionNumber = segmentation->segRegions( img, regions );
|
|
cout << "regions: " << regionNumber << endl;
|
|
cout << "regions: " << regionNumber << endl;
|
|
|
|
+
|
|
int dSize = forest[0][0].dist.size();
|
|
int dSize = forest[0][0].dist.size();
|
|
vector<vector<double> > regionProbs( regionNumber, vector<double>( dSize, 0.0 ) );
|
|
vector<vector<double> > regionProbs( regionNumber, vector<double>( dSize, 0.0 ) );
|
|
vector<int> bestlabels( regionNumber, 0 );
|
|
vector<int> bestlabels( regionNumber, 0 );
|