Best Python code snippet using Airtest
mjpeg_cap.py
Source:mjpeg_cap.py
...84 # çå¾
ä¸ä¸æ¬¡éè¦è·åå±å¹æ¶ï¼åè¿è¡éè¿85 LOGGING.debug("mjpegsock is closed")86 self._is_running = False87 self.buf.close()88 return self.get_blank_screen()89 def get_frame(self):90 # è·å¾åå¼ å±å¹æªå¾91 return self.get_frame_from_stream()92 def snapshot(self, ensure_orientation=True, *args, **kwargs):93 """94 Take a screenshot and convert it into a cv2 image object95 è·åä¸å¼ å±å¹æªå¾ï¼å¹¶è½¬åæcv2çå¾å对象96 !!! 注æï¼è¯¥æ¹æ³æ¿å°çæªå¾å¯è½ä¸æ¯éåä¸ææ°çï¼é¤éä¸ç´å¨æ¶è´¹éåä¸çå¾åï¼å¦åå¯è½ä¼æ¯è¿å¾å¾åå
容ï¼è¯·è°¨æ
使ç¨97 Args:98 ensure_orientation: True or False whether to keep the orientation same as display99 Returns: numpy.ndarray100 """101 screen = self.get_frame_from_stream()102 try:103 screen = aircv.utils.string_2_img(screen)104 except Exception:105 # may be black/locked screen or other reason, print exc for debugging106 traceback.print_exc()107 return None108 if ensure_orientation:109 if self.ori_function:110 display_info = self.ori_function()111 orientation = next(key for key, value in ROTATION_MODE.items() if value == display_info["orientation"])112 screen = aircv.rotate(screen, -orientation, clockwise=False)113 return screen114 def get_blank_screen(self):115 """116 çæä¸ä¸ªé»å±å¾åï¼å¨è¿æ¥å¤±ææ¶ä»£æ¿å±å¹ç»é¢è¿å117 Returns:118 """119 if self.ori_function:120 display_info = self.ori_function()121 width, height = display_info['width'], display_info['height']122 if display_info["orientation"] in [90, 270]:123 width, height = height, width124 else:125 width, height = 1080, 1920126 img = numpy.zeros((width, height, 3)).astype('uint8')127 img_string = aircv.utils.img_2_string(img)128 return img_string...
test_ios_mjpeg.py
Source:test_ios_mjpeg.py
...52 cv2.imshow("test", img)53 c = cv2.waitKey(10)54 time.sleep(0.05)55 cv2.destroyAllWindows()56 def test_get_blank_screen(self):57 img_string = self.mjpeg_server.get_blank_screen()58 img = aircv.utils.string_2_img(img_string)59 aircv.show(img)60 def test_teardown_stream(self):61 self.mjpeg_server.get_frame()62 if self.mjpeg_server.port_forwarding is True:63 self.assertTrue(is_port_open(self.mjpeg_server.ip, self.mjpeg_server.port))64 self.mjpeg_server.teardown_stream()...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!