In [1]:
import os
import time

import IPython
import ipywidgets

import data_io
from progress_bar import bar

import context

import gopro_helper as gopro

In [2]:
%load_ext autoreload
%autoreload 2

New Stuff


In [3]:
wid = gopro.GoProSettings()

In [4]:
wid.initialize()



In [7]:
wid.mode


Out[7]:
'video'

In [17]:
wid.set_mode_video()

In [9]:
wid.update_information()

In [20]:
wid.update_widgets()

In [13]:
gopro.commands.set_mode_video()

In [8]:
gopro.commands.set_mode_photo()

In [14]:
wid.update_information()

In [10]:
wid.update_information()

In [ ]:
wid._wid_box._

In [60]:
wid._wid_box.children=[]

In [55]:
status, settings = gopro.commands.get_raw_status_settings()

mode = gopro.status.current_mode(status)

mode


Out[55]:
'video'

In [32]:
fid = gopro.api._feature_id.video.FPS

fid


Out[32]:
3

In [33]:
name = gopro.api.feature_id_name(mode, fid)

name


Out[33]:
'FPS'

In [7]:
name, options = gopro.api.feature_choices('video', 4, include_empty=True)

name, options


Out[7]:
('Field of View',
 Struct([('-----', -1),
         ('Superview', 3),
         ('Wide', 0),
         ('Medium', 1),
         ('Linear', 4),
         ('Narrow', 2)]))

In [13]:
options['sf']=6

In [16]:
import numpy as np

In [17]:
np.sort(options)


---------------------------------------------------------------------------
AxisError                                 Traceback (most recent call last)
<ipython-input-17-1f89225d823d> in <module>()
----> 1 np.sort(options)

~/.virtualenvs/gopro/lib/python3.6/site-packages/numpy/core/fromnumeric.py in sort(a, axis, kind, order)
    820     else:
    821         a = asanyarray(a).copy(order="K")
--> 822     a.sort(axis=axis, kind=kind, order=order)
    823     return a
    824 

AxisError: axis -1 is out of bounds for array of dimension 0

In [35]:
value = 10

In [36]:
resp = gopro.commands.set_feature_value(fid, value)

In [43]:
w = gopro.feature_dropdown_widget(mode, fid, name)

In [44]:
w



In [54]:
w.value


Out[54]:
3

In [56]:
settings


Out[56]:
Struct([('1', 0),
        ('2', 9),
        ('3', 3),
        ('4', 0),
        ('5', 1),
        ('6', 1),
        ('7', 1),
        ('8', 1),
        ('9', 0),
        ('10', 1),
        ('11', 6),
        ('12', 0),
        ('13', 2),
        ('14', 2),
        ('15', 4),
        ('16', 0),
        ('17', 10),
        ('18', 4),
        ('19', 0),
        ('20', 0),
        ('21', 1),
        ('22', 1),
        ('23', 0),
        ('24', 1),
        ('25', 2),
        ('26', 4),
        ('27', 0),
        ('28', 0),
        ('29', 1),
        ('30', 1),
        ('31', 0),
        ('32', 4),
        ('33', 0),
        ('34', 0),
        ('35', 0),
        ('36', 0),
        ('37', 4),
        ('38', 0),
        ('39', 4),
        ('40', 0),
        ('41', 13),
        ('42', 8),
        ('43', 0),
        ('44', 8),
        ('45', 8),
        ('46', 0),
        ('47', 0),
        ('48', 0),
        ('50', 0),
        ('51', 1),
        ('52', 0),
        ('54', 0),
        ('57', 0),
        ('58', 1),
        ('59', 0),
        ('60', 8),
        ('61', 1),
        ('62', 2500000),
        ('63', 7),
        ('64', 4),
        ('65', 0),
        ('66', 0),
        ('67', 0),
        ('68', 0),
        ('69', 1),
        ('70', 0),
        ('71', 0),
        ('72', 1),
        ('73', 0),
        ('74', 0),
        ('75', 2),
        ('76', 3),
        ('77', 0),
        ('78', 0),
        ('79', 1),
        ('80', 0),
        ('81', 0),
        ('82', 0),
        ('83', 1),
        ('84', 0),
        ('85', 0),
        ('86', 0),
        ('87', 40),
        ('88', 51),
        ('89', 12),
        ('91', 2),
        ('92', 12),
        ('93', 0),
        ('94', 0),
        ('95', 1),
        ('96', 0),
        ('97', 3),
        ('98', 0),
        ('99', 0)])

In [34]:
resp = gopro.commands.set_feature_value(fid, 4)

In [29]:
url = gopro.api.tpl_setting.format(feature=fid, value=0)

print(url)


http://10.5.5.9/gp/gpControl/setting/4/0

In [20]:
# def feature_value(fid):
#     mode = gopro.status.current_mode()
    
#     assert(mode == fid_mode(fid))
    
#     value_init = feature_current_value(fid)
#     wid_feature = select_feature_widget(fid, value_init=value_init)
    
#     def handle_feature_selection(event):
#         value = event.new
# #         print('set {} {}'.format(fid, value))
#         set_feature_value(fid, value)
        
#     wid_feature.observe(handle_feature_selection, names='value')
  
#     IPython.display.display(wid_feature)

In [ ]:


In [ ]:

Timing


In [39]:
gopro.commands.shutter_capture()

time_max = 5
interval = 0.05

time_start = time.time()
while time.time() - time_start < time_max:
    
    time_pre = time.time()
    stat = gopro.status.fetch_camera_info(pretty=False)    
    time_after = time.time()

    delta = time_after - time_pre
    time_sleep = interval - delta
    
    if stat['System']['system_busy'] > 0:
        if time_sleep > 0.001:
            time.sleep(time_sleep)
    else:
        break

print('{:.3f} sec'.format(time_after - time_start))


1.643 sec

In [ ]:

Basic Commands


In [19]:
gopro.commands.set_mode_photo()

In [16]:
gopro.commands.set_mode_video()

In [53]:
gopro.commands.shutter_capture()

In [52]:
gopro.commands.shutter_stop()

File Transfer


In [51]:
gopro.commands.update_local_data(delete=True)



In [ ]: