camerawidget.cpp
Go to the documentation of this file.
1 
19 
20 CameraWidget::CameraWidget(QWidget *parent, CameraThread *camera):
21  QWidget(parent)
22 {
23  this->camera = camera;
24  painterInit = false;
25  imageInit =false;
26 
27  image = new QImage(1, 1, QImage::Format_RGB16);
28 
29  connect(camera, SIGNAL(imageReceived(const sensor_msgs::Image::ConstPtr&)),this, SLOT(imageReceived(const sensor_msgs::Image::ConstPtr&)));
30  camera->start();
31 }
32 
33 void CameraWidget::imageReceived(const sensor_msgs::Image::ConstPtr& msg)
34 {
35  if (!imageInit) {image = new QImage(msg->width, msg->height, QImage::Format_RGB16);}
36  imageInit = true;
37 
38  for(int i = 0; i < image->width(); i++)
39  {
40  for(int j = 0; j < image->height(); j++)
41  {
42  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]));
43  }
44  }
45 
46  this->repaint();
47 }
48 
49 void CameraWidget::paintEvent(QPaintEvent * pe)
50 {
51  QWidget::paintEvent(pe);
52  if (!painterInit) {painter = new QPainter(this);}
53  painterInit = true;
54 
55  if (imageInit)
56  {
57  QPainter painter(this);
58  painter.drawImage(QRect(0,0, this->width(), this->height()), *image);
59  }
60 }
61 void CameraWidget::resizeEvent(QResizeEvent * event)
62 {
63  QWidget::resizeEvent(event);
64 }
QPainter * painter
Definition: camerawidget.h:40
QImage * image
Definition: camerawidget.h:39
void imageReceived(const sensor_msgs::Image::ConstPtr &msg)
CameraWidget(QWidget *parent=0, CameraThread *camera=0)
void paintEvent(QPaintEvent *pe)
void resizeEvent(QResizeEvent *event)
CameraThread * camera
Definition: camerawidget.h:38
bool painterInit
Definition: camerawidget.h:41


asr_mild_calibration_tool
Author(s): Aumann Florian, Heller Florian, Meißner Pascal
autogenerated on Mon Dec 2 2019 03:11:43