-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathhandler.cpp
More file actions
91 lines (76 loc) · 2.12 KB
/
handler.cpp
File metadata and controls
91 lines (76 loc) · 2.12 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* File: handler.cpp
* Author: vorago
*
* Created on March 1, 2011, 8:03 PM
*/
#include "include/handler.hpp"
#include <opencv/cv.h>
#include <stdio.h>
namespace iwb {
Handler::Handler() {
}
Handler::~Handler() {
}
bool* Handler::getLoadFlag() {
return &loadFlag;
}
bool* Handler::getSaveFlag() {
return &saveFlag;
}
void Handler::setLoadFlag() {
loadFlag = true;
saveFlag = false;
}
void Handler::setSaveFlag() {
saveFlag = true;
loadFlag = false;
}
bool Handler::handleArguments(int argc, char* argv[], Capture **cpt, int *resWidth, int* resHeight) {
int cam;
// Argument handling block
if (argc >= 2) {
char *endptr;
cam = strtol(argv[1], &endptr, 10);
if (*endptr == '\0') {
*cpt = new Capture(cam);
} else {
*cpt = new Capture(argv[1]);
}
} else {
cam = 0;
*cpt = new Capture(cam);
}
/**
* Process resolution in second parameter.
* If none is given, use 800x600.
*/
if (argc == 3) {
char* str = argv[2];
char* pch;
pch = strchr(str, 'x');
if (pch == NULL) {
printf("Resolution which was expected in the second argument should "
"be of the form of 1024x768");
return false;
}
pch[0] = '\0';
pch++;
*resWidth = atoi(str);
*resHeight = atoi(pch);
}
return true;
}
void Handler::detectTouchedComponents(IplImage *mask) {
cvSaveImage("mask.jpg", mask);
for (std::list<Touchable*>::iterator component = components.begin(); component != components.end(); component++) {
(*component)->detectTouch(mask);
}
}
void Handler::addComponent(Touchable* component) {
components.push_back(component);
}
void Handler::removeComponent(Touchable* component) {
components.remove(component);
}
}