GoPro


In [1]:
import time

import numpy as np
import matplotlib.pyplot as plt
import data_io
import exiftool
import IPython

import context
import gopro_helper as gopro

%matplotlib notebook 

%load_ext autoreload
%autoreload 2

In [ ]:


In [2]:
IPython.display.display(IPython.display.HTML(data="""
<style>
    div#notebook-container    { width: 95%; }
    div#menubar-container     { width: 65%; }
    div#maintoolbar-container { width: 99%; }
</style>
"""))



In [ ]:

Connect to Camera WiFi


In [3]:
gopro.network.scan()


Out[3]:
['BlueBalloon    : 84',
 'Cocea@Mpk      : 35',
 'Ehrlich        : 32',
 'Ehrlich-ext    : 40',
 'GP26528824     : 71',
 'GreenCanoe     : 82',
 'hEAPSFAM       : 35',
 'HighFive       : 80',
 'TG1672GF2      : 44',
 'TG1672GF2-5G   : 44']

In [4]:
gopro.network.current_connection()


Out[4]:
'GreenCanoe'

In [8]:
ssid = 'GP26528824'
# ssid = 'GreenCanoe'

In [158]:
# ssid = 'GP26528824'
ssid = 'GreenCanoe'

In [10]:
gopro.network.connect_wifi(ssid)


disconnected  [new_activation]
config
ip_config
ip_check
activated
connected: GP26528824


In [4]:
wid = gopro.GoPro()



In [5]:
# wid.stop

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

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

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

In [14]:
gopro.media.update_local_data(show_bar=True)


Exception in thread Thread-5:
Traceback (most recent call last):
  File "/home/pierre/.local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/pierre/.local/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pierre/Projects/GoProHelper/gopro_helper/task.py", line 75, in _work_task
    self.update()
  File "/home/pierre/Projects/GoProHelper/gopro_helper/gopro.py", line 139, in update
    super().update(raw_status_settings=raw_status_settings, **kwargs)
  File "/home/pierre/Projects/GoProHelper/gopro_helper/gopro.py", line 100, in update
    raw_status_settings = commands.get_raw_status_settings()
  File "/home/pierre/Projects/GoProHelper/gopro_helper/commands.py", line 92, in get_raw_status_settings
    raw_status = Struct(content['status'])
KeyError: 'status'

Exception in thread Thread-4:
Traceback (most recent call last):
  File "/home/pierre/.local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/pierre/.local/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pierre/Projects/GoProHelper/gopro_helper/task.py", line 75, in _work_task
    self.update()
  File "/home/pierre/Projects/GoProHelper/gopro_helper/gopro.py", line 242, in update
    changed = self._update_mode()
  File "/home/pierre/Projects/GoProHelper/gopro_helper/gopro.py", line 254, in _update_mode
    new_mode = self._info_status.mode
AttributeError: 'NoneType' object has no attribute 'mode'


In [22]:
def current_mode():
    
    raw_status, raw_settings = gopro.commands.get_raw_status_settings()
    info_status = gopro.api.parse_status_names(raw_status)
    mode, submode = gopro.api.parse_mode_sub_mode(info_status)
    
    return mode

In [23]:
current_mode()


Out[23]:
'video'

In [26]:
gopro.media.get_data_urls()


Out[26]:
[]

In [97]:
def work():
    if current_mode() != 'photo':
        gopro.commands.set_mode_photo()
        
    files_old = gopro.media.local_data_files()
    
    gopro.commands.shutter_capture()
    
    gopro.media.update_local_data()
    
    files_new = gopro.media.local_data_files()
    
    assert(len(files_old) == len(files_new) + 1)

    for f in files_new[::-1]:
        if f not in files_old:
            break
            
    return f


# def status_line(gp, time_ref=0):
#     tpl = ''  
#     t = gp.status.current_time_msec/1000 - time_ref
#     b = gp.status.system_busy > 0
#     n = gp.status.num_total_photos
#     m = gp.status.num_total_videos
#     msg = tpl.format()

In [96]:
gopro.get(gopro.commands.api.url_delete_all)


Out[96]:
{}

In [137]:


In [139]:
files = gopro.media.local_data_files()

In [140]:
files[-10]


Out[140]:
'data/G0018568.JPG'

In [172]:


In [173]:
d.shape


Out[173]:
(3000, 4000, 3)

In [ ]:


In [ ]:


In [ ]: