Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MainWindow.hpp"
- #include "Device.hpp"
- #include <QHBoxLayout>
- #include <QLabel>
- #include <QTimer>
- #include <QDebug>
- namespace lfb
- {
- MainWindow::MainWindow()
- : QWidget()
- , mGrabber( *this )
- , mRGBLabel()
- , mDepthLabel()
- {
- mRGBLabel = new QLabel();
- mRGBImage = new QImage( FREENECT_FRAME_W, FREENECT_FRAME_H, QImage::Format_RGB888 );
- mRGBLabel->setPixmap( QPixmap::fromImage( *mRGBImage ) );
- mDepthLabel = new QLabel();
- mDepthImage = new QImage( FREENECT_FRAME_W, FREENECT_FRAME_H, QImage::Format_RGB888 );
- mDepthLabel->setPixmap( QPixmap::fromImage( *mDepthImage ) );
- QHBoxLayout* layout = new QHBoxLayout();
- layout->addWidget( mRGBLabel );
- layout->addWidget( mDepthLabel );
- setLayout( layout );
- mGrabber.start();
- }
- MainWindow::~MainWindow()
- {
- mGrabber.quit();
- mGrabber.wait();
- }
- void MainWindow::RefreshKinectData( const std::vector<uint8_t>& rgb, const std::vector<uint8_t>& depth )
- {
- mGrabber.LockImages();
- qDebug() << "Images updated. Pixel(0,0) = (" << rgb[0] << "," << rgb[1] << ","<< rgb[2] << ")";
- mRGBImage->fromData( (const char*)rgb.data() );
- mDepthImage->fromData( (const char*)depth.data() );
- mRGBLabel->setPixmap( QPixmap::fromImage( *mRGBImage ) );
- mDepthLabel->setPixmap( QPixmap::fromImage( *mDepthImage ) );
- mGrabber.UnlockImages();
- update();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement