def get_data_stream(token): """ @return: [(img, (4 coordinates))] """ img_dir = get_images_directory(token) for f_idx, coords in load_annotations(token): img = cv2.imread(os.path.join(img_dir, "%08d.jpg" % f_idx)) coords = [(float(x) / img.shape[1], float(y) / img.shape[0]) for x, y in coords] yield (img, coords)
def get_data_stream(token): """ @return: [(img, (4 coordinates))] """ img_dir = get_images_directory(token) for idx, line in enumerate(open(token)): img = cv2.imread(os.path.join(img_dir, "%08d.jpg" % (idx + 1))) arr = map(int, map(float, line.strip().split(","))) coords = zip(arr[::2], arr[1::2]) coords = coords[1:] + coords[:1] coords = [(float(x) / img.shape[1], float(y) / img.shape[0]) for x, y in coords] yield (img, coords)
def get_data_stream(token): """ @return: [(img, (4 coordinates))] """ def process_line(line): if line.find(",") >= 0: return map(int, line.split(",")) else: return map(int, line.split("\t")) img_dir = get_images_directory(token) for idx, line in enumerate(open(token)): img = cv2.imread(os.path.join(img_dir, "%04d.jpg" % (idx + 1))) x, y, w, h = process_line(line.strip()) coords = [(x, y), (x + w, y), (x + w, y + h), (x, y + h)] coords = [(float(x) / img.shape[1], float(y) / img.shape[0]) for x, y in coords] yield (img, coords)