Skip to content

Commit

Permalink
add: minor bug fixes and minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jernejaMislej committed Aug 14, 2018
1 parent 1e1d7c6 commit f1e36a2
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 19 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@
* print out version
* increase the amount of information printed out without the verbose flag.


## 0.1.4 (2018-08-14)

### Bug fixes
* Create .mapillary folder for image copies in case of passing `--keep_original`
* Add missing global variable EPOCH in interpolation

### Features and improvements
* Do not require filename column to be passed when processing csv, but align csv data and images in order by image file names if filename column is missing
* Support partial matching between image file names and file names in the csv file

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ mapillary_tools video_process_and_upload --import_path "path/to/images" --video_
mapillary_tools process_csv --import_path "path/to/images" --csv_path "path/to/csv_file" --filename_column 1 --timestamp_column 4 --latitude_column 2 --longitude_column 3 --advanced
```

- Insert image capture time and meta data from a csv file based on the order of image file names (in case filename column is missing):

```bash
mapillary_tools process_csv --import_path "path/to/images" --csv_path "path/to/csv_file" --timestamp_column 1 --meta_columns "6,7" --meta_names "random_name1,random_name2" --meta_types "double,string" --advanced
```

## Tool Specifications

Expand Down
2 changes: 1 addition & 1 deletion mapillary_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
import process_csv
import interpolation

VERSION = "0.1.2"
VERSION = "0.1.4"
2 changes: 1 addition & 1 deletion mapillary_tools/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
process_and_upload
]

VERSION = "0.1.3"
VERSION = "0.1.4"


def add_general_arguments(parser, command):
Expand Down
2 changes: 1 addition & 1 deletion mapillary_tools/commands/process_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def add_basic_arguments(self, parser):
parser.add_argument("--convert_utc_time",
help="Convert utc epoch time in seconds or milliseconds.", action="store_true", default=False, required=False)
parser.add_argument("--filename_column",
help='Specify the column number of image filename, counting from 1 on.', action="store", required=True, type=int)
help='Specify the column number of image filename, counting from 1 on.', action="store", required=False, type=int)
parser.add_argument("--timestamp_column",
help='Specify the column number of image timestamp, counting from 1 on.', action="store", required=False, type=int)
parser.add_argument("--latitude_column",
Expand Down
4 changes: 4 additions & 0 deletions mapillary_tools/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from process_import_meta_properties import add_meta_tag
import process_csv
import csv
import datetime


EPOCH = datetime.datetime.utcfromtimestamp(0)


def format_datetime(timestamps_interpolated, time_utc=False, time_format="%Y-%m-%dT%H:%M:%SZ"):
Expand Down
36 changes: 24 additions & 12 deletions mapillary_tools/process_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def get_image_index(image, file_names):
file_names = [os.path.basename(entry) for entry in file_names]
image_index = file_names.index(os.path.basename(image))
except:
pass
try:
image_index = [idx for idx, file_name in enumerate(
file_names) if file_name in image][0]
except:
pass
return image_index


Expand All @@ -112,18 +116,18 @@ def parse_csv_geotag_data(csv_data, image_index, column_indexes, convert_gps_tim
heading_column = column_indexes[4]
altitude_column = column_indexes[5]

if timestamp_column:
if timestamp_column != None:
timestamp = csv_data[timestamp_column][image_index]
timestamp = convert_from_gps_time(
timestamp) if convert_gps_time else format_time(timestamp, convert_utc_time, time_format)

if latitude_column:
if latitude_column != None:
lat = float(csv_data[latitude_column][image_index])
if longitude_column:
if longitude_column != None:
lon = float(csv_data[longitude_column][image_index])
if heading_column:
if heading_column != None:
heading = float(csv_data[heading_column][image_index])
if altitude_column:
if altitude_column != None:
altitude = float(csv_data[altitude_column][image_index])

return timestamp, lat, lon, heading, altitude
Expand Down Expand Up @@ -158,7 +162,7 @@ def read_csv(csv_path, delimiter=",", header=False):

def process_csv(import_path,
csv_path,
filename_column,
filename_column=None,
timestamp_column=None,
latitude_column=None,
longitude_column=None,
Expand Down Expand Up @@ -206,13 +210,21 @@ def process_csv(import_path,
csv_data = read_csv(csv_path,
delimiter=delimiter,
header=header)
file_names = csv_data[filename_column - 1]

# align by filename column if provided, otherwise align in order of image
# names
file_names = None
if filename_column:
file_names = csv_data[filename_column - 1]
else:
if verbose:
print("Warning, filename column not provided, images will be aligned with the csv data in order of the image filenames.")

# process each image
for image in process_file_list:
for idx, image in enumerate(process_file_list):

# get image entry index
image_index = get_image_index(image, file_names)
image_index = get_image_index(image, file_names) if file_names else idx
if image_index == None:
print("Warning, no entry found in csv file for image " + image)
continue
Expand Down Expand Up @@ -245,8 +257,8 @@ def process_csv(import_path,
os.remove(filename_keep_original)

if keep_original:
if not os.path.isdir(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
if not os.path.isdir(os.path.dirname(filename_keep_original)):
os.makedirs(os.path.dirname(filename_keep_original))
filename = filename_keep_original

try:
Expand Down
2 changes: 1 addition & 1 deletion mapillary_tools/process_import_meta_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def finalize_import_properties_process(image,
add_meta_tag(mapillary_description,
"strings",
"mapillary_tools_version",
"0.1.3")
"0.1.4")

processing.create_and_log_process(image,
"import_meta_data_process",
Expand Down
4 changes: 2 additions & 2 deletions mapillary_tools/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ def get_final_mapillary_image_description(log_root, image, master_upload=False,
os.remove(filename_keep_original)
if keep_original:
filename = filename_keep_original
if not os.path.isdir(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
if not os.path.isdir(os.path.dirname(filename_keep_original)):
os.makedirs(os.path.dirname(filename_keep_original))
try:
image_exif.write(filename=filename)
except:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup

setup(name='mapillary_tools',
version='0.1.3',
version='0.1.4',
description='Mapillary Image/Video Import Pipeline',
url='https://github.com/mapillary/mapillary_tools',
author='Mapillary',
Expand Down

0 comments on commit f1e36a2

Please sign in to comment.