API Reference¶
Core Modules¶
gpmf.parse¶
- class gpmf.parse.KLVItem(key, length, value)¶
Bases:
tuple- key¶
Alias for field number 0
- length¶
Alias for field number 1
- value¶
Alias for field number 2
- class gpmf.parse.KLVLength(type, size, repeat)¶
Bases:
tuple- repeat¶
Alias for field number 2
- size¶
Alias for field number 1
- type¶
Alias for field number 0
- gpmf.parse.parse_payload(x, fourcc, type_str, size, repeat)[source]¶
Parse the payload
- Parameters:
- Returns:
payload – The parsed payload. the actual type depends on the type_str and the size and repeat values.
- Return type:
- gpmf.parse.iter_klv(x)[source]¶
Iterate on KLV items.
- Parameters:
x (byte) – The byte array corresponding to the stream.
- Returns:
klv_gen – A generator of (fourcc, (type_str, size, repeat), payload) tuples.
- Return type:
generator
gpmf.gps¶
- class gpmf.gps.GPSData(description, timestamp, precision, fix, latitude, longitude, altitude, speed_2d, speed_3d, units, npoints)¶
Bases:
tuple- altitude¶
Alias for field number 6
- description¶
Alias for field number 0
- fix¶
Alias for field number 3
- latitude¶
Alias for field number 4
- longitude¶
Alias for field number 5
- npoints¶
Alias for field number 10
- precision¶
Alias for field number 2
- speed_2d¶
Alias for field number 7
- speed_3d¶
Alias for field number 8
- timestamp¶
Alias for field number 1
- units¶
Alias for field number 9
- gpmf.gps.extract_gps_blocks(stream)[source]¶
Extract GPS data blocks from binary stream
This is a generator on lists KVLItem objects. In the GPMF stream, GPS data comes into blocks of several different data items. For each of these blocks we return a list.
- Parameters:
stream (bytes) – The raw GPMF binary stream
- Returns:
gps_items_generator – Generator of lists of KVLItem objects
- Return type:
generator
- gpmf.gps.parse_gps_block(gps_block)[source]¶
Turn GPS data blocks into GPSData objects
Supports both GPS5 (Hero 5-10) and GPS9 (Hero 11+) streams
- gpmf.gps.make_pgx_segment(gps_blocks, first_only=False, speeds_as_extensions=True)[source]¶
Convert a list of GPSData objects into a GPX track segment.
- Parameters:
- Returns:
gpx_segment – A gpx track segment.
- Return type:
gpxpy.gpx.GPXTrackSegment
gpmf.io¶
- gpmf.io.find_gpmf_stream(fname)[source]¶
Find the reference to the GPMF Stream in the video file
- Parameters:
fname (str) – The input file
- Returns:
stream_info – The GPMF Stream info.
- Return type:
- Raises:
RuntimeError – If no stream found.:
gpmf.gps_plot¶
- gpmf.gps_plot.to_dataframe(gps_data_blocks)[source]¶
Convert a sequence of GPSData into pandas dataframe.
- Parameters:
gps_data_blocks (seq of GPSData) – A sequence of GPSData objects
- Returns:
df_gps – The output dataframe
- Return type:
- gpmf.gps_plot.plot_gps_trace(latlon, min_tile_size=10, map_provider=None, zoom=12, figsize=(10, 10), proj_crs='EPSG:2154', color='tab:red')[source]¶
Plot a (lat, lon) coordinates on a Map
- Parameters:
latlon (numpy.ndarray) – Array of (latitude, longitude) coordinates
min_tile_size (int, optional (default=10)) – Minimum size of the map in km
map_provider (dict) – Dictionnary describing a map provider as given by contextly.providers. If None contextily.providers.OpenStreetMap.Mapnik is used.
zoom (int, optional (default=12)) – The zoom level used.
figsize (tuple of int, optional (default=(10, 10))) – The matplotlib figure size
proj_crs (str or geopandas.CRS object, optional (default="EPSG:2154")) – The projection system used to compute distances on the map. The default value corresponds to the Lambert 93 system.
color (str, optional (default="tab:red")) – The color used to plot the track.
- gpmf.gps_plot.plot_gps_trace_from_stream(stream, first_only=False, min_tile_size=10, map_provider=None, zoom=12, figsize=(10, 10), proj_crs='EPSG:2154', output_path=None, precision_max=3.0, color='tab:red')[source]¶
Plot GPS data from a string on a map.
- Parameters:
stream (bytes) – The raw GPMF binary stream.
min_tile_size (int, optional (default=10)) – Minimum size of the map in km
map_provider (dict) – Dictionnary describing a map provider as given by contextly.providers. If None contextily.providers.OpenStreetMap.Mapnik is used.
zoom (int, optional (default=12)) – The zoom level used.
figsize (tuple of int, optional (default=(10, 10))) – The matplotlib figure size
proj_crs (str or geopandas.CRS object, optional (default="EPSG:2154")) – The projection system used to compute distances on the map. The default value corresponds to the Lambert 93 system.
color (str, optional (default="tab:red")) – The color used to plot the track.