Fixed NetSend so it can be used in debug mode.
[qt/compvision.git] / ImageViewer.cpp
1 #include "ImageViewer.h"\r
2 #include <QPixmap>\r
3 \r
4 ImageViewer::ImageViewer(QLabel *disp, QLabel *rate, ImagePool *source, ImagePool *destination) : ImageThread(source, destination)\r
5 {\r
6         display=disp;\r
7         width=0;\r
8         height=0;\r
9         \r
10         dt=0;\r
11         fpsLabel=rate;\r
12         clock.start();\r
13 }\r
14 \r
15 void ImageViewer::process()\r
16 {\r
17         display->setPixmap(QPixmap::fromImage(*img));\r
18         \r
19         // 8-point average\r
20         dt=dt - (dt>>3) + clock.elapsed();\r
21         \r
22         fpsLabel->setText(QString("%1 fps").arg(8000/dt));\r
23         \r
24         // Force the display to reflect the current image size.\r
25         if(width!=img->width() || height!=img->height())\r
26         {\r
27                 width=img->width();\r
28                 height=img->height();\r
29                 \r
30                 // stall the pipeline to give MainWindow time to update fully\r
31                 // Dirty but effective.  Open to suggestions.\r
32                 QSemaphore lock;\r
33                 emit(layout(&lock));\r
34                 lock.acquire();\r
35         }\r
36         \r
37         clock.restart();\r
38 }\r