Skip to content
Snippets Groups Projects
Commit 187bb763 authored by gospodnetic's avatar gospodnetic
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
__pycache__/
Log.py 0 → 100644
import json
class Log:
def __init__(self, log_filename):
self.camera_parameters = {
"focusing_distance_mm": 0,
"focal_length": 0,
"model": "",
"pixel_size_mm": 0,
"height": 0,
"width": 0
}
self.coverage = {
"triangle_count": 0,
"percent": 0
}
self.timing = {
"visibility_matrix_sec": 0,
"optimization_sec": 0
}
self.model = {
"name": 0,
"face_count": 0,
"vertex_count": 0
}
self.VPC = {
"count": 0,
"discarded_count": 0,
"method": "",
"generation_parameter": 0
}
self.optimization = {
"type": "",
"coverage_per_vp": [],
"triangle_per_vp": [],
"vp_selection_order": [],
"OVP": []
}
self.__parse_filename(log_filename)
def __str__(self):
return """
Camera:
focusing_distance_mm: {}
focal_length: {}
model: {}
pixel_size_mm: {}
height: {}
width: {}
Coverage:
triangle_count: {}
percent: {}
Timing:
visibility_matrix_sec: {}
optimization_sec: {}
Model:
name: {}
face_count: {}
vertex_count: {}
VPC:
count: {}
discarded_count: {}
method: {}
generation_parameter: {}
Optimization:
type: {}
coverage_per_vp: _list_length_{}
triangle_per_vp: _list_length_{}
vp_selection_order: _list_length_{}
OVP: _list_length_{}
""".format(
self.camera_parameters["focusing_distance_mm"],
self.camera_parameters["focal_length"],
self.camera_parameters["model"],
self.camera_parameters["pixel_size_mm"],
self.camera_parameters["height"],
self.camera_parameters["width"],
self.coverage["triangle_count"],
self.coverage["percent"],
self.timing["visibility_matrix_sec"],
self.timing["optimization_sec"],
self.model["name"],
self.model["face_count"],
self.model["vertex_count"],
self.VPC["count"],
self.VPC["discarded_count"],
self.VPC["method"],
self.VPC["generation_parameter"],
self.optimization["type"],
len(self.optimization["coverage_per_vp"]),
len(self.optimization["triangle_per_vp"]),
len(self.optimization["vp_selection_order"]),
len(self.optimization["OVP"]))
def __parse_filename(self, log_filename):
with open(log_filename) as log_file:
log_data = json.load(log_file)
self.__check_file_structure(log_data)
self.camera_parameters["focusing_distance_mm"] = log_data["Log"]["Camera"]["DistanceMM"]
self.camera_parameters["focal_length"] = log_data["Log"]["Camera"]["FocalLength"]
self.camera_parameters["model"] = log_data["Log"]["Camera"]["Model"]
self.camera_parameters["pixel_size_mm"] = log_data["Log"]["Camera"]["PixSizeMM"]
self.camera_parameters["height"] = log_data["Log"]["Camera"]["ResHeight"]
self.camera_parameters["width"] = log_data["Log"]["Camera"]["ResWidth"]
self.coverage["triangle_count"] = log_data["Log"]["Coverage"]["InTriangles"]
self.coverage["triangle_count"] = log_data["Log"]["Coverage"]["Percentage"]
self.timing["visibility_matrix_sec"] = log_data["Log"]["Duration"]["RayTracingSec"]
self.timing["optimization_sec"] = log_data["Log"]["Duration"]["OptimizationSec"]
self.model["name"] = log_data["Log"]["Model"]["Name"]
self.model["face_count"] = log_data["Log"]["Model"]["FaceCount"]
self.model["vertex_count"] = log_data["Log"]["Model"]["VertexCount"]
self.VPC["count"] = log_data["Log"]["VPC"]["Count"]
self.VPC["discarded_count"] = log_data["Log"]["VPC"]["DiscardedCount"]
self.VPC["method"] = log_data["Log"]["VPC"]["Functional"]
self.VPC["generation_parameter"] = log_data["Log"]["VPC"]["Threshold"]
self.optimization["type"] = log_data["Log"]["OptimizationType"]
self.optimization["coverage_per_vp"] = log_data["Log"]["CoveragePerVP"]
self.optimization["triangle_per_vp"] = log_data["Log"]["TriangleCoveragePerVP"]
self.optimization["vp_selection_order"] = log_data["Log"]["VPSelectionOrder"]
self.optimization["OVP"] = log_data["OVP"]["List"]
self.__check_data()
# Only checks if the coverage per vp data are of equal length.
def __check_data(self):
if ((len(self.optimization["coverage_per_vp"]) != len(self.optimization["triangle_per_vp"])) or \
(len(self.optimization["triangle_per_vp"]) != len(self.optimization["vp_selection_order"]))):
raise Exception("'coverage per viewpoint', 'triangle per viewpoint' and " +
"'viewpoint selection order' are not of same length!")
def __check_file_structure(self, log_data):
if "Log" in log_data:
if "Camera" in log_data["Log"]:
if "DistanceMM" not in log_data["Log"]["Camera"]:
raise Exception("'Camera' has no 'DistanceMM' entry available.")
if "FocalLength" not in log_data["Log"]["Camera"]:
raise Exception("'Camera' has no 'FocalLength' entry available.")
if "Model" not in log_data["Log"]["Camera"]:
raise Exception("'Camera' has no 'Model' entry available.")
if "PixSizeMM" not in log_data["Log"]["Camera"]:
raise Exception("'Camera' has no 'PixSizeMM' entry available.")
if "ResHeight" not in log_data["Log"]["Camera"]:
raise Exception("'Camera' has no 'ResHeight' entry available.")
if "ResWidth" not in log_data["Log"]["Camera"]:
raise Exception("'Camera' has no 'ResWidth' entry available.")
else:
raise Exception("'Log' has no 'Camera' entry available.")
if "Coverage" in log_data["Log"]:
if "InTriangles" not in log_data["Log"]["Coverage"]:
raise Exception("'Coverage' has no 'InTriangles' entry available.")
if "Percentage" not in log_data["Log"]["Coverage"]:
raise Exception("'Coverage' has no 'Percentage' entry available.")
else:
raise Exception("'Log' has no 'Coverage' entry available.")
if "Duration" in log_data["Log"]:
if "OptimizationSec" not in log_data["Log"]["Duration"]:
raise Exception("'Duration' has no 'OptimizationSec' entry available.")
if "RayTracingSec" not in log_data["Log"]["Duration"]:
raise Exception("'Duration' has no 'RayTracingSec' entry available.")
else:
raise Exception("'Log' has no 'Duration' entry available.")
if "Model" in log_data["Log"]:
if "FaceCount" not in log_data["Log"]["Model"]:
raise Exception("'Model' has no 'FaceCount' entry available.")
if "Name" not in log_data["Log"]["Model"]:
raise Exception("'Model' has no 'Name' entry available.")
if "VertexCount" not in log_data["Log"]["Model"]:
raise Exception("'Model' has no 'VertexCount' entry available.")
else:
raise Exception("'Log' has no 'Model' entry available.")
if "VPC" in log_data["Log"]:
if "Count" not in log_data["Log"]["VPC"]:
raise Exception("'VPC' has no 'Count' entry available.")
if "DiscardedCount" not in log_data["Log"]["VPC"]:
raise Exception("'VPC' has no 'DiscardedCount' entry available.")
if "Functional" not in log_data["Log"]["VPC"]:
raise Exception("'VPC' has no 'Functional' entry available.")
if "Threshold" not in log_data["Log"]["VPC"]:
raise Exception("'VPC' has no 'Threshold' entry available.")
else:
raise Exception("'Log' has no 'VPC' entry available.")
if "CoveragePerVP" not in log_data["Log"]:
raise Exception("No 'CoveragePerVP' entry available.")
if "TriangleCoveragePerVP" not in log_data["Log"]:
raise Exception("No 'TriangleCoveragePerVP' entry available.")
if "VPSelectionOrder" not in log_data["Log"]:
raise Exception("No 'VPSelectionOrder' entry available.")
if "OptimizationType" not in log_data["Log"]:
raise Exception("No 'OptimizationType' entry available.")
else:
raise Exception("No 'Log' entry available.")
if "OVP" in log_data:
if "Count" not in log_data["OVP"]:
raise Exception("'OVP' has no 'Count' entry available.")
if "List" not in log_data["OVP"]:
raise Exception("'OVP' has no 'List' entry available.")
else:
raise Exception("No 'OVP' entry available.")
[
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--0.5f--OVP--ThinPlate--0.994921_coverage_2020-05-16_03-17-40_VPC_dist10_ThinPlate_th0.5f_log.json",
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--0.25f--OVP--ThinPlate--0.992063_coverage_2020-05-16_04-31-59_VPC_dist10_ThinPlate_th0.25f_log.json",
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--0.75f--OVP--ThinPlate--0.990636_coverage_2020-05-16_06-52-30_VPC_dist10_ThinPlate_th0.75f_log.json",
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--1f--OVP--ThinPlate--0.988589_coverage_2020-05-16_07-43-20_VPC_dist10_ThinPlate_th1f_log.json",
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--30a--OVP--NormalDev--0.995471_coverage_2020-05-15_13-35-19_VPC_dist10_NormalDev_th30a_log.json",
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--45a--OVP--NormalDev--0.990657_coverage_2020-05-15_21-14-54_VPC_dist10_NormalDev_th45a_log.json",
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--60a--OVP--NormalDev--0.994068_coverage_2020-05-16_01-00-40_VPC_dist10_NormalDev_th60a_log.json",
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--90a--OVP--NormalDev--0.982161_coverage_2020-05-16_02-51-49_VPC_dist10_NormalDev_th90a_log.json",
"/home/pastrva/Projects/VirtualImageProcessing/Fileserver/Papers/2020_Generate_and_Test_Comparison/Results/Dennis_VPCs-OVP_no_filtering/2020-04-30_Dennis_VPC_optimization/MissingHirthAndTimeShaft_OVPs/gear--10000f--OVP--ThinPlate--0.951490_coverage_2020-05-16_08-18-28_VPC_dist10_ThinPlate_th10000f_log.json"
]
#ViewpointOptimizationBenchmark
vob.py 0 → 100644
from Log import Log
import sys
import json
def main():
if (len(sys.argv) == 2):
path_list = sys.argv[1]
else:
print("No .json file containing OVP paths provided.")
exit()
with open(path_list) as ovp_path_file:
ovp_paths = json.load(ovp_path_file)
for filename in ovp_paths:
log = Log(filename)
print(log)
if __name__ == "__main__":
main()
# per_method_coverage = []
# for filename in ovp_paths:
# with open(filename) as OVP_file:
# ovp_data = json.load(OVP_file)
# if ovp_data["Log"]["CoveragePerVP"] is None:
# print("No coverage")
# continue
# per_method_coverage.append(
# convert_to_percentage(
# convert_cumulative(np.array(ovp_data["Log"]["CoveragePerVP"]))))
# y = np.array(per_method_coverage[-1])
# x = np.array(range(len(y)))
# plt.plot(x, y, c="0.4", alpha=0.2)
# peaks, troughs = stacked_coverage_find_peaks_and_troughs(per_method_coverage)
# peaks = filter_falling_peaks(peaks)
# # plt.plot(peaks, c="#009e28", ls="--", lw=2, alpha=0.5)
# plt.plot(peaks, c="blue", ls="--", lw=2, alpha=0.5)
# plt.plot(troughs, c="#e36120", ls="--", lw=2, alpha=0.7)
# plt.xlim(0,45)
# plt.ylim(0,100)
# plt.xlabel("Number of viewpoints")
# plt.ylabel("Coverage [%]")
# # plt.show()
# plt.savefig(graph_name)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment