#include "imesh_project.h"
#include <imesh/imesh_operations.h>
#include <imesh/algo/imesh_intersect.h>
#include <vgl/vgl_point_2d.h>
#include <vgl/vgl_homg_point_2d.h>
#include <vgl/vgl_homg_point_3d.h>
#include <vgl/vgl_vector_3d.h>
#include <vgl/vgl_plane_3d.h>
#include <vgl/vgl_line_3d_2_points.h>
#include <vgl/vgl_triangle_test.h>
#include <vgl/vgl_intersection.h>
#include <vgl/vgl_distance.h>
#include <vgl/vgl_triangle_scan_iterator.h>
#include <vcl_algorithm.h>
#include <vcl_limits.h>
#include <vcl_cmath.h>
#include <vcl_cassert.h>
Go to the source code of this file.
Functions | |
void | imesh_project_verts (const imesh_vertex_array< 3 > &verts3d, const vpgl_proj_camera< double > &camera, vcl_vector< vgl_point_2d< double > > &verts2d) |
project the 3D vertices into 2D using the camera. | |
void | imesh_project_verts (const vcl_vector< vgl_point_3d< double > > &verts3d, const vpgl_proj_camera< double > &camera, vcl_vector< vgl_point_2d< double > > &verts2d) |
project the 3D vertices into 2D using the camera. | |
void | imesh_project_verts (const vcl_vector< vgl_point_3d< double > > &verts3d, const vpgl_proj_camera< double > &camera, vcl_vector< vgl_point_2d< double > > &verts2d, vcl_vector< double > &depths) |
project the 3D vertices into 2D vertices and depths using the camera. | |
void | imesh_project_verts (const imesh_vertex_array< 3 > &verts3d, const vpgl_proj_camera< double > &camera, vcl_vector< vgl_point_2d< double > > &verts2d, vcl_vector< double > &depths) |
project the 3D mesh vertices into 2D vertices and depths using the camera. | |
void | imesh_distort_verts (const vcl_vector< vgl_point_2d< double > > &in_verts, const bpgl_lens_distortion< double > &lens, vcl_vector< vgl_point_2d< double > > &out_verts) |
distort the 2D vertices using the lens. | |
void | imesh_render_triangle (const vgl_point_2d< double > &v1, const vgl_point_2d< double > &v2, const vgl_point_2d< double > &v3, vil_image_view< bool > &image) |
Render a triangle defined by its vertices. | |
void | imesh_render_triangle_interp (const vgl_point_2d< double > &v1, const vgl_point_2d< double > &v2, const vgl_point_2d< double > &v3, const double &i1, const double &i2, const double &i3, vil_image_view< double > &image) |
Render a triangle defined by its vertices. | |
void | imesh_render_triangles (const imesh_regular_face_array< 3 > &tris, const vcl_vector< vgl_point_2d< double > > &img_verts, vil_image_view< bool > &image) |
void | imesh_render_faces (const imesh_mesh &mesh, const vcl_vector< vgl_point_2d< double > > &img_verts, vil_image_view< bool > &image) |
void | imesh_render_triangles_interp (const imesh_regular_face_array< 3 > &tris, const vcl_vector< vgl_point_2d< double > > &img_verts, const vcl_vector< double > &vals, vil_image_view< double > &image) |
Render the faces of the mesh into the image by interpolating the values at the vertices. | |
void | imesh_render_faces_interp (const imesh_mesh &mesh, const vcl_vector< vgl_point_2d< double > > &img_verts, const vcl_vector< double > &vals, vil_image_view< double > &image) |
Triangulates the faces and then calls imesh_render_triangles_interp. | |
void | imesh_project (const imesh_mesh &mesh, const vpgl_proj_camera< double > &camera, const bpgl_lens_distortion< double > &lens, vil_image_view< bool > &image) |
project the mesh onto the image plane using the camera and lens distortion. | |
void | imesh_project (const imesh_mesh &mesh, const vcl_vector< vgl_vector_3d< double > > &normals, const vpgl_proj_camera< double > &camera, const bpgl_lens_distortion< double > &lens, vil_image_view< bool > &image, vgl_box_2d< unsigned int > *bbox) |
project the front-facing triangles of the mesh onto the image plane. | |
void | imesh_project (const imesh_mesh &mesh, const vpgl_proj_camera< double > &camera, vil_image_view< bool > &image) |
project the mesh onto the image plane using the camera. | |
void | imesh_project_depth (const imesh_mesh &mesh, const vpgl_proj_camera< double > &camera, vil_image_view< double > &image) |
project the mesh onto the image plane using the camera. | |
void | imesh_projection_bounds (const vcl_vector< vgl_point_2d< double > > &img_pts, vgl_box_2d< unsigned int > &bbox) |
Compute the bounds of the projection of a set of image points. | |
int | imesh_project_onto_mesh (const imesh_mesh &mesh, const vcl_vector< vgl_vector_3d< double > > &normals, const vcl_vector< vgl_point_2d< double > > &verts2d, const vpgl_perspective_camera< double > &camera, const vgl_point_2d< double > &pt_2d, vgl_point_3d< double > &pt_3d) |
back project an image point onto the mesh using the camera. | |
void | imesh_project_onto_mesh (const imesh_mesh &mesh, const vcl_vector< vgl_vector_3d< double > > &normals, const vpgl_perspective_camera< double > &camera, const vcl_vector< vgl_point_2d< double > > &pts_2d, vcl_vector< unsigned int > &idx_2d, vcl_vector< vgl_point_3d< double > > &pts_3d) |
back project image points onto the mesh using the camera. | |
int | imesh_project_onto_mesh_barycentric (const imesh_mesh &mesh, const vcl_vector< vgl_vector_3d< double > > &normals, const vcl_vector< vgl_point_2d< double > > &verts2d, const vpgl_perspective_camera< double > &camera, const vgl_point_2d< double > &pt_img, vgl_point_2d< double > &pt_bary) |
back project an image point onto the mesh using the camera. | |
int | imesh_project_onto_mesh_texture (const imesh_mesh &mesh, const vcl_vector< vgl_point_2d< double > > &verts2d, const vpgl_perspective_camera< double > &camera, const vgl_point_2d< double > &pt_img, vgl_point_2d< double > &pt_uv) |
back project an image point onto the mesh using the camera. | |
int | imesh_project_texture_to_barycentric (const imesh_mesh &mesh, const vgl_point_2d< double > &pt_2d, vgl_point_2d< double > &pt_uv) |
project a texture point onto a mesh face index with barycentric coordinates. | |
bool | imesh_project_texture_to_barycentric (const imesh_mesh &mesh, const vcl_vector< vgl_point_2d< double > > &pts_2d, vcl_vector< vgl_point_2d< double > > &pts_uv, vcl_vector< unsigned long > &idxs, vcl_vector< int > &map_back) |
project a texture polygon into barycentric coordinates. | |
vnl_matrix_fixed< double, 3, 3 > | imesh_project_texture_to_3d_map (const imesh_mesh &mesh, unsigned int tidx) |
compute the matrix that maps texture points to 3-d for a given triangle index. | |
vnl_matrix_fixed< double, 3, 3 > | imesh_affine_map (const vgl_point_2d< double > &a1, const vgl_point_2d< double > &b1, const vgl_point_2d< double > &c1, const vgl_point_2d< double > &a2, const vgl_point_2d< double > &b2, const vgl_point_2d< double > &c2) |
compute the affine matrix that maps triangle (a1,b1,c1) to (a2,b2,c2). | |
vgl_point_2d< double > | imesh_project_barycentric_to_texture (const imesh_mesh &mesh, const vgl_point_2d< double > &pt_uv, unsigned int idx) |
project barycentric coordinates with an index to texture space. | |
vgl_point_3d< double > | imesh_project_barycentric_to_mesh (const imesh_mesh &mesh, const vgl_point_2d< double > &pt_uv, unsigned int idx) |
project barycentric coordinates with an index the mesh surface (3D). |
Definition in file imesh_project.cxx.
vnl_matrix_fixed<double,3,3> imesh_affine_map | ( | const vgl_point_2d< double > & | a1, |
const vgl_point_2d< double > & | b1, | ||
const vgl_point_2d< double > & | c1, | ||
const vgl_point_2d< double > & | a2, | ||
const vgl_point_2d< double > & | b2, | ||
const vgl_point_2d< double > & | c2 | ||
) |
compute the affine matrix that maps triangle (a1,b1,c1) to (a2,b2,c2).
Definition at line 926 of file imesh_project.cxx.
void imesh_distort_verts | ( | const vcl_vector< vgl_point_2d< double > > & | in_verts, |
const bpgl_lens_distortion< double > & | lens, | ||
vcl_vector< vgl_point_2d< double > > & | out_verts | ||
) |
distort the 2D vertices using the lens.
Definition at line 79 of file imesh_project.cxx.
void imesh_project | ( | const imesh_mesh & | mesh, |
const vpgl_proj_camera< double > & | camera, | ||
const bpgl_lens_distortion< double > & | lens, | ||
vil_image_view< bool > & | image | ||
) |
project the mesh onto the image plane using the camera and lens distortion.
Set each pixel of the image to true if the mesh project onto it
Definition at line 224 of file imesh_project.cxx.
void imesh_project | ( | const imesh_mesh & | mesh, |
const vcl_vector< vgl_vector_3d< double > > & | normals, | ||
const vpgl_proj_camera< double > & | camera, | ||
const bpgl_lens_distortion< double > & | lens, | ||
vil_image_view< bool > & | image, | ||
vgl_box_2d< unsigned int > * | bbox | ||
) |
project the front-facing triangles of the mesh onto the image plane.
Using the camera and lens distortion Set each pixel of the image to true if the mesh projects onto it
Definition at line 242 of file imesh_project.cxx.
void imesh_project | ( | const imesh_mesh & | mesh, |
const vpgl_proj_camera< double > & | camera, | ||
vil_image_view< bool > & | image | ||
) |
project the mesh onto the image plane using the camera.
Set each pixel of the image to true if the mesh projects onto it
Definition at line 295 of file imesh_project.cxx.
vgl_point_3d<double> imesh_project_barycentric_to_mesh | ( | const imesh_mesh & | mesh, |
const vgl_point_2d< double > & | pt_uv, | ||
unsigned int | idx | ||
) |
project barycentric coordinates with an index the mesh surface (3D).
idx | is the face index |
Definition at line 977 of file imesh_project.cxx.
vgl_point_2d<double> imesh_project_barycentric_to_texture | ( | const imesh_mesh & | mesh, |
const vgl_point_2d< double > & | pt_uv, | ||
unsigned int | idx | ||
) |
project barycentric coordinates with an index to texture space.
idx | is the face index |
Definition at line 959 of file imesh_project.cxx.
void imesh_project_depth | ( | const imesh_mesh & | mesh, |
const vpgl_proj_camera< double > & | camera, | ||
vil_image_view< double > & | image | ||
) |
project the mesh onto the image plane using the camera.
Set each pixel of the image to the depth to the mesh
Definition at line 308 of file imesh_project.cxx.
int imesh_project_onto_mesh | ( | const imesh_mesh & | mesh, |
const vcl_vector< vgl_vector_3d< double > > & | normals, | ||
const vcl_vector< vgl_point_2d< double > > & | verts2d, | ||
const vpgl_perspective_camera< double > & | camera, | ||
const vgl_point_2d< double > & | pt_2d, | ||
vgl_point_3d< double > & | pt_3d | ||
) |
back project an image point onto the mesh using the camera.
Return true if the ray intersects the mesh
Definition at line 353 of file imesh_project.cxx.
void imesh_project_onto_mesh | ( | const imesh_mesh & | mesh, |
const vcl_vector< vgl_vector_3d< double > > & | normals, | ||
const vpgl_perspective_camera< double > & | camera, | ||
const vcl_vector< vgl_point_2d< double > > & | pts_2d, | ||
vcl_vector< unsigned int > & | idx_2d, | ||
vcl_vector< vgl_point_3d< double > > & | pts_3d | ||
) |
back project image points onto the mesh using the camera.
Returns a vector of all valid 3d points and indices to corresponding 2d points
Definition at line 407 of file imesh_project.cxx.
int imesh_project_onto_mesh_barycentric | ( | const imesh_mesh & | mesh, |
const vcl_vector< vgl_vector_3d< double > > & | normals, | ||
const vcl_vector< vgl_point_2d< double > > & | verts2d, | ||
const vpgl_perspective_camera< double > & | camera, | ||
const vgl_point_2d< double > & | pt_img, | ||
vgl_point_2d< double > & | pt_bary | ||
) |
back project an image point onto the mesh using the camera.
The resulting point is in barycentric coordinates for the returned triangle Returns the index of the intersected triangle, or -1 for no intersection
Definition at line 465 of file imesh_project.cxx.
int imesh_project_onto_mesh_texture | ( | const imesh_mesh & | mesh, |
const vcl_vector< vgl_point_2d< double > > & | verts2d, | ||
const vpgl_perspective_camera< double > & | camera, | ||
const vgl_point_2d< double > & | pt_img, | ||
vgl_point_2d< double > & | pt_uv | ||
) |
back project an image point onto the mesh using the camera.
Then project from the mesh into normalized texture coordinate (UV) Assumes the mesh has both normals and texture coordinates
Definition at line 495 of file imesh_project.cxx.
vnl_matrix_fixed<double,3,3> imesh_project_texture_to_3d_map | ( | const imesh_mesh & | mesh, |
unsigned int | tidx | ||
) |
compute the matrix that maps texture points to 3-d for a given triangle index.
maps into 3-d
Definition at line 886 of file imesh_project.cxx.
int imesh_project_texture_to_barycentric | ( | const imesh_mesh & | mesh, |
const vgl_point_2d< double > & | pt_2d, | ||
vgl_point_2d< double > & | pt_uv | ||
) |
project a texture point onto a mesh face index with barycentric coordinates.
Definition at line 542 of file imesh_project.cxx.
bool imesh_project_texture_to_barycentric | ( | const imesh_mesh & | mesh, |
const vcl_vector< vgl_point_2d< double > > & | pts_2d, | ||
vcl_vector< vgl_point_2d< double > > & | pts_uv, | ||
vcl_vector< unsigned long > & | idxs, | ||
vcl_vector< int > & | map_back | ||
) |
project a texture polygon into barycentric coordinates.
Definition at line 781 of file imesh_project.cxx.
void imesh_project_verts | ( | const imesh_vertex_array< 3 > & | verts3d, |
const vpgl_proj_camera< double > & | camera, | ||
vcl_vector< vgl_point_2d< double > > & | verts2d | ||
) |
project the 3D vertices into 2D using the camera.
Definition at line 26 of file imesh_project.cxx.
void imesh_project_verts | ( | const vcl_vector< vgl_point_3d< double > > & | verts3d, |
const vpgl_proj_camera< double > & | camera, | ||
vcl_vector< vgl_point_2d< double > > & | verts2d | ||
) |
project the 3D vertices into 2D using the camera.
Definition at line 36 of file imesh_project.cxx.
void imesh_project_verts | ( | const vcl_vector< vgl_point_3d< double > > & | verts3d, |
const vpgl_proj_camera< double > & | camera, | ||
vcl_vector< vgl_point_2d< double > > & | verts2d, | ||
vcl_vector< double > & | depths | ||
) |
project the 3D vertices into 2D vertices and depths using the camera.
Definition at line 47 of file imesh_project.cxx.
void imesh_project_verts | ( | const imesh_vertex_array< 3 > & | verts3d, |
const vpgl_proj_camera< double > & | camera, | ||
vcl_vector< vgl_point_2d< double > > & | verts2d, | ||
vcl_vector< double > & | depths | ||
) |
project the 3D mesh vertices into 2D vertices and depths using the camera.
Definition at line 63 of file imesh_project.cxx.
void imesh_projection_bounds | ( | const vcl_vector< vgl_point_2d< double > > & | img_pts, |
vgl_box_2d< unsigned int > & | bbox | ||
) |
Compute the bounds of the projection of a set of image points.
The returned bounds are the intersection of the input bounds and the bounding box of the points
Definition at line 324 of file imesh_project.cxx.
void imesh_render_faces | ( | const imesh_mesh & | mesh, |
const vcl_vector< vgl_point_2d< double > > & | img_verts, | ||
vil_image_view< bool > & | image | ||
) |
Definition at line 166 of file imesh_project.cxx.
void imesh_render_faces_interp | ( | const imesh_mesh & | mesh, |
const vcl_vector< vgl_point_2d< double > > & | img_verts, | ||
const vcl_vector< double > & | vals, | ||
vil_image_view< double > & | image | ||
) |
Triangulates the faces and then calls imesh_render_triangles_interp.
Definition at line 203 of file imesh_project.cxx.
void imesh_render_triangle | ( | const vgl_point_2d< double > & | v1, |
const vgl_point_2d< double > & | v2, | ||
const vgl_point_2d< double > & | v3, | ||
vil_image_view< bool > & | image | ||
) |
Render a triangle defined by its vertices.
Definition at line 90 of file imesh_project.cxx.
void imesh_render_triangle_interp | ( | const vgl_point_2d< double > & | v1, |
const vgl_point_2d< double > & | v2, | ||
const vgl_point_2d< double > & | v3, | ||
const double & | i1, | ||
const double & | i2, | ||
const double & | i3, | ||
vil_image_view< double > & | image | ||
) |
Render a triangle defined by its vertices.
Definition at line 116 of file imesh_project.cxx.
void imesh_render_triangles | ( | const imesh_regular_face_array< 3 > & | tris, |
const vcl_vector< vgl_point_2d< double > > & | img_verts, | ||
vil_image_view< bool > & | image | ||
) |
Definition at line 152 of file imesh_project.cxx.
void imesh_render_triangles_interp | ( | const imesh_regular_face_array< 3 > & | tris, |
const vcl_vector< vgl_point_2d< double > > & | img_verts, | ||
const vcl_vector< double > & | vals, | ||
vil_image_view< double > & | image | ||
) |
Render the faces of the mesh into the image by interpolating the values at the vertices.
The minimum value is kept at each pixel (as in computing a depth map)
Definition at line 185 of file imesh_project.cxx.