Make hand gesture recogniser and test work on frames
This commit is contained in:
@@ -3,18 +3,8 @@ import numpy as np
|
|||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
class SimpleHandRecogniser(HandRecogniser):
|
class SimpleHandRecogniser(HandRecogniser):
|
||||||
def __init__(self, image_path = ""):
|
def __init__(self, frame):
|
||||||
self._image_path = image_path
|
self.img = frame
|
||||||
|
|
||||||
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 __calc_pos_y(self, x, radius, centre):
|
def __calc_pos_y(self, x, radius, centre):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from GestureRecognition.SimpleHandRecogniser import SimpleHandRecogniser
|
from GestureRecognition.SimpleHandRecogniser import SimpleHandRecogniser
|
||||||
|
import cv2
|
||||||
|
|
||||||
class TestSimpleHandRecogniser(unittest.TestCase):
|
class TestSimpleHandRecogniser(unittest.TestCase):
|
||||||
|
|
||||||
def test_5_digits(self):
|
def test_5_digits(self):
|
||||||
self.recogniser.load_image(self.image_path_5)
|
self.assertEqual(self.recogniser_5.get_gesture(), 5)
|
||||||
self.assertEqual(self.recogniser.get_gesture(), 5)
|
|
||||||
|
|
||||||
def test_3_digits(self):
|
def test_3_digits(self):
|
||||||
self.recogniser.load_image(self.image_path_3)
|
self.assertEqual(self.recogniser_3.get_gesture(), 3)
|
||||||
self.assertEqual(self.recogniser.get_gesture(), 3)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.image_path_5 = "H:\car\GestureRecognition\IMG_0818.png"
|
self.recogniser_3 = SimpleHandRecogniser(cv2.imread("H:\car\GestureRecognition\IMG_0825.jpg"))
|
||||||
self.image_path_3 = "H:\car\GestureRecognition\IMG_0825.jpg"
|
self.recogniser_5 = SimpleHandRecogniser(cv2.imread("H:\car\GestureRecognition\IMG_0818.png"))
|
||||||
self.recogniser = SimpleHandRecogniser()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
Reference in New Issue
Block a user