import corner_dets_methods import os dir_name = r'ENTER THE DIR YOU WANT TO WALK' save_file = os.path.join(dir_name, 'roi_file.txt') for root, dirs, files in os.walk(dir_name): for file in files: print(file) path = os.path.join(dir_name, file) detections, found_dets = corner_dets_methods.find_contours( path, 20, .05, 15, 0.0) print(found_dets) # print(found_dets) if found_dets != []: x, y, _, w, h = found_dets[0] text = (file + ":ROI:" + str(y) + "," + str(int(y + h)) + "," + str(x) + "," + str(int(x + w)) + "\n") if os.path.exists(save_file): append_write = 'a' # append if already exists else: append_write = 'w' # make a new file if not with open(save_file, append_write) as text_file: text_file.write(text)
def detection_funct(self, path): detections, found_dets = corner_dets_methods.find_contours( path, self.corner_num, self.quality, self.distance, self.detection_threshold) return detections, found_dets
def detection_funct(path): detections, found_dets = corner_dets_methods.find_contours( path, 20, 0.1, 15, -3.0) return detections, found_dets
import os import shutil import corner_dets_methods path = r'C:\Users\KinectProcessing\Desktop\test_mmse_classify\extracted_images\mmse_data' for _,_, file_list in os.walk(path): for file in file_list: filename = os.path.join(path, file) print(filename) detections, found_dets = corner_dets_methods.find_contours(filename, 50, .2, 2, 0) print(len(found_dets)) if found_dets != [] and len(found_dets) == 1: shutil.copy(filename, r'C:\Users\KinectProcessing\Desktop\new_potitves') print("copied")