forked from Linquas/Barcode-Decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.cpp
82 lines (59 loc) · 1.41 KB
/
display.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "display.h"
#include "ui_display.h"
#include <iostream>
#include <QDebug>
Display::Display(QWidget *parent) :
QGLWidget(parent),
ui(new Ui::Display)
{
isBarcodeLocated = false;
isProgramRun = false;
ui->setupUi(this);
setFixedSize(640,480);
this->painter = new QPainter(this);
update();
}
void Display::loadImg(cv::Mat in){
if(isProgramRun){
in.copyTo(img);
//cv::cvtColor(img,img,CV_BGR2RGB);
if(isBarcodeLocated){
cv::rectangle(img , this->barcadeLocation , cv::Scalar(255,0,0) );
}
update();
}
}
void Display::slotGetBarcodeLocation(cv::Rect R){
this->barcadeLocation = R;
}
void Display::slotIsBarcodeLocated(bool status){
isBarcodeLocated = status;
}
void Display::updateScreen(){
//img = cv::imread("barcode.jpg");
update();
}
void Display::paintEvent(QPaintEvent *){
painter->begin(this);
QRect A(0,0,640,480);
painter->eraseRect(A);
if(img.data && isProgramRun){
QPixmap out = QPixmap::fromImage(QImage ((uchar*)img.data , img.cols , img.rows , QImage::Format_RGB888));
painter->drawPixmap(0,0,out);
}
painter->end();
}
void Display::cleanScrean(){
isProgramRun = false;
update();
img.release();
qDebug("clean screan");
}
void Display::startDisplay(){
isProgramRun = true;
}
Display::~Display()
{
delete ui;
painter->end();
}