Make hand gesture recogniser and test work on frames

This commit is contained in:
DSTO\pivatom
2018-12-18 14:24:33 +10:30
parent 363122fe29
commit 11604228fc
2 changed files with 7 additions and 19 deletions

View File

@@ -3,18 +3,8 @@ import numpy as np
import cv2
class SimpleHandRecogniser(HandRecogniser):
def __init__(self, image_path = ""):
self._image_path = image_path
def load_image(self, image_path = None):
"""
Loads the given image path into memory. This must be called before
any other operations can be completed.
"""
if image_path is not None:
self._image_path = image_path
self.img = cv2.imread(self._image_path, 1)
self.img = cv2.resize(self.img, None, fx=0.1, fy=0.1, interpolation = cv2.INTER_AREA)
def __init__(self, frame):
self.img = frame
def __calc_pos_y(self, x, radius, centre):
"""

View File

@@ -1,20 +1,18 @@
import unittest
from GestureRecognition.SimpleHandRecogniser import SimpleHandRecogniser
import cv2
class TestSimpleHandRecogniser(unittest.TestCase):
def test_5_digits(self):
self.recogniser.load_image(self.image_path_5)
self.assertEqual(self.recogniser.get_gesture(), 5)
self.assertEqual(self.recogniser_5.get_gesture(), 5)
def test_3_digits(self):
self.recogniser.load_image(self.image_path_3)
self.assertEqual(self.recogniser.get_gesture(), 3)
self.assertEqual(self.recogniser_3.get_gesture(), 3)
def setUp(self):
self.image_path_5 = "H:\car\GestureRecognition\IMG_0818.png"
self.image_path_3 = "H:\car\GestureRecognition\IMG_0825.jpg"
self.recogniser = SimpleHandRecogniser()
self.recogniser_3 = SimpleHandRecogniser(cv2.imread("H:\car\GestureRecognition\IMG_0825.jpg"))
self.recogniser_5 = SimpleHandRecogniser(cv2.imread("H:\car\GestureRecognition\IMG_0818.png"))
if __name__ == '__main__':
unittest.main()