From 6d45dfebd2f0146e42778f9b0195ce788f7384a3 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Thu, 22 Jan 2015 20:50:43 +0100 Subject: configurable resolution --- client2.cpp | 22 ++++++++++++---------- server.py | 4 +++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/client2.cpp b/client2.cpp index 2ee78e7..8a140e2 100644 --- a/client2.cpp +++ b/client2.cpp @@ -22,6 +22,8 @@ using namespace cv; +#define CANVAS_WIDTH 1280 +#define CANVAS_HEIGHT 400 @@ -60,18 +62,18 @@ float vertices[] = { void calcVerticesRotated(int xshift, int yshift, float angle, float* v) { Point2f pt; - float scale = 0.4; + float scale = 0.2; pt = Point2f( -cos(angle)*1280./2 + sin(angle)*720./2, +sin(angle)*1280./2 + cos(angle)*720./2 ); - v[0]=v[20]=( pt.x + xshift)/1280 * scale; - v[1]=v[21]=( pt.y + yshift)/720 * scale; - v[8]=v[12]=(-pt.x + xshift)/1280 * scale; - v[9]=v[13]=(-pt.y + yshift)/720 * scale; + v[0]=v[20]=( pt.x + xshift)/CANVAS_WIDTH * scale; + v[1]=v[21]=( pt.y + yshift)/CANVAS_HEIGHT * scale; + v[8]=v[12]=(-pt.x + xshift)/CANVAS_WIDTH * scale; + v[9]=v[13]=(-pt.y + yshift)/CANVAS_HEIGHT * scale; pt = Point2f( cos(angle)*1280./2 + sin(angle)*720./2, -sin(angle)*1280./2 + cos(angle)*720./2 ); - v[4] =( pt.x + xshift)/1280 * scale; - v[5] =( pt.y + yshift)/720 * scale; - v[16]=(-pt.x + xshift)/1280 * scale; - v[17]=(-pt.y + yshift)/720 * scale; + v[4] =( pt.x + xshift)/CANVAS_WIDTH * scale; + v[5] =( pt.y + yshift)/CANVAS_HEIGHT * scale; + v[16]=(-pt.x + xshift)/CANVAS_WIDTH * scale; + v[17]=(-pt.y + yshift)/CANVAS_HEIGHT * scale; } @@ -135,7 +137,7 @@ GLFWwindow* initOpenGL() glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); - GLFWwindow* window = glfwCreateWindow(1280, 720, "OpenGL", NULL, NULL); // Windowed + GLFWwindow* window = glfwCreateWindow(CANVAS_WIDTH, CANVAS_HEIGHT, "OpenGL", NULL, NULL); // Windowed // GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL", glfwGetPrimaryMonitor(), nullptr); // Fullscreen glfwMakeContextCurrent(window); diff --git a/server.py b/server.py index 4e56790..8cb50c0 100644 --- a/server.py +++ b/server.py @@ -8,6 +8,8 @@ import threading import time import struct +OVERRIDE_THRESHOLD=0.01 + def putStatusText(img, text, pos, activated): cv2.putText(img, text, pos, cv2.FONT_HERSHEY_PLAIN, 1, (0,0,255) if activated else (127,127,127), 2 if activated else 1) @@ -144,7 +146,7 @@ while True: js_radius = math.sqrt(js_x**2 + js_y**2) if btn_leftshoulder==0: js_x, js_y = ( js_x * cos(rel_angle) + js_y * sin(rel_angle) ) , ( -js_x * sin(rel_angle) + js_y * cos(rel_angle) ) - + js_hover = (btn_rightshoulder==0 and (js_radius <= 0.01)) if (js_radius > OVERRIDE_THRESHOLD): manual_override_xy = True -- cgit v1.2.1