def _find_sift_in_predict_area(self, image, screen): if not self.record_pos: return None # calc predict area in screen image_wh, screen_resolution = aircv.get_resolution( image), aircv.get_resolution(screen) xmin, ymin, xmax, ymax = Predictor.get_predict_area( self.record_pos, image_wh, self.resolution, screen_resolution) # crop predict image from screen predict_area = aircv.crop_image(screen, (xmin, ymin, xmax, ymax)) if not predict_area.any(): return None # find sift in that image ret_in_area = aircv.find_sift(predict_area, image, threshold=self.threshold, rgb=self.rgb) # calc cv ret if found if not ret_in_area: return None ret = deepcopy(ret_in_area) if "rectangle" in ret: for idx, item in enumerate(ret["rectangle"]): ret["rectangle"][idx] = (item[0] + xmin, item[1] + ymin) ret["result"] = (ret_in_area["result"][0] + xmin, ret_in_area["result"][1] + ymin) return ret
def _find_sift_in_predict_area(self, image, screen): if not self.record_pos: return None # calc predict area in screen screen_resolution = aircv.get_resolution(screen) xmin, ymin, xmax, ymax = Predictor.get_predict_area(self.record_pos, screen_resolution) # crop predict image from screen predict_area = aircv.crop_image(screen, (xmin, ymin, xmax, ymax)) # aircv.show(predict_area) # find sift in that image ret_in_area = aircv.find_sift(predict_area, image, threshold=self.threshold, rgb=self.rgb) # calc cv ret if found if not ret_in_area: return None ret = deepcopy(ret_in_area) ret["result"] = (ret_in_area["result"][0] + xmin, ret_in_area["result"][1] + ymin) return ret
def _find_sift(self, image, screen): return aircv.find_sift(screen, image, threshold=self.threshold, rgb=self.rgb)