Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import h5py
- import cv2
- from extract_nvm import extract
- class Data():
- def __init__(self):
- self.coordinates = np.zeros((1,7))
- self.images = np.zeros((1,480,640,3))
- def load(self):
- pass
- def save(self, dset_name):
- self.images = np.asarray(self.images)
- self.coordinates = np.array(self.coordinates, dtype='float16')
- h5f = h5py.File(dset_name, 'w')
- h5f.create_dataset('X', data=self.images)
- h5f.create_dataset('Y', data=self.coordinates)
- h5f.close()
- def string_from_integer(integer):
- integer = str(integer)
- initial_string = ""
- initial_string += "0"*(4-len(integer))
- initial_string += integer
- return initial_string
- X, Y = extract("/home/mpcr/Desktop/rodrigo-sfm/dataset/fau-routes-6.nvm")
- d = Data()
- image_batch = np.zeros((1,480,640,3))
- coordinate_batch = np.zeros((1,7))
- for i in range(1,len(X)):
- fname = "/home/mpcr/Desktop/rodrigo-sfm/dataset/fau-route-6/output_{}.jpg".format(string_from_integer(i))
- print(fname)
- image = cv2.imread(fname)
- coordinates = np.asarray(Y[i])
- print(d.images.shape)
- print(image.shape)
- print(d.coordinates.shape)
- print(coordinates.shape)
- d.images = np.concatenate((d.images, [image]))
- d.coordinates = np.concatenate((d.coordinates, [coordinates]))
- d.save("/home/mpcr/Desktop/rodrigo-sfm/dataset/fau-route-6/dataset1.h5")
Add Comment
Please, Sign In to add comment