In [54]:
import time

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

import context
import gopro_helper as gopro

%matplotlib notebook 

%load_ext autoreload
%autoreload 2


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

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 [3]:
files = gopro.media.local_data_files()

In [61]:
m = gopro.media.metadata(files[:10])

In [62]:
m[0]


Out[62]:
Struct([('FileSize', 2235458),
        ('ColorComponents', 3),
        ('BitsPerSample', 8),
        ('WhiteBalance', 1),
        ('ISO', 741),
        ('FocalLength', 3),
        ('FNumber', 2.8),
        ('ExposureTime', 0.01),
        ('ExposureCompensation', 0),
        ('ApertureValue', 2.79917173119039),
        ('GPSAltitude', 163.664),
        ('GPSAltitudeRef', 0),
        ('GPSLatitude', 34.1585956999722),
        ('GPSLatitudeRef', 'N'),
        ('GPSLongitude', 118.442514099972),
        ('GPSLongitudeRef', 'W'),
        ('GainControl', 0),
        ('Sharpness', 1),
        ('GPSDateTime', '2017:07:08 22:16:57Z'),
        ('HyperfocalDistance', 0.534889474931471),
        ('FOV', 100.388942610382),
        ('ShutterSpeed', 0.01),
        ('LightValue', 6.7252363015841)])

In [64]:
dt = maya.parse(m[0].GPSDateTime)

In [65]:
dt.datetime()


Out[65]:
datetime.datetime(2017, 7, 8, 22, 16, 57, tzinfo=<UTC>)

In [56]:
meta.GPSDateStamp


Out[56]:
'2017:07:08'

In [38]:
d


Out[38]:
'2017-07-08'

In [51]:
t = moment.date(2017, 7, 9, 0, 24)

In [53]:
t


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/.virtualenvs/gopro/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    691                 type_pprinters=self.type_printers,
    692                 deferred_pprinters=self.deferred_printers)
--> 693             printer.pretty(obj)
    694             printer.flush()
    695             return stream.getvalue()

~/.virtualenvs/gopro/lib/python3.6/site-packages/IPython/lib/pretty.py in pretty(self, obj)
    378                             if callable(meth):
    379                                 return meth(obj, self, cycle)
--> 380             return _default_pprint(obj, self, cycle)
    381         finally:
    382             self.end_group()

~/.virtualenvs/gopro/lib/python3.6/site-packages/IPython/lib/pretty.py in _default_pprint(obj, p, cycle)
    493     if _safe_getattr(klass, '__repr__', None) is not object.__repr__:
    494         # A user-provided repr. Find newlines and replace them with p.break_()
--> 495         _repr_pprint(obj, p, cycle)
    496         return
    497     p.begin_group(1, '<')

~/.virtualenvs/gopro/lib/python3.6/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
    691     """A pprint that just redirects to the normal repr function."""
    692     # Find newlines and replace them with p.break_()
--> 693     output = repr(obj)
    694     for idx,output_line in enumerate(output.splitlines()):
    695         if idx:

~/.virtualenvs/gopro/lib/python3.6/site-packages/moment/core.py in __repr__(self)
    113     def __repr__(self):
    114         if self._date is not None:
--> 115             return "<Moment(%s)>" % (self._date.strftime(self._formula))
    116         return "<Moment>"
    117 

TypeError: strftime() argument 1 must be str, not None

In [20]:
f = files[100]

data = data_io.read(f)

meta = gopro.media.metadata(f)

In [21]:
AR = 3/4
W = 16
H = W/2*AR

fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(W, H))

bins = np.arange(0, 255, 2)

ax1.imshow(data)
ax2.hist(data[:, :, 0].flatten(), bins=bins, color='blue', alpha=0.5)
ax2.hist(data[:, :, 1].flatten(), bins=bins, color='green', alpha=0.5)
ax2.hist(data[:, :, 2].flatten(), bins=bins, color='red', alpha=0.5)

plt.tight_layout()



In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: