Exemplo n.º 1
0
 def test_use_full_camera_bounds_y(self):
     pzs = PanZoomState(640, 480, 10, 640, 960)
     bounds = pzs.compute_bounds()
     self.assertEqual(1, pzs.zoom_level, "wrong zoom level")
     self.assertEqual(0, bounds.dx, "wrong dx")
     self.assertEqual(0, bounds.dy, "wrong dy")
     self.assertEqual(640, bounds.width, "wrong width")
     self.assertEqual(480, bounds.height, "wrong height")
Exemplo n.º 2
0
 def test_no_unused_display_real_estate_y(self):
     pzs = PanZoomState(640, 480, 10, 640, 960)
     pzs.zoom(1)
     bounds = pzs.compute_bounds()
     self.assertEqual(2, pzs.zoom_level, "wrong zoom level")
     self.assertEqual(160, bounds.dx, "wrong dx")
     self.assertEqual(0, bounds.dy, "wrong dy")
     self.assertEqual(320, bounds.width, "wrong width")
     self.assertEqual(480, bounds.height, "wrong height")
Exemplo n.º 3
0
touch_input_handler = None
try:
    ret, frame = cap.read()
    if frame is None:
        print("Failed to capture from device " + video_device + " => Aborting execution")
        sys.exit(-1)

    cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN | cv2.WINDOW_GUI_NORMAL)
    cv2.setWindowProperty("window", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)

    display_width = get_monitors()[0].width
    display_height = get_monitors()[0].height
    ratio = display_width / display_height

    height, width, channels = frame.shape
    pan_zoom_state = PanZoomState(width, height, 10, display_width, display_height)
    pan_zoom_state.zoom_level = runtime_settings.zoom

    touch_input_handler = TouchInputHandler(pan_zoom_state)
    Thread(target=touch_input_handler.listen, args=()).start()

    smooth_scroll_step_count = config.smooth_scroll_step_count
    smooth_transition_state = SmoothTransitionState(
        pan_zoom_state.pos_x,
        pan_zoom_state.pos_x,
        pan_zoom_state.pos_y,
        pan_zoom_state.pos_y,
        smooth_scroll_step_count
    )

    while True:
Exemplo n.º 4
0
 def test_pan_beyond_top_limit(self):
     pzs = PanZoomState(640, 480, 10, 1280, 960)
     pzs.zoom(1)
     pzs.pan(0, -250)
     self.assertEqual(320, pzs.pos_x, "wrong x")
     self.assertEqual(120, pzs.pos_y, "wrong y")
Exemplo n.º 5
0
 def test_pan_beyond_left_limit(self):
     pzs = PanZoomState(640, 480, 10, 1280, 960)
     pzs.zoom(1)
     pzs.pan(-330, 0)
     self.assertEqual(160, pzs.pos_x, "wrong x")
     self.assertEqual(240, pzs.pos_y, "wrong y")
Exemplo n.º 6
0
 def test_initial_zoom(self):
     pzs = PanZoomState(640, 480, 10, 1920, 1080)
     self.assertEqual(1, pzs.min_zoom_level)
     self.assertEqual(pzs.min_zoom_level, pzs.zoom_level)
Exemplo n.º 7
0
 def test_pan(self):
     pzs = PanZoomState(640, 480, 10, 1280, 960)
     pzs.zoom(1)
     pzs.pan(40, 20)
     self.assertEqual(360, pzs.pos_x, "wrong x")
     self.assertEqual(260, pzs.pos_y, "wrong y")
Exemplo n.º 8
0
 def test_pan_unzoomed(self):
     pzs = PanZoomState(640, 480, 10, 640, 640)
     pzs.pan(100, 100)
     self.assertLessEqual(320, pzs.pos_x, "wrong x")
     self.assertLessEqual(240, pzs.pos_y, "wrong y")
Exemplo n.º 9
0
 def test_max_zoom(self):
     pzs = PanZoomState(640, 480, 10, 1920, 1080)
     pzs.zoom(20)
     self.assertEqual(10, pzs.zoom_level)
Exemplo n.º 10
0
 def test_min_zoom(self):
     pzs = PanZoomState(640, 480, 10, 1920, 1080)
     pzs.zoom(-1.1)
     self.assertEqual(pzs.min_zoom_level, pzs.zoom_level)
Exemplo n.º 11
0
 def test_excessive_width(self):
     pzs = PanZoomState(660, 480, 10, 640, 480)
     self.assertEqual(20, pzs.excessive_width, "wrong excessive width")
     self.assertEqual(0, pzs.excessive_height, "wrong excessive width")
Exemplo n.º 12
0
 def test_perfect_aspect(self):
     pzs = PanZoomState(640, 480, 10, 640, 480)
     self.assertEqual(0, pzs.excessive_width, "wrong excessive width")
     self.assertEqual(0, pzs.excessive_height, "wrong excessive width")
Exemplo n.º 13
0
 def test_initial_pos_zoomed(self):
     pzs = PanZoomState(640, 480, 10, 1280, 960)
     self.assertEqual(320, pzs.pos_x, "wrong x")
     self.assertEqual(240, pzs.pos_y, "wrong y")