1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| void ImageWarping::GetTriangleVertices(const Subdiv2D& sub_div, const vector<Point2f>& points, vector<Vec3i>& triangle_vertices)
{
vector<Vec6f> triangles;
sub_div.getTriangleList(triangles);
int num_triangles = triangles.size();
triangle_vertices.clear();
triangle_vertices.reserve(num_triangles);
for (int i = 0; i<num_triangles; i++){
vector<Point2f>::const_iterator vert1, vert2, vert3;
vert1 = find(points.begin(), points.end(), Point2f(triangles[i][0], triangles[i][1]));
vert2 = find(points.begin(), points.end(), Point2f(triangles[i][2], triangles[i][3]));
vert3 = find(points.begin(), points.end(), Point2f(triangles[i][4], triangles[i][5]));
Vec3i vertex;
if (vert1 != points.end() && vert2 != points.end() && vert3 != points.end()){
vertex[0] = vert1 - points.begin();
vertex[1] = vert2 - points.begin();
vertex[2] = vert3 - points.begin();
triangle_vertices.push_back(vertex);
}
}
}
|