-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservidor4.cpp
More file actions
67 lines (59 loc) · 1.3 KB
/
Copy pathservidor4.cpp
File metadata and controls
67 lines (59 loc) · 1.3 KB
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
//compila -w -c
#include "projeto.hpp"
#include "cekeikon.h"
#include <wiringPi.h>
#include <softPwm.h>
int main(void)
{
SERVER server;
server.waitConnection();
wiringPiSetup();
if (softPwmCreate(0, 0, 100))
erro("erro");
if (softPwmCreate(1, 0, 100))
erro("erro");
if (softPwmCreate(2, 0, 100))
erro("erro");
if (softPwmCreate(3, 0, 100))
erro("erro");
VideoCapture cam(0);
if (!cam.isOpened())
erro("Erro: Abertura de webcam.");
cam.set(CV_CAP_PROP_FRAME_WIDTH,320);
cam.set(CV_CAP_PROP_FRAME_HEIGHT,240);
Mat_<COR> image;
cam >> image;
uint32_t comando = 0;
int ch = -1;
while (ch <0)
{
cam.grab();
cam.grab();
cam >> image;
flip(image, image, -1);
server.receiveUint(comando);
putTxt (image, 10, 10, to_string (comando), COR (0,255,0), 4);
server.sendImgComp(image);
if (comando == 11)
{
softPwmWrite (0, 100);
softPwmWrite (1, 100);
softPwmWrite (2, 100);
softPwmWrite (3, 100);
}
else if(comando >= 5)
{
softPwmWrite (0, 20 + 10*(comando - 5));
softPwmWrite (1, 0);
softPwmWrite (2, 100);
softPwmWrite (3, 0);
}
else
{
softPwmWrite (0, 100);
softPwmWrite (1, 0);
softPwmWrite (2, 20 + 10*comando);
softPwmWrite (3, 0);
}
}
}