本文整理汇总了C++中ParseTree::appearanceSet方法的典型用法代码示例。如果您正苦于以下问题:C++ ParseTree::appearanceSet方法的具体用法?C++ ParseTree::appearanceSet怎么用?C++ ParseTree::appearanceSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseTree
的用法示例。
在下文中一共展示了ParseTree::appearanceSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PtNode
ParseTree::ParseTree(const ParseTree & pt) :
g_(NULL), idxRootNode_(-1), states_(NULL), dataId_(pt.dataId()),
appearanceX_(NULL), imgWd_(pt.imgWd()), imgHt_(pt.imgHt())
{
nodeSet_.resize(pt.nodeSet().size(), NULL);
for ( int i = 0; i < nodeSet_.size(); ++i ) {
nodeSet_[i] = new PtNode(*pt.nodeSet()[i]);
}
edgeSet_.resize(pt.edgeSet().size(), NULL);
for ( int i = 0; i < edgeSet_.size(); ++i ) {
edgeSet_[i] = new PtEdge(*pt.edgeSet()[i]);
}
idxRootNode_ = pt.idxRootNode();
g_ = pt.grammar();
appearanceSet_.resize(pt.appearanceSet().size(), NULL);
for ( int i = 0; i < appearanceSet_.size(); ++i ) {
appearanceSet_[i] = new Appearance::Param(*pt.appearanceSet()[i]);
}
biasSet_ = pt.biasSet();
deformationSet_.resize(pt.deformationSet().size(), NULL);
for ( int i = 0; i < deformationSet_.size(); ++i ) {
deformationSet_[i] = new Deformation::Param(*pt.deformationSet()[i]);
}
scalepriorSet_.resize(pt.scalepriorSet().size(), NULL);
for ( int i = 0; i < scalepriorSet_.size(); ++i ) {
scalepriorSet_[i] = new Scaleprior::Param(*pt.scalepriorSet()[i]);
}
parseInfoSet_.resize(pt.parseInfoSet().size(), NULL);
for ( int i = 0; i < parseInfoSet_.size(); ++i ) {
parseInfoSet_[i] = new ParseInfo(*pt.parseInfoSet()[i]);
}
if (pt.states() != NULL ) {
states_ = new States(*pt.states());
}
appUsage_ = pt.appUsage();
if ( pt.appearaceX() != NULL ) {
appearanceX_ = new Appearance::Param( *(pt.appearaceX()) );
}
}
示例2: compareFeatures
int ParseTree::compareFeatures(const ParseTree & pt) const
{
assert(grammar() != NULL && grammar() == pt.grammar() );
for ( int i = 0; i < nodeSet().size(); ++i ) {
int idxG = nodeSet()[i]->idx()(PtNode::IDX_G);
int ii = 0;
for ( ; ii < pt.nodeSet().size(); ++ii ) {
int idxG1 = pt.nodeSet()[ii]->idx()(PtNode::IDX_G);
if ( idxG1 == idxG ) {
break;
}
} // for ii
if ( ii == pt.nodeSet().size() ) {
return 1;
}
for ( int j = PtNode::IDX_BIAS; j < PtNode::IDX_APP+1; ++j ) {
int fidx = nodeSet()[i]->idx()(j);
int fidx1 = pt.nodeSet()[ii]->idx()(j);
if (fidx != -1 && fidx1 != -1 ) {
switch (j) {
case PtNode::IDX_BIAS: {
if ( biasSet()[fidx] > pt.biasSet()[fidx1] ) {
return 1;
} else if ( biasSet()[fidx] < pt.biasSet()[fidx1] ) {
return -1;
}
break;
}
case PtNode::IDX_DEF: {
const Deformation::Param & p(*deformationSet()[fidx]);
const Deformation::Param & p1(*pt.deformationSet()[fidx1]);
for ( int k = 0; k < 4; ++k ) {
if ( p(k) > p1(k) ) {
return 1;
} else if (p(k) < p1(k)) {
return -1;
}
}
break;
}
case PtNode::IDX_SCALEPRIOR: {
const Scaleprior::Param & p(*scalepriorSet()[fidx]);
const Scaleprior::Param & p1(*pt.scalepriorSet()[fidx1]);
for ( int k = 0; k < 3; ++k ) {
if ( p(k) > p1(k) ) {
return 1;
} else if (p(k) < p1(k)) {
return -1;
}
}
break;
}
case PtNode::IDX_APP: {
const Appearance::Param & p(*appearanceSet()[fidx]);
const Appearance::Param & p1(*pt.appearanceSet()[fidx1]);
for ( int row=0; row < p.rows(); ++ row )
for ( int col=0; col < p.cols(); ++col )
for ( int k = 0; k < FeaturePyramid::NbFeatures; ++k ) {
if ( p(row, col)(k) > p1(row, col)(k) ) {
return 1;
} else if (p(row, col)(k) < p1(row, col)(k)) {
return -1;
}
}
break;
}
}
} else {
if (fidx != -1 && fidx1 == -1) {
return 1;
}
if (fidx == -1 && fidx1 != -1) {
return -1;
}
}
}
} // for i
return 0;
}