How to use screenshot_cv2 method in ATX

Best Python code snippet using ATX

DeviceCtrol.py

Source:DeviceCtrol.py Github

copy

Full Screen

...114 adb.keyevent(keymap[c])115 return 'break'116 self.canvas.bind('<Key>', on_key)117 def _refresh_screen(self):118 img = adb.screenshot_cv2()119 if scale != 1.0:120 h, w = img.shape[:2]121 h, w = int(scale * h), int(scale * w)122 img = cv2.resize(img, (w, h))123 self.image = Image.fromarray(img[:, :, ::-1])124 self.tkimage = ImageTk.PhotoImage(self.image)125 w, h = self.image.size126 self.canvas.config(width=w, height=h)127 if self.canvas_image is None:128 self.canvas_image = self.canvas.create_image(0, 0, anchor=tk.NW, image=self.tkimage)129 else:130 self.canvas.itemconfig(self.canvas_image, image=self.tkimage)131 self.root.after(10, self._refresh_screen)132 def run(self):133 self._refresh_screen()134 self.root.mainloop()135 s = Screen()136 img = adb.screenshot_cv2()137 while img is None:138 time.sleep(1)139 img = adb.screenshot_cv2()140 s.run()141def screen_simple(host, port, serial, scale=0.5):142 adb = get_adb(host, port, serial)143 img = adb.screenshot_cv2()144 while img is None:145 time.sleep(1)146 img = adb.screenshot_cv2()147 print 'Press Ctrl-C or Esc to quit.'148 winname = 'Sync Screen'149 cv2.namedWindow(winname)150 while True:151 try:152 img = adb.screenshot_cv2()153 if scale != 1.0:154 h, w = img.shape[:2]155 h, w = int(scale * h), int(scale * w)156 img = cv2.resize(img, (w, h))157 cv2.imshow(winname, img)158 key = cv2.waitKey(10)159 if key == 27: # Escape160 break161 except KeyboardInterrupt:162 print 'Done'163 break164 except:165 traceback.print_exc()166 break...

Full Screen

Full Screen

screen.py

Source:screen.py Github

copy

Full Screen

...114 adb.keyevent(keymap[c])115 return 'break'116 self.canvas.bind('<Key>', on_key)117 def _refresh_screen(self):118 img = adb.screenshot_cv2()119 if scale != 1.0:120 h, w = img.shape[:2]121 h, w = int(scale * h), int(scale * w)122 img = cv2.resize(img, (w, h))123 self.image = Image.fromarray(img[:, :, ::-1])124 self.tkimage = ImageTk.PhotoImage(self.image)125 w, h = self.image.size126 self.canvas.config(width=w, height=h)127 if self.canvas_image is None:128 self.canvas_image = self.canvas.create_image(0, 0, anchor=tk.NW, image=self.tkimage)129 else:130 self.canvas.itemconfig(self.canvas_image, image=self.tkimage)131 self.root.after(10, self._refresh_screen)132 def run(self):133 self._refresh_screen()134 self.root.mainloop()135 s = Screen()136 img = adb.screenshot_cv2()137 while img is None:138 time.sleep(1)139 img = adb.screenshot_cv2()140 s.run()141def screen_simple(host, port, serial, scale=0.5):142 adb = get_adb(host, port, serial)143 img = adb.screenshot_cv2()144 while img is None:145 time.sleep(1)146 img = adb.screenshot_cv2()147 print 'Press Ctrl-C or Esc to quit.'148 winname = 'Sync Screen'149 cv2.namedWindow(winname)150 while True:151 try:152 img = adb.screenshot_cv2()153 if scale != 1.0:154 h, w = img.shape[:2]155 h, w = int(scale * h), int(scale * w)156 img = cv2.resize(img, (w, h))157 cv2.imshow(winname, img)158 key = cv2.waitKey(10)159 if key == 27: # Escape160 break161 except KeyboardInterrupt:162 print 'Done'163 break164 except:165 traceback.print_exc()166 break...

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