Skip to content

Commit

Permalink
dataset loadvideo sample_rate fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cr committed Jan 15, 2019
1 parent c597f3d commit fe5eb99
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ def to_tensor(self, buffer):

def loadvideo(self, fname):
# initialize a VideoCapture object to read video data into a numpy array
remainder = np.random.randint(self.frame_sample_rate)
capture = cv2.VideoCapture(fname)
frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
frame_width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
# create a buffer. Must have dtype float, so it gets converted to a FloatTensor by Pytorch later
frame_count_sample = (frame_count-remainder) // self.frame_sample_rate
frame_count_sample = frame_count // self.frame_sample_rate
buffer = np.empty((frame_count_sample, self.resize_height, self.resize_width, 3), np.dtype('float32'))

count = 0
retaining = True
sample_count = 0

remainder = np.random.randint(self.frame_sample_rate)
# read in each frame, one at a time into the numpy buffer array
while (count < frame_count and retaining):
retaining, frame = capture.read()
Expand Down

0 comments on commit fe5eb99

Please sign in to comment.