Best Python code snippet using Airtest
keypoint_matching.py
Source: keypoint_matching.py
...44 rect, matches, good = self.get_rect_from_good_matches(im_source, im_search, kp_sch, des_sch, kp_src, des_src)45 if not rect:46 return None47 # 第ä¸æ¥, ä»å¹é
å¾çæªåç©éµèå´,并缩æ¾å°æ¨¡æ¿å¤§å°,è¿è¡æ¨¡æ¿å¹é
æ±åºç¸ä¼¼åº¦48 confidence = self._cal_confidence(im_source=im_source, im_search=im_search, rect=rect, rgb=rgb)49 best_match = generate_result(rect=rect, confi=confidence)50 return best_match if confidence > threshold else None51 @print_all_result52 def find_all(self, im_source, im_search, threshold: Union[int, float] = None,53 max_count: int = 10,54 rgb: bool = None):55 threshold = threshold or self.threshold56 rgb = rgb is None and self.rgb or rgb57 im_source, im_search = self.check_detection_input(im_source, im_search)58 if not im_source or not im_search:59 return None60 result = []61 # 第ä¸æ¥: è·åç¹å¾ç¹é62 kp_sch, des_sch = self.get_keypoints_and_descriptors(image=im_search.rgb_2_gray())63 kp_src, des_src = self.get_keypoints_and_descriptors(image=im_source.rgb_2_gray())64 while len(kp_src) > 2 or len(kp_sch) > 2:65 rect, matches, good = self.get_rect_from_good_matches(im_source, im_search,66 kp_sch, des_sch,67 kp_src, des_src)68 if not rect:69 break70 confidence = self._cal_confidence(im_source=im_source, im_search=im_search, rect=rect, rgb=rgb)71 if confidence > threshold and len(result) < max_count:72 result.append(generate_result(rect, confidence))73 kp_src, des_src = self.delect_good_descriptors(good, kp_src, des_src)74 kp_src, des_src = self.delect_rect_descriptors(rect, kp_src, des_src)75 return result76 def _cal_confidence(self, im_source, im_search, rect: Rect, rgb: bool):77 """ å°æªå¾åè¯å«ç»æ缩æ¾å°å¤§å°ä¸è´,并计ç®å¯ä¿¡åº¦ """78 try:79 target_img = im_source.crop_image(rect)80 except OverflowError:81 raise MatchResultError("Target area({}) out of screen{}".format(rect, im_source.size))82 h, w = im_search.size83 target_img.resize(w, h)84 if rgb:85 confidence = self.template.cal_rgb_confidence(im_source=im_search, im_search=target_img)86 else:87 confidence = self.template.cal_ccoeff_confidence(im_source=im_search, im_search=target_img)88 confidence = (1 + confidence) / 289 return confidence90 @staticmethod...
detect_id_card.py
Source: detect_id_card.py
...59def _dist(point, target):60 x, y = point61 m, n = target62 return np.sqrt((x - m) ** 2 + (y - n) ** 2)63def _cal_confidence(dist):64 # linear function. score decreases as the distance increases65 return -CONFIDENCE_RATE * dist + 166def is_id_card(crop_box, face_box, debug=False):67 xleft, xright, xtop, xbottom = crop_box68 yleft, yright, ytop, ybottom = face_box69 yleft += xleft70 yright += xleft71 ytop += xtop72 ybottom += xtop73 if debug:74 print('crop box: ', xleft, xright, xtop, xbottom)75 print('face box: ', yleft, yright, ytop, ybottom)76 crop_mid = _calc_mid(xleft, xright, xtop, xbottom)77 face_mid = _calc_mid(yleft, yright, ytop, ybottom)78 target = (xright + crop_mid[0]) // 2, crop_mid[1]79 return _cal_confidence(_dist(face_mid, target))80def id_card_detect(img, args):81 sess, detection_graph, category_index = args82 tensors = get_tensors(detection_graph)83 try:84 # crop85 cropped_img, crop_box, score = crop_id(img, sess, tensors, category_index)86 except:87 import traceback88 traceback.print_exc()89 return None, 090 return cropped_img if cropped_img is not None else None, score91if __name__ == "__main__":92 img = cv.imread('test_samples/1121.png')93 args = load_model()...
Check out the latest blogs from LambdaTest on this topic:
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
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!!