Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include "MainWindow.hpp"
  2. #include "Device.hpp"
  3.  
  4. #include <QHBoxLayout>
  5. #include <QLabel>
  6. #include <QTimer>
  7. #include <QDebug>
  8.  
  9. namespace lfb
  10. {
  11.  
  12. MainWindow::MainWindow()
  13.     : QWidget()
  14.     , mGrabber( *this )
  15.     , mRGBLabel()
  16.     , mDepthLabel()
  17. {
  18.     mRGBLabel = new QLabel();
  19.     mRGBImage = new QImage( FREENECT_FRAME_W, FREENECT_FRAME_H, QImage::Format_RGB888 );
  20.     mRGBLabel->setPixmap( QPixmap::fromImage( *mRGBImage ) );
  21.  
  22.     mDepthLabel = new QLabel();
  23.     mDepthImage = new QImage( FREENECT_FRAME_W, FREENECT_FRAME_H, QImage::Format_RGB888 );
  24.     mDepthLabel->setPixmap( QPixmap::fromImage( *mDepthImage ) );
  25.  
  26.     QHBoxLayout* layout = new QHBoxLayout();
  27.     layout->addWidget( mRGBLabel );
  28.     layout->addWidget( mDepthLabel );
  29.     setLayout( layout );
  30.  
  31.     mGrabber.start();
  32. }
  33.  
  34. MainWindow::~MainWindow()
  35. {
  36.     mGrabber.quit();
  37.     mGrabber.wait();
  38. }
  39.  
  40. void MainWindow::RefreshKinectData( const std::vector<uint8_t>& rgb, const std::vector<uint8_t>& depth )
  41. {
  42.     mGrabber.LockImages();
  43.     qDebug() << "Images updated. Pixel(0,0) = (" << rgb[0] << "," << rgb[1] << ","<< rgb[2] << ")";
  44.     mRGBImage->fromData( (const char*)rgb.data() );
  45.     mDepthImage->fromData( (const char*)depth.data() );
  46.     mRGBLabel->setPixmap( QPixmap::fromImage( *mRGBImage ) );
  47.     mDepthLabel->setPixmap( QPixmap::fromImage( *mDepthImage ) );
  48.     mGrabber.UnlockImages();
  49.     update();
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement