diff --git a/mariusz/dist/Debug/GNU-Linux-x86/mariusz b/mariusz/dist/Debug/GNU-Linux-x86/mariusz index 15f6f13..85511d3 100755 Binary files a/mariusz/dist/Debug/GNU-Linux-x86/mariusz and b/mariusz/dist/Debug/GNU-Linux-x86/mariusz differ diff --git a/mariusz/src/HandPointer/HandPointer.cpp b/mariusz/src/HandPointer/HandPointer.cpp index b12cb44..b4594d3 100644 --- a/mariusz/src/HandPointer/HandPointer.cpp +++ b/mariusz/src/HandPointer/HandPointer.cpp @@ -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); diff --git a/mariusz/src/HandPointer/Media.cpp b/mariusz/src/HandPointer/Media.cpp index cbeada5..ca8acf7 100644 --- a/mariusz/src/HandPointer/Media.cpp +++ b/mariusz/src/HandPointer/Media.cpp @@ -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 Media::getResolution() { std::pair 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; diff --git a/mariusz/src/HandPointer/Media.hpp b/mariusz/src/HandPointer/Media.hpp index fdb27d5..fa27a2d 100644 --- a/mariusz/src/HandPointer/Media.hpp +++ b/mariusz/src/HandPointer/Media.hpp @@ -37,6 +37,7 @@ private: int currYR; int currXM; int currYM; + std::pair res; }; #endif /* MOUSE_HPP */