Skip to content

Instantly share code, notes, and snippets.

@cooncesean
Created June 24, 2013 23:39
Show Gist options
  • Save cooncesean/5854710 to your computer and use it in GitHub Desktop.
Save cooncesean/5854710 to your computer and use it in GitHub Desktop.
Sample API for how I envision the GoPro interface working.
class GoProInterface(object):
"""
This is a sample API (written in Python) of how I envision
the calls to be made to the firmware.
Sample (Python) Usage:
>>> gpi = GoProInterface('~/gopro/videos/')
>>> gpi.start()
>>> gpi.stop()
/Users/sean/gopro/videos/0001.m4v
"""
def __init__(self, file_path_to_saved_videos):
"""
@file_path_for_videos => (string) The path on the connected computer
to which the GoPro files will be saved.
"""
self.file_path_to_saved_videos = file_path_to_saved_videos
self.recording = False
print 'Establishing connection with the connected GoPro Hero2 via USB.'
print 'Video files will be saved to: `%s`' % file_path_for_videos
print 'You may now issue start()/stop() commands'
def start(self):
"""
Issues the `start` recording command to the GoPro. Asserts that the GoPro isn't
already recording another video before issuing the `start` command.
"""
if self.recording == True:
print 'You are currently recording a video. You cannot issue the `start()` command until you `stop` your current recording.'
return
print 'Issuing `record` command to GoPro Hero2.'
self.recording = True
def stop(self):
" Issues the `stop` recording command to the GoPro. Returns the path to the file on disk. "
print 'Issuing `stop` command to GoPro Hero2.'
self.recording = False
print 'Saving file to disk'
return self.file_path_for_videos + some_file_name.m4v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment