mirror of
https://github.com/jlengrand/Ivolution.git
synced 2026-03-10 08:21:18 +00:00
Comments out all log messages to console. Avoid having errors in GUI.
This commit is contained in:
@@ -49,7 +49,6 @@ class FaceParams(object):
|
||||
|
||||
cascade_name = training_types.simple_set[training_type] + ".xml"
|
||||
# Setting up some default parameters for Face Detection
|
||||
print xml_folder
|
||||
self.face_cascade = cv.Load(os.path.join(xml_folder, cascade_name))
|
||||
|
||||
# To be defined more precisely
|
||||
|
||||
@@ -41,7 +41,7 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
self.subscribe(self.facemovie) # Used to send request to stop
|
||||
|
||||
self.my_logger = logging.getLogger('IvolutionFile.Thread')
|
||||
self.console_logger = logging.getLogger('ConsoleLog')
|
||||
#self.console_logger = logging.getLogger('ConsoleLog')
|
||||
|
||||
def update(self, message):
|
||||
"""
|
||||
@@ -50,19 +50,19 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
"""
|
||||
if len(message) == 1: # system commands
|
||||
if message[0] == "STOP":
|
||||
self.console_logger.debug("Facemovie is going to stop")
|
||||
#self.console_logger.debug("Facemovie is going to stop")
|
||||
self.my_logger.debug("Facemovie is going to stop")
|
||||
|
||||
self.stop_process = True
|
||||
self.notify(["Lib", ["STOP"]])
|
||||
else:
|
||||
self.console_logger.debug("Unrecognized system command")
|
||||
#self.console_logger.debug("Unrecognized system command")
|
||||
self.my_logger.debug("Unrecognized system command")
|
||||
#self.console_logger.debug(message)
|
||||
##self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
elif len(message) == 2: # notifications
|
||||
|
||||
#self.console_logger.debug(message)
|
||||
##self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
if message[0] == "FILEADD":
|
||||
self.notify(["Interface", [message[0], message[1], 0]])
|
||||
@@ -72,7 +72,7 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
|
||||
# checking for fatal error
|
||||
if message[0] == "Error":
|
||||
self.console_logger.debug("Fatal Error detected")
|
||||
#self.console_logger.debug("Fatal Error detected")
|
||||
self.my_logger.debug("Fatal Error detected")
|
||||
self.stop_process = True
|
||||
self.notify(["Lib", ["STOP"]])
|
||||
@@ -82,9 +82,9 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
self.notify(["Interface", message])
|
||||
|
||||
else:
|
||||
self.console_logger.debug("Unrecognized command")
|
||||
#self.console_logger.debug("Unrecognized command")
|
||||
self.my_logger.debug("Unrecognized command")
|
||||
self.console_logger.debug(message)
|
||||
#self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
|
||||
def run(self):
|
||||
|
||||
@@ -42,7 +42,7 @@ class FaceMovie(object, Observable, Observer):
|
||||
Observable.__init__(self) # used to send notifications to process
|
||||
Observer.__init__(self, "Lib") # used to receive notification to stop
|
||||
|
||||
self.console_logger = logging.getLogger('ConsoleLog') # Used to send messages to the console
|
||||
#self.console_logger = logging.getLogger('ConsoleLog') # Used to send messages to the console
|
||||
self.my_logger = logging.getLogger('IvolutionFile.Lib') # Used to save events into a file
|
||||
|
||||
self.source = face_params.input_folder # Source folder for pictures
|
||||
@@ -89,7 +89,7 @@ class FaceMovie(object, Observable, Observer):
|
||||
os.path.exists(self.source)
|
||||
os.path.isdir(self.source) # checking if folder exists
|
||||
except: # find precise exception
|
||||
self.console_logger.critical("Source folder not found ! Exiting. . .")
|
||||
#self.console_logger.critical("Source folder not found ! Exiting. . .")
|
||||
self.my_logger.critical("Source folder not found ! Exiting. . .")
|
||||
sys.exit(0)
|
||||
|
||||
@@ -111,8 +111,8 @@ class FaceMovie(object, Observable, Observer):
|
||||
guy_date = exif.parse(guy_source)['DateTime']
|
||||
except Exception:
|
||||
self.my_logger.warning("No metadata found for %s" % (guy_name))
|
||||
if self.sort_method == "exif":
|
||||
self.console_logger.warning(" No metadata found for %s" % (guy_name))
|
||||
#if self.sort_method == "exif":
|
||||
#self.console_logger.warning(" No metadata found for %s" % (guy_name))
|
||||
|
||||
guy_date = ''
|
||||
|
||||
@@ -123,11 +123,11 @@ class FaceMovie(object, Observable, Observer):
|
||||
self.guys.append(a_guy)
|
||||
self.notify(["Application", ["FILEADD", guy_name]])
|
||||
except:
|
||||
self.console_logger.info("Skipping %s. Not an image file" % (guy_source))
|
||||
#self.console_logger.info("Skipping %s. Not an image file" % (guy_source))
|
||||
self.my_logger.info("Skipping %s. Not an image file" % (guy_source))
|
||||
|
||||
self.sort_guys()
|
||||
self.console_logger.info("%d guys found in source folder." % (self.number_guys()))
|
||||
##self.console_logger.info("%d guys found in source folder." % (self.number_guys()))
|
||||
self.my_logger.info("%d guys found in source folder." % (self.number_guys()))
|
||||
|
||||
def sort_guys(self):
|
||||
@@ -161,11 +161,11 @@ class FaceMovie(object, Observable, Observer):
|
||||
self.notify_progress("Processing picture", ptr, self.number_guys())
|
||||
|
||||
if a_guy.has_face(): # face(s) have been found
|
||||
self.console_logger.info("Face found for %s" % (a_guy.name))
|
||||
#self.console_logger.info("Face found for %s" % (a_guy.name))
|
||||
self.my_logger.info("Face found for %s" % (a_guy.name))
|
||||
faceres = 1 # for notifying
|
||||
else:
|
||||
self.console_logger.warning("No face found for %s. Skipped . . ." % (a_guy.name))
|
||||
#self.console_logger.warning("No face found for %s. Skipped . . ." % (a_guy.name))
|
||||
self.my_logger.warning("No face found for %s. Skipped . . ." % (a_guy.name))
|
||||
|
||||
self.notify(["Application", ["FILEDONE", a_guy.name, faceres]])
|
||||
@@ -217,7 +217,7 @@ class FaceMovie(object, Observable, Observer):
|
||||
self.check_depth()
|
||||
|
||||
if self.number_guys() == 0:
|
||||
self.console_logger.error("No face has been found in the whole repository! Exiting. . . ")
|
||||
#self.console_logger.error("No face has been found in the whole repository! Exiting. . . ")
|
||||
self.my_logger.error("No face has been found in the whole repository! Exiting. . . ")
|
||||
self.notify(["Error", 0])
|
||||
sys.exit(0)
|
||||
@@ -237,7 +237,7 @@ class FaceMovie(object, Observable, Observer):
|
||||
my_depth = list(set(my_depth)) # remove duplicates
|
||||
if len(my_depth) != 1:
|
||||
# We do not have a unique number of channels for all images
|
||||
self.console_logger.error("All images must have the same depth")
|
||||
#self.console_logger.error("All images must have the same depth")
|
||||
self.my_logger.error("All images must have the same depth")
|
||||
else:
|
||||
self.depth = my_depth[0]
|
||||
@@ -254,7 +254,7 @@ class FaceMovie(object, Observable, Observer):
|
||||
my_chans = list(set(my_chans)) # remove duplicates
|
||||
if len(my_chans) != 1:
|
||||
# We do not have a unique number of channels for all images
|
||||
self.console_logger.error("All images must have the same number of channels")
|
||||
#self.console_logger.error("All images must have the same number of channels")
|
||||
self.my_logger.error("All images must have the same number of channels")
|
||||
else:
|
||||
self.nChannels = my_chans[0]
|
||||
@@ -295,7 +295,7 @@ class FaceMovie(object, Observable, Observer):
|
||||
self.find_crop_dims()
|
||||
elif self.mode == "custom crop":
|
||||
# TODO : implement
|
||||
self.console_logger.critical("custom crop is not yet implemented")
|
||||
#self.console_logger.critical("custom crop is not yet implemented")
|
||||
self.my_logger.critical("custom crop is not yet implemented")
|
||||
raise Exception
|
||||
|
||||
@@ -414,7 +414,7 @@ class FaceMovie(object, Observable, Observer):
|
||||
ii += 1
|
||||
self.notify_progress("Saving frame", ii, self.number_guys())
|
||||
|
||||
self.console_logger.info("Saving frame %d / %d" % (ii, self.number_guys()))
|
||||
#self.console_logger.info("Saving frame %d / %d" % (ii, self.number_guys()))
|
||||
self.my_logger.info("Saving frame %d / %d" % (ii, self.number_guys()))
|
||||
out_im = self.prepare_image(a_guy)
|
||||
|
||||
@@ -529,7 +529,7 @@ class FaceMovie(object, Observable, Observer):
|
||||
file_name = name + "." + ext
|
||||
out_name = os.path.join(self.out_path, file_name)
|
||||
self.my_logger.info("Saving %s" % (out_name))
|
||||
self.console_logger.info("Saving %s" % (out_name))
|
||||
#self.console_logger.info("Saving %s" % (out_name))
|
||||
|
||||
cv.SaveImage(out_name, im)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class IvolutionWindow(IvolutionTemplate, Observer, Observable):
|
||||
|
||||
# Sets up logging capability
|
||||
self.my_logger = None
|
||||
self.console_logger = None
|
||||
#self.console_logger = None
|
||||
self.setup_logger()
|
||||
|
||||
# Defines all our parameters neededfor the facemovie
|
||||
@@ -102,7 +102,7 @@ class IvolutionWindow(IvolutionTemplate, Observer, Observable):
|
||||
|
||||
self.process_running = True
|
||||
else:
|
||||
self.console_logger.error("Cannot start, process already running !")
|
||||
#self.console_logger.error("Cannot start, process already running !")
|
||||
self.my_logger.error("Cannot start, process already running !")
|
||||
|
||||
def on_stop(self, event):
|
||||
@@ -111,7 +111,7 @@ class IvolutionWindow(IvolutionTemplate, Observer, Observable):
|
||||
Asks the FacemovieThread to terminate
|
||||
"""
|
||||
self.my_logger.debug("Stop pressed")
|
||||
self.console_logger.debug("Stop pressed")
|
||||
#self.console_logger.debug("Stop pressed")
|
||||
self.notify(["Application", ["STOP"]]) # Asking the Facemovie to stop
|
||||
self.process_running = False
|
||||
|
||||
@@ -280,8 +280,8 @@ either expressed or implied, of the FreeBSD Project."""
|
||||
|
||||
fh.setLevel(logging.DEBUG)
|
||||
# create console handler with a higher log level
|
||||
self.console_logger = logging.getLogger('ConsoleLog')
|
||||
self.console_logger.setLevel(logging.DEBUG) # not needed
|
||||
#self.console_logger = logging.getLogger('ConsoleLog')
|
||||
#self.console_logger.setLevel(logging.DEBUG) # not needed
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
#ch.setLevel(logging.DEBUG) # not needed
|
||||
@@ -296,7 +296,7 @@ either expressed or implied, of the FreeBSD Project."""
|
||||
fh.setFormatter(formatter)
|
||||
#ch.setFormatter(formatter)
|
||||
|
||||
self.console_logger.addHandler(ch)
|
||||
#self.console_logger.addHandler(ch)
|
||||
|
||||
def update(self, message):
|
||||
"""
|
||||
@@ -305,7 +305,7 @@ either expressed or implied, of the FreeBSD Project."""
|
||||
"""
|
||||
if len(message) == 3:
|
||||
# notifications
|
||||
#self.console_logger.debug(message)
|
||||
##self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
|
||||
if message[0] == "PROGRESS": # progress bar
|
||||
@@ -317,7 +317,7 @@ either expressed or implied, of the FreeBSD Project."""
|
||||
|
||||
if float(message[2]) >= 1.0: # 100% of process
|
||||
self.my_logger.debug("Reached end of facemovie process")
|
||||
#self.console_logger.debug("Reached end of facemovie process")
|
||||
##self.console_logger.debug("Reached end of facemovie process")
|
||||
self.process_running = False
|
||||
|
||||
elif message[0] == "STATUS": # status label
|
||||
@@ -349,7 +349,7 @@ either expressed or implied, of the FreeBSD Project."""
|
||||
wx.MutexGuiLeave()
|
||||
|
||||
elif len(message) > 1: # system commands shall be ignored
|
||||
self.console_logger.debug("Unrecognized command")
|
||||
#self.console_logger.debug("Unrecognized command")
|
||||
self.my_logger.debug("Unrecognized command")
|
||||
self.console_logger.debug(message)
|
||||
#self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
|
||||
@@ -14,5 +14,6 @@ sys.path.append("C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\redist\\x86
|
||||
setup(
|
||||
options = {'py2exe': {'bundle_files': 1, 'includes': ['numpy', 'wx'] } },
|
||||
windows=['Ivolutioner'],
|
||||
#console=['Ivolutioner'],
|
||||
zipfile = None,
|
||||
)
|
||||
Reference in New Issue
Block a user