KINECT STATS GENERATOR FOR SPORTS VISUALISATION  1.0
RGBboundsVisualization Class Reference

To visualize RGB data used to define bounds. More...

#include <RGBboundsVisualization.h>

+ Collaboration diagram for RGBboundsVisualization:

List of all members.

Public Member Functions

 RGBboundsVisualization (QWidget *_parent)
 Constructor for RGBboundsVisualization.
 ~RGBboundsVisualization ()
 dtor

Protected Member Functions

void initializeGL ()
 The following methods must be implimented in the sub class this is called when the window is created.
void resizeGL (const int _w, const int _h)
 this is called whenever the window is re-sized
void paintGL ()
 this is the main gl drawing routine which is called whenever the window needs to

Private Member Functions

void mouseMoveEvent (QMouseEvent *_event)
 this method is called every time a mouse is moved
void mousePressEvent (QMouseEvent *_event)
 this method is called everytime the mouse button is pressed inherited from QObject and overridden here.
void mouseReleaseEvent (QMouseEvent *_event)
 this method is called everytime the mouse button is released inherited from QObject and overridden here.
void timerEvent (QTimerEvent *_event)
 called when the timer is triggered

Private Attributes

cv::Mat m_rgb
 RGB mat buffer.
QTime m_timer
 timer to call paintgl
ScreenQuadm_screen
 rendering instance for quad pasting the RGB buffer
cv::Rect m_selectionBox
 bounds defined is stored in this rect structure
bool m_drawingStatus
 indicates if bounds definition has finished

Detailed Description

To visualize RGB data used to define bounds.

Definition at line 27 of file RGBboundsVisualization.h.


Constructor & Destructor Documentation

Constructor for RGBboundsVisualization.

Parameters:
[in]_parentthe parent window to create the GL context in

Definition at line 17 of file RGBboundsVisualization.cpp.

References m_drawingStatus, and m_rgb.

                      : QGLWidget(new CreateCoreGLContext(QGLFormat::defaultFormat()), _parent)

{

  // set this widget to have the initial keyboard focus
  // re-size the widget to that of the parent (in this case the GLFrame passed in on construction)
  this->resize(_parent->size());
  startTimer(5); // increasing this timer causes the stats window to lose its information

  m_rgb = cvCreateMat(640,480,CV_8UC3);
  m_drawingStatus = false;
}

dtor

Definition at line 207 of file RGBboundsVisualization.cpp.

References m_screen.

{
    if(m_screen)
    {
        delete m_screen;
    }
}

Member Function Documentation

The following methods must be implimented in the sub class this is called when the window is created.

Definition at line 37 of file RGBboundsVisualization.cpp.

References m_screen.

{
  glClearColor(0.4f, 0.4f, 0.4f, 1.0f);        // Grey Background
  // enable depth testing for drawing

    ngl::NGLInit *Init = ngl::NGLInit::instance();
    Init->initGlew();
    // now we have valid GL can create shaders etc
    ngl::ShaderLib *shader = ngl::ShaderLib::instance();
    shader->createShaderProgram("TextureRGB");

    shader->attachShader("TextureVertex",ngl::VERTEX);
    shader->attachShader("TextureFragment",ngl::FRAGMENT);
    shader->loadShaderSource("TextureVertex","shaders/TextureVert.glsl");
    shader->loadShaderSource("TextureFragment","shaders/TextureFrag.glsl");

    shader->compileShader("TextureVertex");
    shader->compileShader("TextureFragment");
    shader->attachShaderToProgram("TextureRGB","TextureVertex");
    shader->attachShaderToProgram("TextureRGB","TextureFragment");

    shader->linkProgramObject("TextureRGB");
    (*shader)["TextureRGB"]->use();
    shader->setShaderParam1i("tex",0);

    m_screen = new ScreenQuad(640,480,"TextureRGB");


    //frame rate GUNDU
//    m_text=new ngl::Text(QFont("Arial",14));
//    currentTime = currentTime.currentTime();

}
void RGBboundsVisualization::mouseMoveEvent ( QMouseEvent *  _event) [private]

this method is called every time a mouse is moved

Parameters:
_eventthe Qt Event structure

Definition at line 119 of file RGBboundsVisualization.cpp.

References m_drawingStatus, and m_selectionBox.

{
 // Q_UNUSED(_event);

    if( m_drawingStatus ){
                    m_selectionBox.width = _event->x()-m_selectionBox.x;
                    m_selectionBox.height = _event->y()-m_selectionBox.y;
                }

  updateGL();
}
void RGBboundsVisualization::mousePressEvent ( QMouseEvent *  _event) [private]

this method is called everytime the mouse button is pressed inherited from QObject and overridden here.

Parameters:
_eventthe Qt Event structure

Definition at line 133 of file RGBboundsVisualization.cpp.

References KinectInterface::instance(), m_drawingStatus, m_selectionBox, and KinectInterface::setBoxObject().

{
  //Q_UNUSED(_event);

//    std::cout<<_event->x()<<"\n";
//    std::cout<<_event->y()<<"\n";
   // std::cout<<_event->globalX()<<"\n";
   // std::cout<<_event->globalY()<<"\n";

     if(_event->buttons() == Qt::LeftButton)
     {

                m_drawingStatus = true;
                m_selectionBox = cv::Rect(_event->x(), _event->y(), 0, 0 );



     }
     else if(_event->buttons() == Qt::RightButton)
     {
         KinectInterface *kinect=KinectInterface::instance();

         m_drawingStatus = false;



         kinect->setBoxObject(m_selectionBox.x,m_selectionBox.y,m_selectionBox.width,m_selectionBox.height);

//         std::cout<<m_selectionBox.x<<"\n";
//         std::cout<<m_selectionBox.y<<"\n";
//         std::cout<<m_selectionBox.width<<"\n";
//         std::cout<<m_selectionBox.height<<"\n";

     }
    updateGL();

   // cv::line(m_rgb,cv::Point(0,0),cv::Point(630,470),cv::Scalar(255,0,0),4);

}

+ Here is the call graph for this function:

void RGBboundsVisualization::mouseReleaseEvent ( QMouseEvent *  _event) [private]

this method is called everytime the mouse button is released inherited from QObject and overridden here.

Parameters:
_eventthe Qt Event structure

Definition at line 174 of file RGBboundsVisualization.cpp.

References m_drawingStatus, and m_selectionBox.

{
  // this event is called when the mouse button is released
  // we then set Rotate to false
 // Q_UNUSED(_event);

    if(_event->buttons() == Qt::LeftButton)
    {
        m_drawingStatus = false;
        if( m_selectionBox.width < 0 ){
            m_selectionBox.x += m_selectionBox.width;
            m_selectionBox.width *= -1;
        }
        if( m_selectionBox.height < 0 ){
            m_selectionBox.y += m_selectionBox.height;
            m_selectionBox.height *= -1;
        }



    }


    updateGL();
}
void RGBboundsVisualization::paintGL ( ) [protected]

this is the main gl drawing routine which is called whenever the window needs to

Definition at line 87 of file RGBboundsVisualization.cpp.

References ScreenQuad::draw(), KinectInterface::getRGB(), KinectInterface::instance(), m_rgb, m_screen, and m_selectionBox.

{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    ngl::ShaderLib *shader = ngl::ShaderLib::instance();
    (*shader)["TextureRGB"]->use();

    // calculate the framerate //frame rate GUNDU
//    QTime newTime = currentTime.currentTime();
//    int msecsPassed = currentTime.msecsTo(newTime);
//    currentTime = newTime;



    KinectInterface *kinect=KinectInterface::instance();
    kinect->getRGB(m_rgb);

    cv::rectangle(m_rgb, cv::Point(m_selectionBox.x, m_selectionBox.y), cv::Point(m_selectionBox.x+m_selectionBox.width,m_selectionBox.y+m_selectionBox.height),
                    cv::Scalar(255,0,0),5 );

    m_screen->draw(&m_rgb);


   /* QString text;
    // framerate GUNDU
    m_text->setColour(1,1,1);
    text.sprintf("framerate is %d",(int)(1000.0/msecsPassed));
    m_text->renderText(10,50,text);*/
}

+ Here is the call graph for this function:

void RGBboundsVisualization::resizeGL ( const int  _w,
const int  _h 
) [protected]

this is called whenever the window is re-sized

Parameters:
[in]_wthe width of the resized window
[in]_hthe height of the resized window

Definition at line 74 of file RGBboundsVisualization.cpp.

{
  glViewport(0,0,_w,_h);

   /*m_text->setScreenSize(_w,_h);*/
}
void RGBboundsVisualization::timerEvent ( QTimerEvent *  _event) [private]

called when the timer is triggered

Definition at line 200 of file RGBboundsVisualization.cpp.

{
    Q_UNUSED(_event);
    // re-draw GL
    updateGL();
}

Member Data Documentation

indicates if bounds definition has finished

Definition at line 52 of file RGBboundsVisualization.h.

cv::Mat RGBboundsVisualization::m_rgb [private]

RGB mat buffer.

Definition at line 40 of file RGBboundsVisualization.h.

rendering instance for quad pasting the RGB buffer

Definition at line 46 of file RGBboundsVisualization.h.

bounds defined is stored in this rect structure

Definition at line 49 of file RGBboundsVisualization.h.

timer to call paintgl

Definition at line 43 of file RGBboundsVisualization.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator