mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-20 20:09:11 +00:00
ReventWorkload: Modified statedection to vary scale of images
Due to inaccuracies in revent playback, the resultant state does not always match the templates precisely causing state detection to fail. To help this images are now scaled to different sizes before being matched to the templates to compensate for slight variations in size.
This commit is contained in:
parent
7af5868c22
commit
1daa7f97c0
@ -91,14 +91,24 @@ def match_state(screenshot_file, defpath, state_definitions): # pylint: disable
|
||||
for template_png in template_list:
|
||||
template = cv2.imread(os.path.join(defpath, 'templates', template_png + '.png'), 0)
|
||||
template_edge = auto_canny(template)
|
||||
template_height, template_width = template_edge.shape[:2]
|
||||
|
||||
res = cv2.matchTemplate(img_edge, template_edge, cv2.TM_CCOEFF_NORMED)
|
||||
threshold = 0.5
|
||||
loc = np.where(res >= threshold)
|
||||
zipped = zip(*loc[::-1])
|
||||
# loop over the scales of the image
|
||||
for scale in np.linspace(1.4, 0.6, 61):
|
||||
resized = imutils.resize(img_edge, width=int(img_edge.shape[1] * scale))
|
||||
|
||||
if len(zipped) > 0:
|
||||
matched_templates.append(template_png)
|
||||
# skip if the resized image is smaller than the template
|
||||
if resized.shape[0] < template_height or resized.shape[1] < template_width:
|
||||
break
|
||||
|
||||
res = cv2.matchTemplate(resized, template_edge, cv2.TM_CCOEFF_NORMED)
|
||||
threshold = 0.4
|
||||
loc = np.where(res >= threshold)
|
||||
zipped = zip(*loc[::-1])
|
||||
|
||||
if len(zipped) > 0:
|
||||
matched_templates.append(template_png)
|
||||
break
|
||||
|
||||
# determine the state according to the matched templates
|
||||
matched_state = "none"
|
||||
|
Loading…
x
Reference in New Issue
Block a user