camerawidget.cpp
Go to the documentation of this file.
00001 
00018 #include "VisualisationUtils/camerawidget.h"
00019 
00020 CameraWidget::CameraWidget(QWidget *parent, CameraThread *camera):
00021     QWidget(parent)
00022 {
00023     this->camera = camera;
00024     painterInit = false;
00025     imageInit =false;
00026 
00027     image = new QImage(1, 1, QImage::Format_RGB16);
00028 
00029     connect(camera, SIGNAL(imageReceived(const sensor_msgs::Image::ConstPtr&)),this, SLOT(imageReceived(const sensor_msgs::Image::ConstPtr&)));
00030     camera->start();
00031 }
00032 
00033 void CameraWidget::imageReceived(const sensor_msgs::Image::ConstPtr& msg)
00034 {
00035     if (!imageInit) {image = new QImage(msg->width, msg->height, QImage::Format_RGB16);}
00036     imageInit = true;
00037 
00038     for(int i = 0; i < image->width(); i++)
00039     {
00040         for(int j = 0; j < image->height(); j++)
00041         {
00042             image->setPixel(i, j, qRgb(msg->data[j * msg->width + i+2],msg->data[j * msg->width + i+1],msg->data[j * msg->width + i]));
00043         }
00044     }
00045 
00046     this->repaint();
00047 }
00048 
00049 void CameraWidget::paintEvent(QPaintEvent * pe)
00050 {
00051     QWidget::paintEvent(pe);
00052     if (!painterInit) {painter = new QPainter(this);}
00053     painterInit = true;
00054 
00055     if (imageInit)
00056     {
00057         QPainter painter(this);
00058         painter.drawImage(QRect(0,0, this->width(), this->height()), *image);
00059     }
00060 }
00061 void CameraWidget::resizeEvent(QResizeEvent * event)
00062 {
00063     QWidget::resizeEvent(event);
00064 }


asr_mild_calibration_tool
Author(s): Aumann Florian, Heller Florian, Meißner Pascal
autogenerated on Thu Jun 6 2019 21:22:44