2
# Copyright (c) 2010 Canonical
4
# Written by Gustavo Niemeyer <gustavo@niemeyer.net>
6
# This file is part of the Xpresser GUI automation library.
8
# Xpresser is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU Lesser General Public License version 3,
10
# as published by the Free Software Foundation.
12
# Xpresser is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Lesser General Public License for more details.
17
# You should have received a copy of the GNU Lesser General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
DEFAULT_SIMILARITY = 0.98
28
@ivar name: The human-oriented name of this image. May be None.
30
@ivar similarity: The similarity tolerance to be used when searching
33
Varies between 0.0 and 1.0, where 1.0 is a perfect match. Defaults
34
to the value of DEFAULT_SIMILARITY when not specified in the image
37
@ivar focus_delta: (dx, dy) pair added to the center position to
40
For instance, if the *center* of the image is found at 200, 300 and
41
the focus_point is (10, -20) the click will actually happen at the
42
screen position (210, 280).
44
When not specified, (0, 0) is assumed, which means click in the
45
center of the image itself.
47
@ivar width: The width of the image.
49
@ivar height: The height of the image.
51
@ivar filename: Filename of the image.
53
@ivar array: Numpy array with three dimensions (rows, columns, RGB).
55
@ivar cache: Generic storage for data associated with this image, used
56
by the image finder, for instance.
59
def __init__(self, name=None, similarity=None, focus_delta=None,
60
width=None, height=None, filename=None, array=None):
61
if similarity is None:
62
similarity = DEFAULT_SIMILARITY
63
if focus_delta is None:
66
if not (0 < similarity < 1):
67
raise ValueError("Similarity out of range: %.2f" % similarity)
70
self.similarity = similarity
71
self.focus_delta = focus_delta
74
self.filename = filename