Skip to content

Commit

Permalink
Minor changes/refactors.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgddrd committed Apr 3, 2015
1 parent a28b674 commit f9a324e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 33 deletions.

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/template_matching_scaling/template_matching_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def __init__(self, image_root_file_path, image_one_file_name, image_two_file_nam
self._plot_axis = plot_axis

def load_calibration_data(self, file_path):

raw_data = TSEFileIO.read_file(file_path, split_delimiter=",", start_position=1)
return dict(TSEUtils.string_list_to_int_list(raw_data))
return dict(TSEUtils.string_2d_list_to_int_2d_list(raw_data))

def search_image(self, patch_height, match_methods, use_scaling=False, force_cont_search=False):

Expand Down
6 changes: 4 additions & 2 deletions src/template_matching_scaling/tse/tse_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ class TSEFileIO:
def __init__(self, filepath="./"):
self._file_path = filepath

def write_file(self, filename, data_prefix, data_collection, append):
def write_tuple_list_to_file(self, filename, data_collection, data_prefix=None, append=True):

self.check_directory(self._file_path)

file_io_op = 'a' if append else 'w'

new_file = open(self._file_path + filename, file_io_op)

new_file.write(data_prefix + "\n")
if data_prefix is not None:
new_file.write(data_prefix + "\n")

for data in data_collection:
new_file.write("{0},{1}\n".format(data[0], data[1]))
Expand Down
1 change: 1 addition & 0 deletions src/template_matching_scaling/tse/tse_matchtype.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__author__ = 'connorgoddard'


class TSEMatchType:
def __init__(self, match_name, match_type, match_id, format_string, reverse_score=False):
self._match_name = match_name
Expand Down
8 changes: 4 additions & 4 deletions src/template_matching_scaling/tse/tse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def get_smallest_key_value_dict(dict):
return dict[smallest_dict_key]

@staticmethod
def string_list_to_int_list(string_list):
return map(TSEUtils.convert_to_int, string_list)
def string_2d_list_to_int_2d_list(string_list):
return map(TSEUtils.convert_list_to_int, string_list)

@staticmethod
def convert_to_int(value):
return map(int, value)
def convert_list_to_int(list_to_convert):
return map(int, list_to_convert)

@staticmethod
def calc_moving_average_array(values, window, mode='valid'):
Expand Down

0 comments on commit f9a324e

Please sign in to comment.