def main(): parser = argparse.ArgumentParser() parser.add_argument('images_dir', type=str) parser.add_argument('results_file', type=str) args = parser.parse_args() im_dir = Path('./numbers_letters/') im_paths = sorted([ im_path for im_path in im_dir.iterdir() if im_path.name.endswith('.jpeg') ]) images_dir = Path(args.images_dir) results_file = Path(args.results_file) images_paths = sorted([ image_path for image_path in images_dir.iterdir() if image_path.name.endswith('.jpg') ]) results = {} for image_path in images_paths: image = cv2.imread(str(image_path)) if image is None: print(f'Error loading image {image_path}') continue results[image_path.name] = perform_processing(image, im_paths) with results_file.open('w') as output_file: json.dump(results, output_file, indent=4)
def main(): parser = argparse.ArgumentParser() parser.add_argument('images_dir', type=str) parser.add_argument('results_file', type=str) args = parser.parse_args() images_dir = Path(args.images_dir) results_file = Path(args.results_file) images_paths = sorted([image_path for image_path in images_dir.iterdir() if image_path.name.endswith('.jpg')]) results = {} t1_start = perf_counter() for image_path in images_paths: image = cv2.imread(str(image_path)) if image is None: print(f'Error loading image {image_path}') continue results[image_path.name] = perform_processing(image) t1_stop = perf_counter() print("Elapsed time during the whole program in seconds:",t1_stop - t1_start) # print("liczba zdjec:", i) with results_file.open('w') as output_file: json.dump(results, output_file, indent=4)
def main(): parser = argparse.ArgumentParser() parser.add_argument('input_file', type=str) parser.add_argument('results_file', type=str) args = parser.parse_args() input_file = Path(args.input_file) results_file = Path(args.results_file) with open(input_file) as f: arguments = json.load(f) start = pd.Timestamp(arguments['start']).tz_localize('UTC') stop = pd.Timestamp(arguments['stop']).tz_localize('UTC') df_temperature = pd.read_csv(arguments['file_temperature'], index_col=0, parse_dates=True) df_target_temperature = pd.read_csv(arguments['file_target_temperature'], index_col=0, parse_dates=True) df_valve = pd.read_csv(arguments['file_valve_level'], index_col=0, parse_dates=True) df_combined = pd.concat([ df_temperature[df_temperature['serialNumber'] == arguments['serial_number']].rename( columns={'value': 'temperature'}), df_target_temperature.rename(columns={'value': 'target_temperature'}), df_valve.rename(columns={'value': 'valve_level'}) ]) df_combined_resampled = df_combined.resample( pd.Timedelta(minutes=15), label='right').mean().fillna(method='ffill') df_combined_resampled = df_combined_resampled.loc[start:stop] df_combined_resampled['predicted_temperature'] = 0.0 df_combined_resampled['predicted_valve_level'] = 0.0 current = start - pd.DateOffset(minutes=15) while current < stop: predicted_temperature, predicted_valve_level = perform_processing( df_temperature.loc[(current - pd.DateOffset(days=7)):current], df_target_temperature.loc[(current - pd.DateOffset(days=7)):current], df_valve.loc[(current - pd.DateOffset(days=7)):current], arguments['serial_number']) current = current + pd.DateOffset(minutes=15) df_combined_resampled.at[ current, 'predicted_temperature'] = predicted_temperature df_combined_resampled.at[ current, 'predicted_valve_level'] = predicted_valve_level df_combined_resampled.to_csv(results_file)
def main(): parser = argparse.ArgumentParser() parser.add_argument('images_dir', type=str) parser.add_argument('results_file', type=str) args = parser.parse_args() images_dir = Path(args.images_dir) results_file = Path(args.results_file) images_paths = sorted([ image_path for image_path in images_dir.iterdir() if image_path.name.endswith('.jpg') ]) results = {} template = [] sign = [] #start = time.perf_counter() templete_dir = Path("./szablon/") template_paths = sorted([ image_path for image_path in templete_dir.iterdir() if image_path.name.endswith('.jpg') ]) for template_path in template_paths: temp = cv2.imread(str(template_path), 0) l = len(str(template_path)) s = str(template_path)[l - 5:l - 4] sign.append(s) template.append(temp) for image_path in images_paths: image = cv2.imread(str(image_path)) if image is None: print(f'Error loading image {image_path}') continue results[image_path.name] = perform_processing(image, template, sign) # end = time.perf_counter() # print("Czas: " + str(round(end-start,2)) + "s.") with results_file.open('w') as output_file: json.dump(results, output_file, indent=4)