SuperimposeMesh
All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SICAD Class Reference

A Superimpose derived class to superimpose mesh models on images. More...

#include <SICAD.h>

Inheritance diagram for SICAD:
[legend]

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, ModelPoseModelPoseContainer
 
typedef std::pair< std::string, ModelPoseModelPoseContainerElement
 

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)
 

Private Attributes

const std::string log_ID_ = "[SI::SICAD]"
 
GLFWwindow * window_ = nullptr
 
GLint tiles_num_ = 0
 
GLsizei tiles_cols_ = 0
 
GLsizei tiles_rows_ = 0
 
GLsizei image_width_ = 0
 
GLsizei image_height_ = 0
 
glm::mat3 ogl_to_cam_ = glm::mat3(1.0f)
 
GLsizei framebuffer_width_ = 0
 
GLsizei framebuffer_height_ = 0
 
GLsizei tile_img_width_ = 0
 
GLsizei tile_img_height_ = 0
 
const GLfloat near_ = 0.001f
 
const GLfloat far_ = 1000.0f
 
std::thread::id main_thread_id_
 
bool show_background_ = false
 
GLenum show_mesh_mode_ = GL_FILL
 
MIPMaps mesh_mmaps_ = MIPMaps::nearest
 
Shadershader_background_ = nullptr
 
Shadershader_cad_ = nullptr
 
std::unique_ptr< Shadershader_mesh_texture_
 
Shadershader_frame_ = nullptr
 
ModelContainer model_obj_
 
GLuint fbo_
 
GLuint texture_color_buffer_
 
GLuint texture_depth_buffer_
 
GLuint texture_background_
 
GLuint vao_background_
 
GLuint ebo_background_
 
GLuint vbo_background_
 
GLuint vao_frame_
 
GLuint vbo_frame_
 
size_t pbo_number_ = 2
 
GLuint pbo_ [2]
 
glm::mat4 back_proj_
 
glm::mat4 projection_
 

Static Private Attributes

static int class_counter_ = 0
 
static GLsizei renderbuffer_size_ = 0
 

Detailed Description

A Superimpose derived class to superimpose mesh models on images.

Definition at line 30 of file SICAD.h.

Member Typedef Documentation

◆ ModelContainer

typedef std::unordered_map<std::string, Model*> SICAD::ModelContainer

Definition at line 37 of file SICAD.h.

◆ ModelElement

typedef std::pair<std::string, Model*> SICAD::ModelElement

Definition at line 39 of file SICAD.h.

◆ ModelPathContainer

typedef std::unordered_map<std::string, std::string> SICAD::ModelPathContainer

Definition at line 33 of file SICAD.h.

◆ ModelPathElement

typedef std::pair<std::string, std::string> SICAD::ModelPathElement

Definition at line 35 of file SICAD.h.

◆ ModelPose

typedef std::vector<double> Superimpose::ModelPose
inherited

Definition at line 23 of file Superimpose.h.

◆ ModelPoseContainer

typedef std::multimap<std::string, ModelPose> Superimpose::ModelPoseContainer
inherited

Definition at line 25 of file Superimpose.h.

◆ ModelPoseContainerElement

typedef std::pair<std::string, ModelPose> Superimpose::ModelPoseContainerElement
inherited

Definition at line 27 of file Superimpose.h.

Member Enumeration Documentation

◆ MIPMaps

enum SICAD::MIPMaps
strong
Enumerator
nearest 
linear 

Definition at line 41 of file SICAD.h.

Constructor & Destructor Documentation

◆ SICAD() [1/4]

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.

Parameters
objfile_mapA (tag, path) container to associate a 'tag' to the mesh file specified in 'path'.
cam_widthCamera or image width.
cam_heightCamera or image height.
cam_fxfocal Length along the x axis in pixels.
cam_fyfocal Length along the y axis in pixels.

Definition at line 29 of file SICAD.cpp.

◆ SICAD() [2/4]

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.

Parameters
objfile_mapA (tag, path) container to associate a 'tag' to the mesh file specified in 'path'.
cam_widthCamera or image width.
cam_heightCamera or image height.
cam_fxfocal Length along the x axis in pixels.
cam_fyfocal Length along the y axis in pixels.
num_imagesNumber of images (i.e. viewports) rendered in the same GL context.

Definition at line 43 of file SICAD.cpp.

◆ SICAD() [3/4]

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 models
  • shader_model.frag for the fragment shader for mesh models
  • shader_model_texture.frag for the fragment shader for textured mesh models
  • shader_frame.vert for the vertex shader for reference frames
  • shader_frame.frag for the fragment shader for reference frames
  • shader_background.vert for the vertex shader for background
  • shader_background.frag for the fragment shader for background

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.

Parameters
objfile_mapA (tag, path) container to associate a 'tag' to the mesh file specified in 'path'.
cam_widthCamera or image width.
cam_heightCamera or image height.
cam_fxfocal Length along the x axis in pixels.
cam_fyfocal Length along the y axis in pixels.
num_imagesNumber of images (i.e. viewports) rendered in the same GL context.
shader_folderPath to the folder containing the above-mentioned required shaders.

Definition at line 58 of file SICAD.cpp.

◆ SICAD() [4/4]

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 models
  • shader_model.frag for the fragment shader for mesh models
  • shader_model_texture.frag for the fragment shader for textured mesh models
  • shader_frame.vert for the vertex shader for reference frames
  • shader_frame.frag for the fragment shader for reference frames
  • shader_background.vert for the vertex shader for background
  • shader_background.frag for the fragment shader for background

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 and can be changed by means of ogl_to_cam.

Parameters
objfile_mapA (tag, path) container to associate a 'tag' to the mesh file specified in 'path'.
cam_widthCamera or image width.
cam_heightCamera or image height.
cam_fxfocal Length along the x axis in pixels.
cam_fyfocal Length along the y axis in pixels.
num_imagesNumber of images (i.e. viewports) rendered in the same GL context.
shader_folderPath to the folder containing the above-mentioned required shaders.
ogl_to_camA 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.

Definition at line 74 of file SICAD.cpp.

◆ ~SICAD()

SICAD::~SICAD ( )
virtual

Member Function Documentation

◆ factorize_int()

void SICAD::factorize_int ( const GLsizei  area,
const GLsizei  width_limit,
const GLsizei  height_limit,
GLsizei &  width,
GLsizei &  height 
)
private

Definition at line 1412 of file SICAD.cpp.

◆ getBackgroundOpt()

bool SICAD::getBackgroundOpt ( ) const

Definition at line 1297 of file SICAD.cpp.

References show_background_.

◆ getMipmapsOpt()

SICAD::MIPMaps SICAD::getMipmapsOpt ( ) const

Definition at line 1322 of file SICAD.cpp.

References mesh_mmaps_.

Referenced by renderBackground().

◆ getOglWindowShouldClose()

bool SICAD::getOglWindowShouldClose ( )

Definition at line 449 of file SICAD.cpp.

References window_.

◆ getPBO()

std::pair< bool, GLuint > SICAD::getPBO ( const size_t  pbo_index) const

Returns pbo_index-th Pixel Buffer Object (PBO) value.

Note
Rendered pixels are stored in the 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().
Returns
(true, PBO) if pbo_index exists, (false, 0) otherwise.

Definition at line 1220 of file SICAD.cpp.

References pbo_, pbo_number_, and window_.

◆ getPBOs()

std::pair< const GLuint *, size_t > SICAD::getPBOs ( ) const

Returns the Pixel Buffer Object (PBO) vector and its size.

Note
Rendered pixels are stored in the 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().
Returns
(PBO base array address, number of PBOs)

Definition at line 1212 of file SICAD.cpp.

References pbo_, pbo_number_, and window_.

◆ getTilesCols()

int SICAD::getTilesCols ( ) const

Definition at line 1340 of file SICAD.cpp.

References tiles_cols_.

◆ getTilesNumber()

int SICAD::getTilesNumber ( ) const

Definition at line 1328 of file SICAD.cpp.

References tiles_cols_, and tiles_rows_.

◆ getTilesRows()

int SICAD::getTilesRows ( ) const

Definition at line 1334 of file SICAD.cpp.

References tiles_rows_.

◆ getViewTransformationMatrix()

glm::mat4 SICAD::getViewTransformationMatrix ( const double *  cam_x,
const double *  cam_o 
)
private

Definition at line 1346 of file SICAD.cpp.

References ogl_to_cam_.

◆ getWireframeOpt()

GLenum SICAD::getWireframeOpt ( ) const

Definition at line 1316 of file SICAD.cpp.

References show_mesh_mode_.

◆ pollOrPostEvent()

void SICAD::pollOrPostEvent ( )
private

Definition at line 1361 of file SICAD.cpp.

References main_thread_id_.

Referenced by setOglWindowShouldClose().

◆ releaseContext()

void SICAD::releaseContext ( ) const
virtual

Make the current thread OpenGL context not current.

Note
This method must be called only when invoking 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.

Definition at line 1206 of file SICAD.cpp.

◆ renderBackground()

void SICAD::renderBackground ( const cv::Mat &  img) const
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_.

Here is the call graph for this function:

◆ setBackgroundOpt()

void SICAD::setBackgroundOpt ( bool  show_background)

Definition at line 1291 of file SICAD.cpp.

References show_background_.

Referenced by main().

◆ setMipmapsOpt()

void SICAD::setMipmapsOpt ( const MIPMaps mipmaps)

Definition at line 1310 of file SICAD.cpp.

References mesh_mmaps_.

◆ setOglWindowShouldClose()

void SICAD::setOglWindowShouldClose ( bool  should_close)

Definition at line 455 of file SICAD.cpp.

References pollOrPostEvent(), and window_.

Here is the call graph for this function:

◆ setProjectionMatrix()

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 
)

Definition at line 1234 of file SICAD.cpp.

◆ setWireframe()

void SICAD::setWireframe ( GLenum  mode)
private

Definition at line 1405 of file SICAD.cpp.

◆ setWireframeOpt()

void SICAD::setWireframeOpt ( bool  show_mesh_wires)

Definition at line 1303 of file SICAD.cpp.

References show_mesh_mode_.

◆ superimpose() [1/8]

bool SICAD::superimpose ( const ModelPoseContainer objpos_map,
const double *  cam_x,
const double *  cam_o,
cv::Mat &  img 
)
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.

Note
If cv::Mat 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.
Parameters
objpos_mapA (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.
imgAn 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.
Returns
true upon success, false otherswise.

Implements Superimpose.

Definition at line 464 of file SICAD.cpp.

Referenced by main().

◆ superimpose() [2/8]

bool SICAD::superimpose ( const std::vector< ModelPoseContainer > &  objpos_multimap,
const double *  cam_x,
const double *  cam_o,
cv::Mat &  img 
)
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.

Note
The size of the grid representing the tiled viewports can be accessed through getTilesRows() and getTilesCols().
If cv::Mat 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.
Parameters
objpos_mapA (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.
imgAn 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.
Returns
true upon success, false otherswise.

Definition at line 576 of file SICAD.cpp.

◆ superimpose() [3/8]

bool SICAD::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

Definition at line 701 of file SICAD.cpp.

◆ superimpose() [4/8]

bool SICAD::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

Definition at line 722 of file SICAD.cpp.

◆ superimpose() [5/8]

bool SICAD::superimpose ( const ModelPoseContainer objpos_map,
const double *  cam_x,
const double *  cam_o,
const size_t  pbo_index 
)
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).

Note
By invoking this command rendered pixels are stored in the 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().
Parameters
objpos_mapA (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_indexThe index of the PBO where the pixel are stored.
Returns
(true, PBO) upon success, (false, 0) otherswise.

Definition at line 743 of file SICAD.cpp.

◆ superimpose() [6/8]

bool SICAD::superimpose ( const ModelPoseContainer objpos_map,
const double *  cam_x,
const double *  cam_o,
const size_t  pbo_index,
const cv::Mat &  img 
)
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).

Note
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.
Parameters
objpos_mapA (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_indexThe index of the PBO where the pixel are stored.
imgA background image.
Returns
(true, PBO) upon success, (false, 0) otherswise.

Definition at line 850 of file SICAD.cpp.

◆ superimpose() [7/8]

bool SICAD::superimpose ( const std::vector< ModelPoseContainer > &  objpos_multimap,
const double *  cam_x,
const double *  cam_o,
const size_t  pbo_index 
)
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.

Note
By invoking this command rendered pixels are stored in the 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().
The size of the grid representing the tiled viewports can be accessed through getTilesRows() and getTilesCols().
Parameters
objpos_mapA (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_indexThe index of the PBO where the pixel are stored.
Returns
(true, PBO) upon success, (false, 0) otherswise.

Definition at line 962 of file SICAD.cpp.

◆ superimpose() [8/8]

bool SICAD::superimpose ( const std::vector< ModelPoseContainer > &  objpos_multimap,
const double *  cam_x,
const double *  cam_o,
const size_t  pbo_index,
const cv::Mat &  img 
)
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.

Note
The size of the grid representing the tiled viewports can be accessed through 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.
Parameters
objpos_mapA (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_indexThe index of the PBO where the pixel are stored.
imgA background image.
Returns
(true, PBO) upon success, (false, 0) otherswise.

Definition at line 1082 of file SICAD.cpp.

Member Data Documentation

◆ back_proj_

glm::mat4 SICAD::back_proj_
private

Definition at line 404 of file SICAD.h.

Referenced by renderBackground().

◆ class_counter_

int SICAD::class_counter_ = 0
staticprivate

Definition at line 332 of file SICAD.h.

Referenced by ~SICAD().

◆ ebo_background_

GLuint SICAD::ebo_background_
private

Definition at line 392 of file SICAD.h.

Referenced by ~SICAD().

◆ far_

const GLfloat SICAD::far_ = 1000.0f
private

Definition at line 362 of file SICAD.h.

◆ fbo_

GLuint SICAD::fbo_
private

Definition at line 382 of file SICAD.h.

Referenced by ~SICAD().

◆ framebuffer_height_

GLsizei SICAD::framebuffer_height_ = 0
private

Definition at line 354 of file SICAD.h.

◆ framebuffer_width_

GLsizei SICAD::framebuffer_width_ = 0
private

Definition at line 352 of file SICAD.h.

◆ image_height_

GLsizei SICAD::image_height_ = 0
private

Definition at line 348 of file SICAD.h.

◆ image_width_

GLsizei SICAD::image_width_ = 0
private

Definition at line 346 of file SICAD.h.

◆ log_ID_

const std::string SICAD::log_ID_ = "[SI::SICAD]"
private

Definition at line 336 of file SICAD.h.

Referenced by ~SICAD().

◆ main_thread_id_

std::thread::id SICAD::main_thread_id_
private

Definition at line 364 of file SICAD.h.

Referenced by pollOrPostEvent().

◆ mesh_mmaps_

MIPMaps SICAD::mesh_mmaps_ = MIPMaps::nearest
private

Definition at line 370 of file SICAD.h.

Referenced by getMipmapsOpt(), and setMipmapsOpt().

◆ model_obj_

ModelContainer SICAD::model_obj_
private

Definition at line 380 of file SICAD.h.

Referenced by ~SICAD().

◆ near_

const GLfloat SICAD::near_ = 0.001f
private

Definition at line 360 of file SICAD.h.

◆ ogl_to_cam_

glm::mat3 SICAD::ogl_to_cam_ = glm::mat3(1.0f)
private

Definition at line 350 of file SICAD.h.

Referenced by getViewTransformationMatrix().

◆ pbo_

GLuint SICAD::pbo_[2]
private

Definition at line 402 of file SICAD.h.

Referenced by getPBO(), getPBOs(), and ~SICAD().

◆ pbo_number_

size_t SICAD::pbo_number_ = 2
private

Definition at line 400 of file SICAD.h.

Referenced by getPBO(), and getPBOs().

◆ projection_

glm::mat4 SICAD::projection_
private

Definition at line 406 of file SICAD.h.

◆ renderbuffer_size_

GLsizei SICAD::renderbuffer_size_ = 0
staticprivate

Definition at line 334 of file SICAD.h.

◆ shader_background_

Shader* SICAD::shader_background_ = nullptr
private

Definition at line 372 of file SICAD.h.

Referenced by renderBackground(), and ~SICAD().

◆ shader_cad_

Shader* SICAD::shader_cad_ = nullptr
private

Definition at line 374 of file SICAD.h.

Referenced by ~SICAD().

◆ shader_frame_

Shader* SICAD::shader_frame_ = nullptr
private

Definition at line 378 of file SICAD.h.

Referenced by ~SICAD().

◆ shader_mesh_texture_

std::unique_ptr<Shader> SICAD::shader_mesh_texture_
private

Definition at line 376 of file SICAD.h.

◆ show_background_

bool SICAD::show_background_ = false
private

Definition at line 366 of file SICAD.h.

Referenced by getBackgroundOpt(), and setBackgroundOpt().

◆ show_mesh_mode_

GLenum SICAD::show_mesh_mode_ = GL_FILL
private

Definition at line 368 of file SICAD.h.

Referenced by getWireframeOpt(), and setWireframeOpt().

◆ texture_background_

GLuint SICAD::texture_background_
private

Definition at line 388 of file SICAD.h.

Referenced by renderBackground(), and ~SICAD().

◆ texture_color_buffer_

GLuint SICAD::texture_color_buffer_
private

Definition at line 384 of file SICAD.h.

Referenced by ~SICAD().

◆ texture_depth_buffer_

GLuint SICAD::texture_depth_buffer_
private

Definition at line 386 of file SICAD.h.

Referenced by ~SICAD().

◆ tile_img_height_

GLsizei SICAD::tile_img_height_ = 0
private

Definition at line 358 of file SICAD.h.

◆ tile_img_width_

GLsizei SICAD::tile_img_width_ = 0
private

Definition at line 356 of file SICAD.h.

◆ tiles_cols_

GLsizei SICAD::tiles_cols_ = 0
private

Definition at line 342 of file SICAD.h.

Referenced by getTilesCols(), and getTilesNumber().

◆ tiles_num_

GLint SICAD::tiles_num_ = 0
private

Definition at line 340 of file SICAD.h.

◆ tiles_rows_

GLsizei SICAD::tiles_rows_ = 0
private

Definition at line 344 of file SICAD.h.

Referenced by getTilesNumber(), and getTilesRows().

◆ vao_background_

GLuint SICAD::vao_background_
private

Definition at line 390 of file SICAD.h.

Referenced by renderBackground(), and ~SICAD().

◆ vao_frame_

GLuint SICAD::vao_frame_
private

Definition at line 396 of file SICAD.h.

Referenced by ~SICAD().

◆ vbo_background_

GLuint SICAD::vbo_background_
private

Definition at line 394 of file SICAD.h.

Referenced by ~SICAD().

◆ vbo_frame_

GLuint SICAD::vbo_frame_
private

Definition at line 398 of file SICAD.h.

Referenced by ~SICAD().

◆ window_

GLFWwindow* SICAD::window_ = nullptr
private

Definition at line 338 of file SICAD.h.

Referenced by getOglWindowShouldClose(), getPBO(), getPBOs(), setOglWindowShouldClose(), and ~SICAD().


The documentation for this class was generated from the following files: