img = img[int(shape[0] / 3):shape[0] - 150, 0:shape[1]] # Resize the image img = cv2.resize(img, (params.img_w, params.img_h), interpolation=cv2.INTER_AREA) # Return the image sized as a 4D array return np.resize(img, (params.img_c, params.img_w, params.img_h)) # Process video for epoch_id in epoch_ids: print( '---------- processing video for epoch {} ----------'.format(epoch_id)) vid_path = utils.join_dir(params.data_dir, 'epoch{:0>2}_front.mkv'.format(epoch_id)) assert os.path.isfile(vid_path) frame_count = utils.frame_count(vid_path) cap = cv2.VideoCapture(vid_path) machine_steering = [] print('performing inference...') time_start = time.time() for frame_id in range(frame_count): ret, img = cap.read() assert ret # you can modify here based on your model img = img_pre_process(img) img = img[None, :, :, :] deg = float(model.predict(img, batch_size=1)) machine_steering.append(deg)
""" ## Chop off 1/3 from the top and cut bottom 150px(which contains the head of car) shape = img.shape img = img[int(shape[0]/3):shape[0]-150, 0:shape[1]] ## Resize the image img = cv2.resize(img, (params.FLAGS.img_w, params.FLAGS.img_h), interpolation=cv2.INTER_AREA) ## Return the image sized as a 4D array return np.resize(img, (params.FLAGS.img_w, params.FLAGS.img_h, params.FLAGS.img_c)) ## Process video for epoch_id in epoch_ids: print('---------- processing video for epoch {} ----------'.format(epoch_id)) vid_path = utils.join_dir(params.data_dir, 'epoch{:0>2}_front.mkv'.format(epoch_id)) assert os.path.isfile(vid_path) frame_count = utils.frame_count(vid_path) cap = cv2.VideoCapture(vid_path) machine_steering = [] print('performing inference...') time_start = time.time() for frame_id in range(frame_count): ret, img = cap.read() assert ret ## you can modify here based on your model img = img_pre_process(img) img = img[None,:,:,:] deg = float(model.predict(img, batch_size=1)) machine_steering.append(deg)