本文整理汇总了C++中Skeleton::getPartTree方法的典型用法代码示例。如果您正苦于以下问题:C++ Skeleton::getPartTree方法的具体用法?C++ Skeleton::getPartTree怎么用?C++ Skeleton::getPartTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skeleton
的用法示例。
在下文中一共展示了Skeleton::getPartTree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(skeletonTest, GetAndSetTest)
{
Skeleton s;
string name = "Skeleton Test";
tree <BodyPart> partTree;
tree <BodyPart>::iterator pti;
BodyPart bp;
pti = partTree.begin();
partTree.insert(pti, bp);
tree <BodyJoint> jointTree;
BodyJoint bj;
tree <BodyJoint>::iterator jti;
jti = jointTree.begin();
jointTree.insert(jti, bj);
float scale = 0.5;
s.setName(name);
s.setPartTree(partTree);
s.setJointTree(jointTree);
s.setScale(scale);
EXPECT_EQ(name, s.getName());
tree <BodyPart> pt1 = s.getPartTree();
EXPECT_TRUE(equal(pt1.begin(), pt1.end(), partTree.begin()));
tree <BodyJoint> jt1 = s.getJointTree();
EXPECT_TRUE(equal(jt1.begin(), jt1.end(), jointTree.begin()));
EXPECT_EQ(scale, s.getScale());
EXPECT_EQ(1, s.getPartTreeCount());
EXPECT_TRUE(bj == *s.getBodyJoint(bj.getLimbID()));
EXPECT_TRUE(NULL == s.getBodyJoint(-1));
}
示例2: Model
//Testing function "Train"
TEST(colorHistDetectorTest, Train)
{
//Load the input data
vector<Frame*> frames = LoadTestProject("speltests_TestData/CHDTrainTestData/", "trijumpSD_50x41.xml");
//Setting parameters
auto seq = new Sequence();
map <string, float> params = SetParams(frames, &seq);
for (auto f : frames)
delete f;
frames.clear();
frames = seq->getFrames();
//Counting a keyframes
int FirstKeyframe = FirstKeyFrameNum(frames);
int KeyframesCount = keyFramesCount(frames);
//Copy image and skeleton from keyframe
Mat image = frames[FirstKeyframe]->getImage();
Mat image1;
image.copyTo(image1);
Frame *frame = frames[FirstKeyframe];
Skeleton skeleton = frame->getSkeleton();
tree<BodyPart> PartTree = skeleton.getPartTree();
//Build the rectangles for all of bodyparts
map<int, POSERECT<Point2f>> Rects = SkeletonRects(skeleton);
//Run "Train()"
ColorHistDetector detector;
detector.train(frames, params);
//Calculate the polygons occlusion
//Polygons layers:
map<int, int> depth = { { 0, 2 }, { 1, 1 }, { 2, 3 }, { 3, 2 }, { 4, 4 }, { 5, 4 }, { 6, 1 }, { 7, 3 }, { 8, 2 }, { 9, 0 }, { 10, 4 }, { 11, 1 }, { 12, 3 }, { 13, 0 }, { 14, 4 }, { 15, 1 }, { 16, 3 } };
//Polygons occlusion:
vector<vector<pair<int, int>>> Crossings = CrossingsList(Rects, depth);
//Calculate the parts histograms
map <int32_t, ColorHistDetector::PartModel> partModels;
for (int i = 0; i < Rects.size(); i++)
{
ColorHistDetector::PartModel Model(8);
Model.sizeFG = 0;
float xmin, ymin, xmax, ymax;
Rects[i].GetMinMaxXY <float>(xmin, ymin, xmax, ymax);
for (int x = xmin; x < xmax; x++)
{
for (int y = ymin; y < ymax; y++)
{
bool b = true;
if (Rects[i].containsPoint(Point2f(x, y)) > 0)
{
int k = 0;
while ((k < Crossings[i].size()) && b)
{
if (Rects[Crossings[i][k].first].containsPoint(Point2f(x, y)) > 0)
b = false;
k++;
}
if (b)
{
int c = 50 + i * 10;
image1.at<Vec3b>(y, x) = Vec3b(c, c, c);
Vec3b color = image.at<Vec3b>(y, x);
Model.partHistogram[color[0] / Factor][color[1] / Factor][color[2] / Factor]++;
Model.sizeFG++;
}
}
}
}
partModels.emplace(pair<int32_t, ColorHistDetector::PartModel>(i, Model));
}
//Put results
int nBins = detector.nBins;
bool AllValuesEqual = true;
int delta = 2; // tolerable linear error
ofstream fout("TrainUnitTest_Output.txt");
fout << "\n--------------------------Don't equal----------------------\n";
cout << "\nTolerable error: " << delta << endl;
fout << "Tolerable error: " << delta << endl;
for (int i = 0; i < partModels.size(); i++)
{
for (int r = 0; r < nBins; r++)
for (int g = 0; g < nBins; g++)
for (int b = 0; b < nBins; b++)
{
int expected = int(partModels[i].partHistogram[b][g][r]);
int actual = int(detector.partModels[i].partHistogram[r][g][b] * detector.partModels[i].sizeFG / KeyframesCount);
if (abs(expected - actual) > delta)
{
cout << "Part[" << i << "]." << "Histogram[" << r << ", " << g << ", " << b << "]: Expected = " << expected << ", Actual = " << actual << endl;
fout << "Part[" << i << "]." << "Histogram[" << r << ", " << g << ", " << b << "]: Expected = " << expected << ", Actual = " << actual << endl;
if (!(r*g*b == 0)) AllValuesEqual = false;
}
//.........这里部分代码省略.........