def record_frame(self, image_buffer, angle, throttle):
'''
Record a single image buffer, with frame index, angle and throttle values
as its filename
'''
# throttle is inversed, i.e. forward is negative, backwards positive
# we are only interested in forward values of throttle
# angle is counter-clockwise, i.e. left is positive
# TODO: make a proper value mapping here, and then transform
if (throttle * -1.0 < config.recording.throttle_threshold or
abs(angle) < config.recording.steering_threshold):
self.is_recording = False
return
self.is_recording = True
file_angle = int(angle * 10)
file_throttle = int(throttle * 1000)
filepath = self.create_img_filepath(
self.instance_path,
self.frame_count,
file_angle,
file_throttle)
with open(filepath, 'w') as fd:
image_buffer.seek(0)
shutil.copyfileobj(image_buffer, fd, -1)
self.frame_count += 1
评论列表
文章目录