def test_locate_characters(self): m = Matcher() self.assertTrue(m.loadImage("../img/virtualkeyb_lowercase.png")) chars = "qwertyuiopasdfghjklzxcvbnm" bbox = m.match(icon="../img/keyboardarea.png").bbox[0] result = m.locateCharacters(characters=chars, searcharea=bbox) self.assertTrue(result.result[0] == 100)
def test_negative(self): m = Matcher() result = m.match(icon="") self.assertTrue(result.result[0] == -6) result = m.match(None, None) self.assertTrue(result.result[0] == -6) result = m.match() self.assertTrue(result.result[0] == -6)
def test_OCR_multiple(self): m = Matcher() result = m.match("../img/quick_settings.png", "OFF", 100, "OCR", maxlocations=3) self.assertTrue(result.result[0] == 100) self.assertTrue(result.result[1] == 100) self.assertTrue(result.result[2] == 100) result = m.match("../img/quick_settings.png", "ON", 100, "OCR", maxlocations=3) self.assertTrue(result.result[0] == 100) self.assertTrue(result.result[1] == 100) self.assertTrue(result.result[2] == 100)
def test_OCR_different_fonts(self): m = Matcher() print "NOTE: tesseract prints noise" #m.loadImage("../img/homescreen2.png") result = m.match("../img/homescreen2.png", "SONERA", 100, "OCR") self.assertTrue(result.result[0] == 83) result = m.match("../img/homescreen2.png", "Google", 100, "OCR") self.assertTrue(result.result[0] == 100) result = m.match("../img/homescreen2.png", "SmartActions", 100, "OCR") self.assertTrue(result.result[0] == 100)
def test_multipletemplatematch(self): m = Matcher() result = m.match("../img/quick_settings.png", "../img/icon_tickon.png", 99, "MATCHTEMPLATE", maxlocations=2, scale_factor=1) self.assertTrue(result.result[0] == 99) self.assertTrue(result.result[1] == 99) #printresult(result, 2) result = m.match("../img/quick_settings.png", "../img/icon_tickon.png", 99, "SOBEL", maxlocations=2, scale_factor=1) self.assertTrue(result.result[0] == 99) self.assertTrue(result.result[1] == 99)
def test_templatematch(self): m = Matcher() result = m.match("../img/appgrid.png", "../img/icon_clockworktomato.png", 100, "MATCHTEMPLATE") self.assertTrue(result.result[0] == 100) result = m.match("../img/appgrid.png", "../img/icon_browser.png", 100, "MATCHTEMPLATE") self.assertTrue(result.result[0] == 99) result = m.match("../img/appgrid.png", "../img/icon_gplus.png", 100, "MATCHTEMPLATE") self.assertTrue(result.result[0] == 99)
def test_featurematch(self): m = Matcher() result = m.match("../img/appgrid.png", "../img/icon_clockworktomato.png", 100, "FEATURE", resultimage="/tmp/test.jpg") self.assertTrue(result.result[0] == 83) result = m.match("../img/appgrid.png", "../img/icon_browser.png", 100, "FEATURE", resultimage="/tmp/test1.jpg") self.assertTrue(result.result[0] == 93) result = m.match("../img/appgrid.png", "../img/icon_gplus.png", 100, "FEATURE", resultimage="/tmp/test2.jpg") self.assertTrue(result.result[0] == 86)
def test_OCR_sentences(self): m = Matcher() result = m.match("../img/virtualkeyb_lowercase.png", "The conversation will appear here.", 100, "OCR") self.assertTrue(result.result[0] == 100) result = m.match("../img/virtualkeyb_lowercase.png", "New message", 100, "OCR") self.assertTrue(result.result[0] == 100) result = m.match("../img/virtualkeyb_lowercase.png", "Compose message", 100, "OCR") self.assertTrue(result.result[0] == 100) result = m.match("../img/virtualkeyb_lowercase.png", "qwertyuiop", 90, "OCR") self.assertTrue(result.result[0] == 90) result = m.match("../img/virtualkeyb_lowercase.png", "z", 100, "OCR") self.assertTrue(result.result[0] == 100)
def test_loadunload(self): m = Matcher() # could be in setUp() but m shorter than self.m self.assertTrue(m.loadImage("../img/homescreen.png")) self.assertTrue(m.loadImage("../img/appgrid.png")) self.assertTrue(m.loadImage("../img/virtualkeyb_lowercase.png")) result = m.match("../img/homescreen.png", "../img/icon_appgrid.png", 100, "FEATURE") #printresult(result) m.unloadImage("../img/homescreen.png") m.unloadImage("../img/appgrid.png") m.unloadImage("../img/virtualkeyb_lowercase.png")
def test_load_before_matching(self): m = Matcher() self.assertTrue(m.loadImage("../img/homescreen.png")) result = m.match(icon="../img/icon_appgrid.png") self.assertTrue(result.result[0] == 51)
def test_locate_in_search_area(self): m = Matcher() bbox = Rect(100, 500, 300, 400) result = m.match("../img/homescreen.png", "../img/icon_appgrid.png", searcharea=bbox) self.assertTrue(result.result[0] == 51)
def test_locate_inside_region_of_interest(self): m = Matcher() result = m.match("../img/quick_settings.png", "../img/icon_tickon.png", 0, "MATCHTEMPLATE", "../img/roi_bluetooth_settings.png") self.assertTrue(result.result[0] == 97)
def test_edgedetection(self): m = Matcher() result = m.match("../img/appgrid.png", "../img/icon_clockworktomato.png", 0, "SOBEL") self.assertTrue(result.result[0] == 99)
def test_verifyimage(self): m = Matcher(mvconfig) result = m.match("../img/homescreen.png", "../img/homescreen.png", 0)