Best Python code snippet using Airtest
aircv.py
Source:aircv.py
...42 """43 彿°ä½¿å¾çå¯é¡ºæ¶éæéæ¶éæè½¬90ã180ã270度.44 é»è®¤clockwise=Trueï¼é¡ºæ¶éæè½¬45 """46 def count_clock_rotate(img):47 # éæ¶éæè½¬90°48 rows, cols = img.shape[:2]49 rotate_img = np.zeros((cols, rows))50 rotate_img = cv2.transpose(img)51 rotate_img = cv2.flip(rotate_img, 0)52 return rotate_img53 # å°è§åº¦æè½¬è½¬åä¸ºéæ¶éæè½¬90Â°çæ¬¡æ°:54 counter_rotate_time = (4 - angle / 90) % 4 if clockwise else (angle / 90) % 455 for i in range(int(counter_rotate_time)):56 img = count_clock_rotate(img)57 return img58def crop_image(img, rect):59 """60 åºåæªå¾ï¼åæ¶è¿åæªåç»æ å æªååç§»;61 Crop image , rect = [x_min, y_min, x_max ,y_max].62 (airtest䏿ç¨å°)63 """64 if isinstance(rect, (list, tuple)) and len(rect) == 4:65 height, width = img.shape[:2]66 # è·åå¨å¾åä¸çå®é
ææåºåï¼67 x_min, y_min, x_max, y_max = [int(i) for i in rect]68 x_min, y_min = max(0, x_min), max(0, y_min)69 x_min, y_min = min(width - 1, x_min), min(height - 1, y_min)70 x_max, y_max = max(0, x_max), max(0, y_max)...
cv.py
Source:cv.py
...45 """46 彿°ä½¿å¾çå¯é¡ºæ¶éæéæ¶éæè½¬90ã180ã270度.47 é»è®¤clockwise=Trueï¼é¡ºæ¶éæè½¬48 """49 def count_clock_rotate(img):50 # éæ¶éæè½¬90°51 rows, cols = img.shape[:2]52 rotate_img = np.zeros((cols, rows))53 rotate_img = cv2.transpose(img)54 rotate_img = cv2.flip(rotate_img, 0)55 return rotate_img56 # å°è§åº¦æè½¬è½¬åä¸ºéæ¶éæè½¬90Â°çæ¬¡æ°:57 counter_rotate_time = (58 4 - angle / 90) % 4 if clockwise else (angle / 90) % 459 for i in range(int(counter_rotate_time)):60 img = count_clock_rotate(img)61 return img62def crop_image(img, rect):63 """64 åºåæªå¾ï¼åæ¶è¿åæªåç»æ å æªååç§»;65 Crop image , rect = [x_min, y_min, x_max ,y_max].66 """67 if isinstance(rect, (list, tuple)):68 height, width = img.shape[:2]69 # è·åå¨å¾åä¸çå®é
ææåºåï¼70 x_min, y_min, x_max, y_max = [int(i) for i in rect]71 x_min, y_min = max(0, x_min), max(0, y_min)72 x_min, y_min = min(width - 1, x_min), min(height - 1, y_min)73 x_max, y_max = max(0, x_max), max(0, y_max)74 x_max, y_max = min(width - 1, x_max), min(height - 1, y_max)...
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!!