How to use _cal_scale method in ATX

Best Python code snippet using ATX

mixin.py

Source:mixin.py Github

copy

Full Screen

...128 if not safe:129 raise errors.ImageNotFoundError('Image not gone %s' % (pattern,))130 # def touch(self, x, y):131 # self.click(x, y)132 def _cal_scale(self, pattern=None):133 scale = 1.0134 resolution = (pattern and pattern.resolution) or self.resolution135 if resolution is not None:136 ow, oh = sorted(resolution)137 dw, dh = sorted(self.display)138 fw, fh = 1.0 * dw / ow, 1.0 * dh / oh139 # For horizontal screen, scale by Y (width)140 # For vertical screen, scale by X (height)141 scale = fw if self.rotation in (1, 3) else fh142 return scale143 @property144 def bounds(self):145 if self._bounds is None:146 return None147 return self._bounds * self._cal_scale()148 def match_all(self, pattern, threshold=None):149 pattern = self.pattern_open(pattern)150 search_img = pattern.image151 pattern_scale = self._cal_scale(pattern)152 if pattern_scale != 1.0:153 search_img = cv2.resize(search_img, (0, 0),154 fx=pattern_scale, fy=pattern_scale,155 interpolation=cv2.INTER_CUBIC)156 threshold = threshold or pattern.threshold or self.image_match_threshold157 screen = self.region_screenshot()158 screen = imutils.from_pillow(screen)159 points = ac.find_all_template(screen, search_img, threshold=threshold, maxcnt=10)160 return points161 def match(self, pattern, screen=None, rect=None, offset=None, threshold=None, method=None):162 pattern = self.pattern_open(pattern)163 search_img = pattern.image164 pattern_scale = self._cal_scale(pattern)165 if pattern_scale != 1.0:166 search_img = cv2.resize(search_img, (0, 0),167 fx=pattern_scale, fy=pattern_scale,168 interpolation=cv2.INTER_CUBIC)169 screen = screen or self.region_screenshot()170 threshold = threshold or pattern.threshold or self.image_match_threshold171 # handle offset if percent, ex (0.2, 0.8)172 dx, dy = offset or pattern.offset or (0, 0)173 dx = pattern.image.shape[1] * dx # opencv object width174 dy = pattern.image.shape[0] * dy # opencv object height175 dx, dy = int(dx * pattern_scale), int(dy * pattern_scale)176 # image match177 screen = imutils.from_pillow(screen) # convert to opencv image178 if rect and isinstance(rect, tuple) and len(rect) == 4:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful