A Superimpose derived class to superimpose mesh models on images. More...
#include <SICAD.h>
Public Types | |
enum | MIPMaps { MIPMaps::nearest, MIPMaps::linear } |
typedef std::unordered_map< std::string, std::string > | ModelPathContainer |
typedef std::pair< std::string, std::string > | ModelPathElement |
typedef std::unordered_map< std::string, Model * > | ModelContainer |
typedef std::pair< std::string, Model * > | ModelElement |
typedef std::vector< double > | ModelPose |
typedef std::multimap< std::string, ModelPose > | ModelPoseContainer |
typedef std::pair< std::string, ModelPose > | ModelPoseContainerElement |
Public Member Functions | |
SICAD (const ModelPathContainer &objfile_map, const GLsizei cam_width, const GLsizei cam_height, const GLfloat cam_fx, const GLfloat cam_fy, const GLfloat cam_cx, const GLfloat cam_cy) | |
Create a SICAD object with a dedicated OpenGL context and default shaders. More... | |
SICAD (const ModelPathContainer &objfile_map, const GLsizei cam_width, const GLsizei cam_height, const GLfloat cam_fx, const GLfloat cam_fy, const GLfloat cam_cx, const GLfloat cam_cy, const GLint num_images) | |
Create a SICAD object with a dedicated OpenGL context and default shaders. More... | |
SICAD (const ModelPathContainer &objfile_map, const GLsizei cam_width, const GLsizei cam_height, const GLfloat cam_fx, const GLfloat cam_fy, const GLfloat cam_cx, const GLfloat cam_cy, const GLint num_images, const std::string &shader_folder) | |
Create a SICAD object with a dedicated OpenGL context and custom shaders. More... | |
SICAD (const ModelPathContainer &objfile_map, const GLsizei cam_width, const GLsizei cam_height, const GLfloat cam_fx, const GLfloat cam_fy, const GLfloat cam_cx, const GLfloat cam_cy, const GLint num_images, const std::string &shader_folder, const std::vector< float > &ogl_to_cam) | |
Create a SICAD object with a dedicated OpenGL context and custom shaders. More... | |
virtual | ~SICAD () |
bool | getOglWindowShouldClose () |
void | setOglWindowShouldClose (bool should_close) |
bool | superimpose (const ModelPoseContainer &objpos_map, const double *cam_x, const double *cam_o, cv::Mat &img) override |
Render the mesh models in the pose specified in objpos_map and move the virtual camera in cam_x position with orientation cam_o . More... | |
virtual bool | superimpose (const std::vector< ModelPoseContainer > &objpos_multimap, const double *cam_x, const double *cam_o, cv::Mat &img) |
Render the mesh models in the pose specified in each element of objpos_multimap and move the virtual camera in cam_x position with orientation cam_o . More... | |
virtual bool | superimpose (const ModelPoseContainer &objpos_map, const double *cam_x, const double *cam_o, cv::Mat &img, const GLsizei cam_width, const GLsizei cam_height, const GLfloat cam_fx, const GLfloat cam_fy, const GLfloat cam_cx, const GLfloat cam_cy) |
virtual bool | superimpose (const std::vector< ModelPoseContainer > &objpos_multimap, const double *cam_x, const double *cam_o, cv::Mat &img, const GLsizei cam_width, const GLsizei cam_height, const GLfloat cam_fx, const GLfloat cam_fy, const GLfloat cam_cx, const GLfloat cam_cy) |
virtual bool | superimpose (const ModelPoseContainer &objpos_map, const double *cam_x, const double *cam_o, const size_t pbo_index) |
Render the mesh models in the pose specified in objpos_map and move the virtual camera in cam_x position with orientation cam_o . More... | |
virtual bool | superimpose (const ModelPoseContainer &objpos_map, const double *cam_x, const double *cam_o, const size_t pbo_index, const cv::Mat &img) |
Render the mesh models in the pose specified in objpos_map and move the virtual camera in cam_x position with orientation cam_o . More... | |
virtual bool | superimpose (const std::vector< ModelPoseContainer > &objpos_multimap, const double *cam_x, const double *cam_o, const size_t pbo_index) |
Render the mesh models in the pose specified in each element of objpos_multimap and move the virtual camera in cam_x position with orientation cam_o . More... | |
virtual bool | superimpose (const std::vector< ModelPoseContainer > &objpos_multimap, const double *cam_x, const double *cam_o, const size_t pbo_index, const cv::Mat &img) |
Render the mesh models in the pose specified in each element of objpos_multimap and move the virtual camera in cam_x position with orientation cam_o . More... | |
virtual void | releaseContext () const |
Make the current thread OpenGL context not current. More... | |
std::pair< const GLuint *, size_t > | getPBOs () const |
Returns the Pixel Buffer Object (PBO) vector and its size. More... | |
std::pair< bool, GLuint > | getPBO (const size_t pbo_index) const |
Returns pbo_index -th Pixel Buffer Object (PBO) value. More... | |
bool | setProjectionMatrix (const GLsizei cam_width, const GLsizei cam_height, const GLfloat cam_fx, const GLfloat cam_fy, const GLfloat cam_cx, const GLfloat cam_cy) |
bool | getBackgroundOpt () const |
void | setBackgroundOpt (bool show_background) |
GLenum | getWireframeOpt () const |
void | setWireframeOpt (bool show_mesh_wires) |
void | setMipmapsOpt (const MIPMaps &mipmaps) |
MIPMaps | getMipmapsOpt () const |
int | getTilesNumber () const |
int | getTilesRows () const |
int | getTilesCols () const |
Private Member Functions | |
glm::mat4 | getViewTransformationMatrix (const double *cam_x, const double *cam_o) |
void | pollOrPostEvent () |
void | renderBackground (const cv::Mat &img) const |
void | setWireframe (GLenum mode) |
void | factorize_int (const GLsizei area, const GLsizei width_limit, const GLsizei height_limit, GLsizei &width, GLsizei &height) |
Static Private Attributes | |
static int | class_counter_ = 0 |
static GLsizei | renderbuffer_size_ = 0 |
A Superimpose derived class to superimpose mesh models on images.
typedef std::unordered_map<std::string, Model*> SICAD::ModelContainer |
typedef std::pair<std::string, Model*> SICAD::ModelElement |
typedef std::unordered_map<std::string, std::string> SICAD::ModelPathContainer |
typedef std::pair<std::string, std::string> SICAD::ModelPathElement |
|
inherited |
Definition at line 23 of file Superimpose.h.
|
inherited |
Definition at line 25 of file Superimpose.h.
|
inherited |
Definition at line 27 of file Superimpose.h.
|
strong |
SICAD::SICAD | ( | const ModelPathContainer & | objfile_map, |
const GLsizei | cam_width, | ||
const GLsizei | cam_height, | ||
const GLfloat | cam_fx, | ||
const GLfloat | cam_fy, | ||
const GLfloat | cam_cx, | ||
const GLfloat | cam_cy | ||
) |
Create a SICAD object with a dedicated OpenGL context and default shaders.
Only 1 image will be rendered in the OpenGL context.
The reference frame of the OpenGL virtual camera is the standard right-handed system and can be changed by means of ogl_to_cam
parameter.
objfile_map | A (tag, path) container to associate a 'tag' to the mesh file specified in 'path'. |
cam_width | Camera or image width. |
cam_height | Camera or image height. |
cam_fx | focal Length along the x axis in pixels. |
cam_fy | focal Length along the y axis in pixels. |
SICAD::SICAD | ( | const ModelPathContainer & | objfile_map, |
const GLsizei | cam_width, | ||
const GLsizei | cam_height, | ||
const GLfloat | cam_fx, | ||
const GLfloat | cam_fy, | ||
const GLfloat | cam_cx, | ||
const GLfloat | cam_cy, | ||
const GLint | num_images | ||
) |
Create a SICAD object with a dedicated OpenGL context and default shaders.
Up to num_images
images will be rendered in the same OpenGL context and the result of the process will be tiled up in a regular grid. This implies that the total number of rendered images may be less than or equal to the required num_images
. The total number of rendered images is chosen to optimize performance and accessibility and can be accessed through SICAD::getTilesNumber()
.
The reference frame of the OpenGL virtual camera is the standard right-handed system.
objfile_map | A (tag, path) container to associate a 'tag' to the mesh file specified in 'path'. |
cam_width | Camera or image width. |
cam_height | Camera or image height. |
cam_fx | focal Length along the x axis in pixels. |
cam_fy | focal Length along the y axis in pixels. |
num_images | Number of images (i.e. viewports) rendered in the same GL context. |
SICAD::SICAD | ( | const ModelPathContainer & | objfile_map, |
const GLsizei | cam_width, | ||
const GLsizei | cam_height, | ||
const GLfloat | cam_fx, | ||
const GLfloat | cam_fy, | ||
const GLfloat | cam_cx, | ||
const GLfloat | cam_cy, | ||
const GLint | num_images, | ||
const std::string & | shader_folder | ||
) |
Create a SICAD object with a dedicated OpenGL context and custom shaders.
The folder where the shaders are stored can be specified in shader_folder
.
The following shaders with this exact names are needed:
shader_model.vert
for the vertex shader for mesh modelsshader_model.frag
for the fragment shader for mesh modelsshader_model_texture.frag
for the fragment shader for textured mesh modelsshader_frame.vert
for the vertex shader for reference framesshader_frame.frag
for the fragment shader for reference framesshader_background.vert
for the vertex shader for backgroundshader_background.frag
for the fragment shader for backgroundUp to num_images
images will be rendered in the same OpenGL context and the result of the process will be tiled up in a regular grid. This implies that the total number of rendered images may be less than or equal to the required num_images
. The total number of rendered images is chosen to optimize performance and accessibility and can be accessed through SICAD::getTilesNumber()
.
The reference frame of the OpenGL virtual camera is the standard right-handed system.
objfile_map | A (tag, path) container to associate a 'tag' to the mesh file specified in 'path'. |
cam_width | Camera or image width. |
cam_height | Camera or image height. |
cam_fx | focal Length along the x axis in pixels. |
cam_fy | focal Length along the y axis in pixels. |
num_images | Number of images (i.e. viewports) rendered in the same GL context. |
shader_folder | Path to the folder containing the above-mentioned required shaders. |
SICAD::SICAD | ( | const ModelPathContainer & | objfile_map, |
const GLsizei | cam_width, | ||
const GLsizei | cam_height, | ||
const GLfloat | cam_fx, | ||
const GLfloat | cam_fy, | ||
const GLfloat | cam_cx, | ||
const GLfloat | cam_cy, | ||
const GLint | num_images, | ||
const std::string & | shader_folder, | ||
const std::vector< float > & | ogl_to_cam | ||
) |
Create a SICAD object with a dedicated OpenGL context and custom shaders.
The folder where the shaders are stored can be specified in shader_folder
.
The following shaders with this exact names are needed:
shader_model.vert
for the vertex shader for mesh modelsshader_model.frag
for the fragment shader for mesh modelsshader_model_texture.frag
for the fragment shader for textured mesh modelsshader_frame.vert
for the vertex shader for reference framesshader_frame.frag
for the fragment shader for reference framesshader_background.vert
for the vertex shader for backgroundshader_background.frag
for the fragment shader for backgroundUp to num_images
images will be rendered in the same OpenGL context and the result of the process will be tiled up in a regular grid. This implies that the total number of rendered images may be less than or equal to the required num_images
. The total number of rendered images is chosen to optimize performance and accessibility and can be accessed through SICAD::getTilesNumber()
.
The reference frame of the OpenGL virtual camera is the standard right-handed system and can be changed by means of ogl_to_cam
.
objfile_map | A (tag, path) container to associate a 'tag' to the mesh file specified in 'path'. |
cam_width | Camera or image width. |
cam_height | Camera or image height. |
cam_fx | focal Length along the x axis in pixels. |
cam_fy | focal Length along the y axis in pixels. |
num_images | Number of images (i.e. viewports) rendered in the same GL context. |
shader_folder | Path to the folder containing the above-mentioned required shaders. |
ogl_to_cam | A 7-component pose vector, (x, y, z) position and a (ux, uy, uz, theta) axis-angle orientation, defining a camera rotation applied to the OpenGL camera. |
|
virtual |
Definition at line 399 of file SICAD.cpp.
References class_counter_, ebo_background_, fbo_, log_ID_, model_obj_, pbo_, shader_background_, shader_cad_, shader_frame_, texture_background_, texture_color_buffer_, texture_depth_buffer_, vao_background_, vao_frame_, vbo_background_, vbo_frame_, and window_.
|
private |
bool SICAD::getBackgroundOpt | ( | ) | const |
Definition at line 1297 of file SICAD.cpp.
References show_background_.
SICAD::MIPMaps SICAD::getMipmapsOpt | ( | ) | const |
Definition at line 1322 of file SICAD.cpp.
References mesh_mmaps_.
Referenced by renderBackground().
bool SICAD::getOglWindowShouldClose | ( | ) |
std::pair< bool, GLuint > SICAD::getPBO | ( | const size_t | pbo_index | ) | const |
Returns pbo_index
-th Pixel Buffer Object (PBO) value.
pbo_index
-th PBO and, in order to use it, the OpenGL context must remain current. As a consequence, once you are done working with the pbo_index
-th PBO and before invoking again any other SICAD::superimpose()
function, you must invoke SICAD::releaseContext()
.pbo_index
exists, (false, 0) otherwise. Definition at line 1220 of file SICAD.cpp.
References pbo_, pbo_number_, and window_.
std::pair< const GLuint *, size_t > SICAD::getPBOs | ( | ) | const |
Returns the Pixel Buffer Object (PBO) vector and its size.
pbo_index
-th PBO and, in order to use it, the OpenGL context must remain current. As a consequence, once you are done working with the pbo_index
-th PBO and before invoking again any other SICAD::superimpose()
function, you must invoke SICAD::releaseContext()
.Definition at line 1212 of file SICAD.cpp.
References pbo_, pbo_number_, and window_.
int SICAD::getTilesCols | ( | ) | const |
Definition at line 1340 of file SICAD.cpp.
References tiles_cols_.
int SICAD::getTilesNumber | ( | ) | const |
Definition at line 1328 of file SICAD.cpp.
References tiles_cols_, and tiles_rows_.
int SICAD::getTilesRows | ( | ) | const |
Definition at line 1334 of file SICAD.cpp.
References tiles_rows_.
|
private |
Definition at line 1346 of file SICAD.cpp.
References ogl_to_cam_.
GLenum SICAD::getWireframeOpt | ( | ) | const |
Definition at line 1316 of file SICAD.cpp.
References show_mesh_mode_.
|
private |
Definition at line 1361 of file SICAD.cpp.
References main_thread_id_.
Referenced by setOglWindowShouldClose().
|
virtual |
Make the current thread OpenGL context not current.
SICAD::superimpose()
working on Pixel Buffer Objects (PBO), before invoking again any SICAD::superimpose()
methods (either the ones using PBOs or not), but after having used the PBO that otherwise cannot be accessed as they are bound to the current thread context.
|
private |
Definition at line 1370 of file SICAD.cpp.
References back_proj_, Shader::get_program(), getMipmapsOpt(), Shader::install(), linear, nearest, shader_background_, texture_background_, Shader::uninstall(), and vao_background_.
void SICAD::setBackgroundOpt | ( | bool | show_background | ) |
void SICAD::setMipmapsOpt | ( | const MIPMaps & | mipmaps | ) |
Definition at line 1310 of file SICAD.cpp.
References mesh_mmaps_.
void SICAD::setOglWindowShouldClose | ( | bool | should_close | ) |
Definition at line 455 of file SICAD.cpp.
References pollOrPostEvent(), and window_.
bool SICAD::setProjectionMatrix | ( | const GLsizei | cam_width, |
const GLsizei | cam_height, | ||
const GLfloat | cam_fx, | ||
const GLfloat | cam_fy, | ||
const GLfloat | cam_cx, | ||
const GLfloat | cam_cy | ||
) |
void SICAD::setWireframeOpt | ( | bool | show_mesh_wires | ) |
Definition at line 1303 of file SICAD.cpp.
References show_mesh_mode_.
|
overridevirtual |
Render the mesh models in the pose specified in objpos_map
and move the virtual camera in cam_x
position with orientation cam_o
.
The method then creates an image of the mesh models as they are seen by the virtual camera.
img
is a background image it must be of size cam_width * cam_height
, as specified during object construction, and the SICAD::setBackgroundOpt(bool show_background)
must have been invoked with true
.objpos_map | A (tag, pose) container to associate a 7-component pose , (x, y, z) position and a (ux, uy, uz, theta) axis-angle orientation, to a mesh with tag 'tag'. |
cam_x | (x, y, z) position. |
cam_o | (ux, uy, uz, theta) axis-angle orientation. |
img | An image representing the result of the superimposition. The variable is automatically resized if its size is not correct to store the entire result of the superimposition. |
Implements Superimpose.
Definition at line 464 of file SICAD.cpp.
Referenced by main().
|
virtual |
Render the mesh models in the pose specified in each element of objpos_multimap
and move the virtual camera in cam_x
position with orientation cam_o
.
Each group of meshes specified by the elements of objpos_multimap
are rendered in a different viewport. Each viewport reports the mesh models as they are seen by the virtual camera. The method then creates a single image tiling the viewports in a regular grid.
getTilesRows()
and getTilesCols()
.img
is a background image it must be of size cam_width * cam_height
, as specified during object construction, and the SICAD::setBackgroundOpt(bool show_background)
must have been invoked with true
.objpos_map | A (tag, pose) container to associate a 7-component pose , (x, y, z) position and a (ux, uy, uz, theta) axis-angle orientation, to a mesh with tag 'tag'. |
cam_x | (x, y, z) position. |
cam_o | (ux, uy, uz, theta) axis-angle orientation. |
img | An image representing the result of the superimposition. The variable is automatically resized if its size is not correct to store the entire result of the superimposition. |
|
virtual |
|
virtual |
|
virtual |
Render the mesh models in the pose specified in objpos_map
and move the virtual camera in cam_x
position with orientation cam_o
.
The method then stores the pixels of the mesh models as they are seen by the virtual camera in the pbo_index
-th Pixel Buffer Object (PBO).
pbo_index
-th PBO and, in order to use it, the OpenGL context must remain current. As a consequence, once you are done working with the pbo_index
-th PBO (can be accessed by means of SICAD::getPBO(pbo_index)
) and before invoking again any other SICAD::superimpose()
function, you must invoke SICAD::releaseContext()
.objpos_map | A (tag, pose) container to associate a 7-component pose , (x, y, z) position and a (ux, uy, uz, theta) axis-angle orientation, to a mesh with tag 'tag'. |
cam_x | (x, y, z) position. |
cam_o | (ux, uy, uz, theta) axis-angle orientation. |
pbo_index | The index of the PBO where the pixel are stored. |
|
virtual |
Render the mesh models in the pose specified in objpos_map
and move the virtual camera in cam_x
position with orientation cam_o
.
The method then stores the pixels of the mesh models as they are seen by the virtual camera in the pbo_index
-th Pixel Buffer Object (PBO).
img
must be of size cam_width * cam_height
, as specified during object construction, and the SICAD::setBackgroundOpt(bool show_background)
must have been invoked with true
.objpos_map | A (tag, pose) container to associate a 7-component pose , (x, y, z) position and a (ux, uy, uz, theta) axis-angle orientation, to a mesh with tag 'tag'. |
cam_x | (x, y, z) position. |
cam_o | (ux, uy, uz, theta) axis-angle orientation. |
pbo_index | The index of the PBO where the pixel are stored. |
img | A background image. |
|
virtual |
Render the mesh models in the pose specified in each element of objpos_multimap
and move the virtual camera in cam_x
position with orientation cam_o
.
Each group of meshes specified by the elements of objpos_multimap
are rendered in a different viewport. Each viewport reports the mesh models as they are seen by the virtual camera. The method then stores the pixels of the viewports in the pbo_index
-th Pixel Buffer Object (PBO) by tiling them in a regular grid.
pbo_index
-th PBO and, in order to use it, the OpenGL context must remain current. As a consequence, once you are done working with the pbo_index
-th PBO (can be accessed by means of SICAD::getPBO(pbo_index)
) and before invoking again any other SICAD::superimpose()
function, you must invoke SICAD::releaseContext()
.getTilesRows()
and getTilesCols()
.objpos_map | A (tag, pose) container to associate a 7-component pose , (x, y, z) position and a (ux, uy, uz, theta) axis-angle orientation, to a mesh with tag 'tag'. |
cam_x | (x, y, z) position. |
cam_o | (ux, uy, uz, theta) axis-angle orientation. |
pbo_index | The index of the PBO where the pixel are stored. |
|
virtual |
Render the mesh models in the pose specified in each element of objpos_multimap
and move the virtual camera in cam_x
position with orientation cam_o
.
Each group of meshes specified by the elements of objpos_multimap
are rendered in a different viewport. Each viewport reports the mesh models as they are seen by the virtual camera. The method then stores the pixels of the viewports in the pbo_index
-th Pixel Buffer Object (PBO) by tiling them in a regular grid.
getTilesRows()
and getTilesCols()
.img
must be of size cam_width * cam_height
, as specified during object construction, and the SICAD::setBackgroundOpt(bool show_background)
must have been invoked with true
.objpos_map | A (tag, pose) container to associate a 7-component pose , (x, y, z) position and a (ux, uy, uz, theta) axis-angle orientation, to a mesh with tag 'tag'. |
cam_x | (x, y, z) position. |
cam_o | (ux, uy, uz, theta) axis-angle orientation. |
pbo_index | The index of the PBO where the pixel are stored. |
img | A background image. |
|
private |
Definition at line 404 of file SICAD.h.
Referenced by renderBackground().
|
staticprivate |
|
private |
|
private |
|
private |
Definition at line 364 of file SICAD.h.
Referenced by pollOrPostEvent().
|
private |
Definition at line 370 of file SICAD.h.
Referenced by getMipmapsOpt(), and setMipmapsOpt().
|
private |
|
private |
Definition at line 350 of file SICAD.h.
Referenced by getViewTransformationMatrix().
|
private |
|
private |
|
private |
Definition at line 372 of file SICAD.h.
Referenced by renderBackground(), and ~SICAD().
|
private |
|
private |
|
private |
Definition at line 366 of file SICAD.h.
Referenced by getBackgroundOpt(), and setBackgroundOpt().
|
private |
Definition at line 368 of file SICAD.h.
Referenced by getWireframeOpt(), and setWireframeOpt().
|
private |
Definition at line 388 of file SICAD.h.
Referenced by renderBackground(), and ~SICAD().
|
private |
|
private |
|
private |
Definition at line 342 of file SICAD.h.
Referenced by getTilesCols(), and getTilesNumber().
|
private |
Definition at line 344 of file SICAD.h.
Referenced by getTilesNumber(), and getTilesRows().
|
private |
Definition at line 390 of file SICAD.h.
Referenced by renderBackground(), and ~SICAD().
|
private |
|
private |
Definition at line 338 of file SICAD.h.
Referenced by getOglWindowShouldClose(), getPBO(), getPBOs(), setOglWindowShouldClose(), and ~SICAD().