[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6. Boxm2 GUI demo

Chapter summary:
Render, update and refine gui-based demo in boxm2


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1 boxm2_render_tableau

The bulk of the gui-based demo code is located in ocl/view/boxm2_render_tableau.h/cxx. This tableau is initialized with a scene.xml full path, a viewport size (ni,nj), a single initial camera vpgl_perspective_camera<double>*, a vector of camera file paths, and a vector of image file paths.

 
  //: initialize tableau with scene_file, viewport size, initial cam,  
  bool init(vcl_string scene_file,
            unsigned ni,
            unsigned nj,
            vpgl_perspective_camera<double>* cam,
            vcl_vector<vcl_string> cam_files,
            vcl_vector<vcl_string> img_files);

All events are handled in the virtual method handle:

 
  //: virtual function handles mouse and keyboard actions
  virtual bool handle( vgui_event const& e );

After the tableau is initialized using the method above, the tableau must also initialize an OpenGL context, some OpenCL objects, and some boxm2 data structures, which are handled in the following methods:

 
  cl_context create_clgl_context();
  bool init_clgl();

The handle method is currently equipped to handle the following commands:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1.1 Updating the voxel model

The following is an outline of the updating procedure performed by the tableau.

 
//: updates given a random frame
float boxm2_render_tableau::update_frame()
{
  //choose random frame and corresponding camera (create portable sptrs)
  vil_image_view<float>* floatimg = random_frame(); 
  vil_image_view_base_sptr floatimg_sptr(floatimg);
  brdb_value_sptr brdb_inimg = new brdb_value_t<vil_image_view_base_sptr>(floatimg_sptr);
  vpgl_camera_double_sptr cam_sptr(pcam);
  brdb_value_sptr brdb_cam = new brdb_value_t<vpgl_camera_double_sptr>(cam_sptr);

  //create brdb pointer to scene
  brdb_value_sptr brdb_scene = new brdb_value_t<boxm2_scene_sptr>(scene_);

  //set inputs
  vcl_vector<brdb_value_sptr> input;
  input.push_back(brdb_scene);
  input.push_back(brdb_cam);
  input.push_back(brdb_inimg);

  //initoutput vector
  vcl_vector<brdb_value_sptr> output;

  //execute gpu_update (update_ is of type boxm2_opencl_update_process)
  gpu_pro_->run(&update_, input, output);
  return gpu_pro_->exec_time();


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated on May, 1 2013 using texi2html 1.76.