def get_matrix_from_annotations(s3_bucket_name, annotation_path): if not annotation_path.endswith('.json'): raise ValueError('Cannot read from non json annotation file') fm = FileManager(s3_bucket_name) im_data = fm.read_image_dict('', annotation_path) M = im_data.get('warp', {}).get('M', {}) if not M: return None M = np.array(M, dtype=np.float32).reshape(9) return M
from utils.display import Display from utils.file_manager import FileManager from utils.warp_tools import * from utils.rink_specs import HockeyRink import random import cv2 fm = FileManager('bsivisiondata') d = Display() annotations = fm.get_folder_list('PHI-PIT_6m-8m/annotations', extension_filter='json') # random.shuffle(annotations) for f in annotations: print f im_dict = fm.read_image_dict('PHI-PIT_6m-8m/annotations', f) if not 'warp' in im_dict: continue imname = f.split('.')[0] + '.png' im = fm.read_image_file('PHI-PIT_6m-8m/frames', imname) im = cv2.cvtColor(im, cv2.COLOR_RGB2BGR) H = np.array(im_dict['warp']['M']) hr = HockeyRink() scaled_H = scale_homography(H, 600, 300) H1280 = scale_homography(H, 1280, 720) ''' NEEDED TO BE RESIZING IMAGES BEFORE CALLING WARP!!! '''