Commit 6288ff5a authored by Stephen Thompson's avatar Stephen Thompson

Issue #3 changed test to use different log files, add logging points to overlay app and locator

parent cb4f46d7
Pipeline #4449 failed with stages
in 5 minutes and 59 seconds
......@@ -16,6 +16,11 @@
"map" : "data/full",
"model to world" : "configuration/model_to_world.txt",
"logo" : false,
"search radius" : 1000
"search radius" : 1000,
"logger" : {
"log file name" : "sks_eval_liver_phantom.log",
"overwrite existing" : false
}
}
......@@ -40,10 +40,11 @@ class Locators():
self.models[index].actor.GetProperty().SetColor(1.0, 1.0, 1.0)
def is_hit(self, tracking):
def is_hit(self, tracking, logger):
"""
Checks whether a target has been hit
:param: the tracking data (3D point)
:param: a logger to write notification to
"""
index, distance = point_in_locator(tracking[0:3, 3],
self._locators,
......@@ -57,7 +58,7 @@ class Locators():
str(self._targets[self._target_index])])
if index == self._targets[self._target_index]:
print("hit")
logger.log(message="Hit target:{0}".format(index))
self._set_target_inactive(self._targets[self._target_index])
self._target_index = self._target_index + 1
if self._target_index < len(self._locators):
......@@ -66,6 +67,7 @@ class Locators():
self._text.set_text([str(index), str(distance),
str(tracking),
str("Finished")])
logger.log(message="All targets hit")
else:
self._text.set_text([str(index), str(distance),
str(tracking),
......
......@@ -9,6 +9,7 @@ from sksurgeryeval.algorithms.background_image import \
OverlayBackground
from sksurgeryeval.shapes.cone import VTKConeModel
from sksurgeryeval.algorithms.locators import Locators
from sksurgeryeval.logging.surgery_logger import Logger
class OverlayApp(OverlayBaseApp):
......@@ -26,6 +27,7 @@ class OverlayApp(OverlayBaseApp):
self.timer = None
self.save_frame = None
self._logger = Logger(config)
if "logo" in config:
self.bg_image = OverlayBackground(config)
else:
......@@ -61,6 +63,8 @@ class OverlayApp(OverlayBaseApp):
self.vtk_overlay_window.add_vtk_actor(self._locator._text.text_actor)
self._logger.log(message="OverlayApp init OK")
def update(self):
"""Update the background renderer with a new frame,
......@@ -88,4 +92,8 @@ class OverlayApp(OverlayBaseApp):
if not isnan(quality[ph_index]):
self._pointer.actor.SetUserMatrix(np2vtk(tracking[ph_index]))
self._locator.is_hit(tracking[ph_index])
self._locator.is_hit(tracking[ph_index], self._logger)
def __del__(self):
self._logger.log(message="Closing overlay app")
self._logger.close()
......@@ -3,7 +3,6 @@
"""scikit-surgery-evaluation tests"""
from os import remove, path
from time import sleep
from sksurgeryeval.logging.surgery_logger import Logger
def test_empty_config():
......@@ -21,6 +20,7 @@ def test_empty_config():
logger.log(message="testing")
logger.close()
def test_non_empty_config():
"""
Test that the app runs
......@@ -36,9 +36,9 @@ def test_non_empty_config():
assert path.exists("sks_evaluation.log")
logger.close()
sleep(0.5)
remove("sks_evaluation.log")
def test_overwrite():
"""
Test that overwrite works
......@@ -46,13 +46,13 @@ def test_overwrite():
config = {
"logger" : {
"log file name" : "testing_log_file.log",
"overwrite existing" : True
}
}
logger = Logger(config)
assert path.exists("sks_evaluation.log")
assert path.exists("testing_log_file.log")
logger.close()
sleep(0.5)
remove("sks_evaluation.log")
remove("testing_log_file.log")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment