kilka poprawek

This commit is contained in:
Mariusz Pacek committed 2013-06-09 23:05:27 +02:00
1 parent 3a24f60597
commit 354641b8a7
4 files changed
+23 -23

No files matched your search

Binary file not shown.
+11 -10
View File
@@ -79,6 +79,7 @@ int main(int, char**) {
namedWindow("output", 1);
namedWindow("bin", 1);
cap >> frame;
int frameX=frame.cols,frameY=frame.rows;
flip(frame, frame, 1);
@@ -137,23 +138,23 @@ int main(int, char**) {
if ((x = solution.x - 50) <= 0)
x = 0;
else
if ((x = solution.x - 50) >= 640)
x = 640;
if ((x = solution.x - 50) >= frameX)
x = frameX;
if ((y = solution.y - 50) <= 0)
y = 0;
else
if ((y = solution.y - 50) >= 480)
y = 480;
if ((y = solution.y - 50) >= frameY)
y = frameY;
if ((x1 = solution.x + solution.width + 50) <= 0)
x1 = 0;
else
if ((x1 = solution.x + solution.width + 50) >= 640)
x1 = 640;
if ((x1 = solution.x + solution.width + 50) >= frameX)
x1 = frameX;
if ((y1 = solution.y + solution.height + 50) <= 0)
y1 = 0;
else
if ((y1 = solution.y + solution.height + 50) >= 480)
y1 = 480;
if ((y1 = solution.y + solution.height + 50) >= frameY)
y1 = frameY;
p3 = Point(x, y);
@@ -166,8 +167,8 @@ int main(int, char**) {
x = (int) (solution.x + solution.x + solution.width) / 2;
y = (int) (solution.y + solution.y + solution.height) / 2;
mouse.setMouse(x / (double) frame.cols * res.second, y / (double) frame.rows * res.first,3);
mouse.drawArc(x / (double) frame.cols * res.second, y / (double) frame.rows * res.first, 3);
mouse.setMouse(x / (double) frame.cols * res.first, y / (double) frame.rows * res.second,3);
mouse.drawArc(x / (double) frame.cols * res.first, y / (double) frame.rows * res.second, 3);
imshow("result3", searchRegion);
+11 -13
View File
@@ -54,10 +54,11 @@ Media::Media() {
XAllocColor(dpy, colormap, &colorval);
XSetForeground(dpy, gc, colorval.pixel);
XFillRectangle(dpy, double_buffer, gc, 0, 0, wa.width, wa.height);
currXM = 1600 / 2;
currYM = 900 / 2;
currXR = 1600 / 2;
currYR = 900 / 2;
res = getResolution();
currXM = res.first/2;
currYM = res.second / 2;
currXR = res.first/2;
currYR = res.second / 2;
}
void Media::setMouse(const int _x, const int _y, double speed) {
@@ -65,9 +66,9 @@ void Media::setMouse(const int _x, const int _y, double speed) {
currXM -= speed * (xM - _x);
currYM -= speed * (yM - _y);
if (currXM > 1600) currXM = 1600;
if (currXM > res.first) currXM = res.first;
if (currXM < 0) currXM = 0;
if (currYM > 900) currYM = 900;
if (currYM > res.second) currYM = res.second;
if (currYM < 0) currYM = 0;
xM = _x;
yM = _y;
@@ -78,23 +79,20 @@ void Media::setMouse(const int _x, const int _y, double speed) {
std::pair<int, int> Media::getResolution() {
std::pair<int, int> resoluton;
resoluton.first = XDisplayHeight(dpy, 0);
resoluton.second = XDisplayWidth(dpy, 0);
resoluton.second = XDisplayHeight(dpy, 0);
resoluton.first = XDisplayWidth(dpy, 0);
return resoluton;
}
void Media::drawArc(int _x, int _y, double speed) {
draw();
currXR -= speed * (xR - _x);
currYR -= speed * (yR - _y);
if (currXR > 1600) currXR = 1600;
if (currXR > res.first) currXR = res.first;
if (currXR < 0) currXR = 0;
if (currYR > 900) currYR = 900;
if (currYR > res.second) currYR = res.second;
if (currYR < 0) currYR = 0;
xR = _x;
yR = _y;
+1
View File
@@ -37,6 +37,7 @@ private:
int currYR;
int currXM;
int currYM;
std::pair<int,int> res;
};
#endif /* MOUSE_HPP */