@ -352,7 +352,7 @@ NCVStatus loadFromXML(const std::string &filename,
if ( oldCascade . empty ( ) )
return NCV_HAAR_XML_LOADING_EXCEPTION ;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
haar . ClassifierSize . width = oldCascade - > orig_window_size . width ;
haar . ClassifierSize . height = oldCascade - > orig_window_size . height ;
@ -366,7 +366,7 @@ NCVStatus loadFromXML(const std::string &filename,
curStage . setStageThreshold ( oldCascade - > stage_classifier [ s ] . threshold ) ;
int treesCount = oldCascade - > stage_classifier [ s ] . count ;
for ( int t = 0 ; t < treesCount ; + + t ) // bytrees
for ( int t = 0 ; t < treesCount ; + + t ) // by trees
{
Ncv32u nodeId = 0 ;
CvHaarClassifier * tree = & oldCascade - > stage_classifier [ s ] . classifier [ t ] ;
@ -379,12 +379,16 @@ NCVStatus loadFromXML(const std::string &filename,
HaarClassifierNode128 curNode ;
curNode . setThreshold ( tree - > threshold [ n ] ) ;
NcvBool bIsLeftNodeLeaf = false ;
NcvBool bIsRightNodeLeaf = false ;
HaarClassifierNodeDescriptor32 nodeLeft ;
if ( tree - > left [ n ] < = 0 )
{
Ncv32f leftVal = tree - > alpha [ - tree - > left [ n ] ] ;
ncvStat = nodeLeft . create ( leftVal ) ;
ncvAssertReturn ( ncvStat = = NCV_SUCCESS , ncvStat ) ;
bIsLeftNodeLeaf = true ;
}
else
{
@ -400,6 +404,7 @@ NCVStatus loadFromXML(const std::string &filename,
Ncv32f rightVal = tree - > alpha [ - tree - > right [ n ] ] ;
ncvStat = nodeRight . create ( rightVal ) ;
ncvAssertReturn ( ncvStat = = NCV_SUCCESS , ncvStat ) ;
bIsRightNodeLeaf = true ;
}
else
{
@ -435,7 +440,8 @@ NCVStatus loadFromXML(const std::string &filename,
}
HaarFeatureDescriptor32 tmpFeatureDesc ;
ncvStat = tmpFeatureDesc . create ( haar . bNeedsTiltedII , featureId , haarFeatures . size ( ) - featureId ) ;
ncvStat = tmpFeatureDesc . create ( haar . bNeedsTiltedII , bIsLeftNodeLeaf , bIsRightNodeLeaf ,
featureId , haarFeatures . size ( ) - featureId ) ;
ncvAssertReturn ( NCV_SUCCESS = = ncvStat , ncvStat ) ;
curNode . setFeatureDesc ( tmpFeatureDesc ) ;
@ -459,8 +465,8 @@ NCVStatus loadFromXML(const std::string &filename,
curStage . setNumClassifierRootNodes ( treesCount ) ;
haarStages . push_back ( curStage ) ;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//fill in cascade stats
haar . NumStages = haarStages . size ( ) ;
@ -472,8 +478,10 @@ NCVStatus loadFromXML(const std::string &filename,
Ncv32u offsetRoot = haarClassifierNodes . size ( ) ;
for ( Ncv32u i = 0 ; i < haarClassifierNodes . size ( ) ; i + + )
{
HaarFeatureDescriptor32 featureDesc = haarClassifierNodes [ i ] . getFeatureDesc ( ) ;
HaarClassifierNodeDescriptor32 nodeLeft = haarClassifierNodes [ i ] . getLeftNodeDesc ( ) ;
if ( ! nodeLeft . isLeaf ( ) )
if ( ! featureDesc . isLeftNode Leaf( ) )
{
Ncv32u newOffset = nodeLeft . getNextNodeOffset ( ) + offsetRoot ;
nodeLeft . create ( newOffset ) ;
@ -481,7 +489,7 @@ NCVStatus loadFromXML(const std::string &filename,
haarClassifierNodes [ i ] . setLeftNodeDesc ( nodeLeft ) ;
HaarClassifierNodeDescriptor32 nodeRight = haarClassifierNodes [ i ] . getRightNodeDesc ( ) ;
if ( ! nodeRight . is Leaf( ) )
if ( ! featureDesc . isRightNode Leaf( ) )
{
Ncv32u newOffset = nodeRight . getNextNodeOffset ( ) + offsetRoot ;
nodeRight . create ( newOffset ) ;
@ -490,8 +498,10 @@ NCVStatus loadFromXML(const std::string &filename,
}
for ( Ncv32u i = 0 ; i < h_TmpClassifierNotRootNodes . size ( ) ; i + + )
{
HaarFeatureDescriptor32 featureDesc = h_TmpClassifierNotRootNodes [ i ] . getFeatureDesc ( ) ;
HaarClassifierNodeDescriptor32 nodeLeft = h_TmpClassifierNotRootNodes [ i ] . getLeftNodeDesc ( ) ;
if ( ! nodeLeft . isLeaf ( ) )
if ( ! featureDesc . isLeftNode Leaf( ) )
{
Ncv32u newOffset = nodeLeft . getNextNodeOffset ( ) + offsetRoot ;
nodeLeft . create ( newOffset ) ;
@ -499,7 +509,7 @@ NCVStatus loadFromXML(const std::string &filename,
h_TmpClassifierNotRootNodes [ i ] . setLeftNodeDesc ( nodeLeft ) ;
HaarClassifierNodeDescriptor32 nodeRight = h_TmpClassifierNotRootNodes [ i ] . getRightNodeDesc ( ) ;
if ( ! nodeRight . is Leaf( ) )
if ( ! featureDesc . isRightNode Leaf( ) )
{
Ncv32u newOffset = nodeRight . getNextNodeOffset ( ) + offsetRoot ;
nodeRight . create ( newOffset ) ;