-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopencview (Cópia em conflito de hpsala 2015-04-17).cpp
executable file
·64 lines (58 loc) · 1.67 KB
/
opencview (Cópia em conflito de hpsala 2015-04-17).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
#include "opencview.h"
#include <QPainter>
#include <QDebug>
OpenCview::OpenCview(QWidget *parent) :
QWidget(parent)
{
cap.open(0);
cap >> m;
startTimer(10);
flag = true;
}
void OpenCview::click(){
flag = !flag;
qDebug() << flag;
}
void OpenCview::paintEvent(QPaintEvent *e)
{
QPainter p(this);
cvtColor(m, disp, CV_GRAY2RGB);
// cvtColor(m, disp, CV_BGR2RGB);
QImage image((uchar*)disp.data, disp.cols, disp.rows,QImage::Format_RGB888);
p.drawImage(rect(),image,image.rect());
}
void OpenCview::capture()
{
// Mat opencv_image = imread("fruits.jpg", CV_LOAD_IMAGE_COLOR);
// Mat dest;
// cvtColor(opencv_image, dest,CV_BGR2RGB);
// QImage image((uchar*)dest.data, dest.cols, dest.rows,QImage::Format_RGB888);
}
void OpenCview::timerEvent(QTimerEvent *e)
{
float horizontal[]={-1,0,1,
-2,0,2,
-1,0,1};
Mat frame, frame32f, frameFiltered;
Mat mask(3,3,CV_32F), mask1(3,3,CV_32F);
double min, max;
mask = Mat(3,3,CV_32F,horizontal);
cap >> m;
frame = m;
cvtColor(m, frame, CV_BGR2GRAY);
if(flag){
flip(frame,frame,1);
}
frame.convertTo(frame32f, CV_32F);
filter2D(frame32f,frameFiltered,frame32f.depth(),mask,Point(1,1),0);
//std::cout << frame32f.at<float>(100,100)<< "\n";
//filter2D(edges,frame1,edges.depth(),mask1,Point(1,1),128);
//res=frame+frame1;
//filter2D(edges,frame,edges.depth(),mask,Point(1,1),128);
//flip(frame,edges,1);
frameFiltered=abs(frameFiltered);
// minMaxLoc(frameFiltered, &min, &max, 0, 0, Mat());
//std::cout << max << "\n";
frameFiltered.convertTo(m,CV_8U);
repaint();
}