Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inpath error #2

Open
scrimaglia opened this issue Jan 31, 2021 · 3 comments
Open

inpath error #2

scrimaglia opened this issue Jan 31, 2021 · 3 comments

Comments

@scrimaglia
Copy link

This is what i did (btw i´m no a programmer o something like that):

1) Copy and paste your code inside a GPSpython.py file (first created a notepad TXT and renamed it .PY, then pasted the code)

usage = """python insta360pro-gps PATH_TO_INPUT_FILE [PATH_TO_OUTPUT_FILE]
Converts to GPX format a file with the GPS track extracted from a Insta360 Pro
video using the GPSreader.exe tool included in the Insta360 Stitcher software."""

author = "Javier Sanchez Portero"
copyright = "Copyright 2018, Javier Sanchez Portero"
license = "GNU v3"
version = "1.0"
email = "[email protected]"

from argparse import ArgumentParser
from collections import OrderedDict
from datetime import datetime
import json
import os

sep = '\n'
tab = ' '
gpxatrs = OrderedDict()
gpxatrs['version'] = "1.1"
gpxatrs['creator'] = "insta360pro-gps"
gpxatrs['xmlns'] = "http://www.topografix.com/GPX/1/1"
gpxatrs['xmlns:xsi'] = "http://www.w3.org/2001/XMLSchema-instance"
gpxatrs['xsi:schemaLocation'] = "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"

def read(inputfile):
with open(inputfile, 'r') as fo:
data = json.loads(fo.read())
track = data['extended_gps_info']
assert isinstance(track, (list, tuple))
return track

def writeln(fo, text, tabs=0):
for i in range(tabs):
fo.write(tab)
fo.write(text)
fo.write(sep)

def togpx(track, fo):
writeln(fo, "")
writeln(fo, '<gpx ' + ' '.join(['{}="{}"'.format(k, v)
for (k, v) in list(gpxatrs.items())]) + '>')
writeln(fo, '', 1)
writeln(fo, '', 2)
for tp in track:
lat = tp['latitude']
lon = tp['longitude']
ele = tp['altitude']
dt = datetime.fromtimestamp(tp['time_gps_epoch'])
writeln(fo, ''.format(lat, lon), 3)
writeln(fo, '{}'.format(ele), 4)
writeln(fo, '{}'.format(dt.strftime('%Y-%m-%dT%H:%M:%S.%fZ')), 4)
writeln(fo, '', 3)
writeln(fo, '', 2)
writeln(fo, '', 1)
writeln(fo, '')

if name == "main":
parser = ArgumentParser(usage=usage)
parser.add_argument('inpath', help="D:\GPStrack.txt")
parser.add_argument('outpath', nargs='?', help="D:\GPStrackGPX.gpx")
args = parser.parse_args()
try:
track = read(args.inpath)
except IOError as e:
print(e)
except (ValueError, KeyError, AssertionError) as e:
print("Bad input file")
fn = args.outpath if args.outpath else os.path.splitext(args.inpath)[0] + '.gpx'
with open(fn, 'w') as fo:
togpx(track, fo)

2) Go to command prompt and execute: C:\python "D:\GPSpython.py"

And this is what i got:

usage: python insta360pro-gps PATH_TO_INPUT_FILE [PATH_TO_OUTPUT_FILE]
Converts to GPX format a file with the GPS track extracted from a Insta360 Pro
video using the GPSreader.exe tool included in the Insta360 Stitcher software.
GPSpython.py: error: the following arguments are required: inpath

@javiersanp
Copy link
Owner

Hola. En el paso 2 ejecuta C:\python "D:\GPSpython.py" "ruta al archivo que contiene los datos".

@scrimaglia
Copy link
Author

Logré obtener el archivo .gpx

Ahora el problema es que al analizarlo, solo hay dos coordenadas (latitud y longitud) repetidas.

El problema seguramente está en la generación del TXT con el gpsreader.exe. Podrás ayudarme con este paso? Vi que tu archivo TXT tiene coordenadas diferentes según el desplazamiento, en cambio el mio sólo tiene un par de coordenadas repetidas.

Estoy haciendo lo siguiente:

"C:\Program Files (x86)\Insta360Stitcher\tools\prostitcher\GPSReader.exe" "D:\GPStrack.txt".

@javiersanp
Copy link
Owner

javiersanp commented Feb 2, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants