mirror of
https://github.com/jlengrand/Ivolution.git
synced 2026-03-10 08:21:18 +00:00
Finishes converting prints into logs.
For an unknown reason, my loggers dont print less than warnings. This has to be investigated
This commit is contained in:
@@ -10,6 +10,8 @@ import os
|
||||
import sys
|
||||
import threading
|
||||
|
||||
import logging
|
||||
|
||||
from facemovie import Facemovie_lib
|
||||
|
||||
class FacemovieThread(threading.Thread):
|
||||
@@ -31,11 +33,16 @@ class FacemovieThread(threading.Thread):
|
||||
self.facemovie = Facemovie_lib.FaceMovie(self.face_params)
|
||||
|
||||
def run(self):
|
||||
print "In thread !"
|
||||
my_logger = logging.getLogger('FileLog')
|
||||
my_logger.debug("Thread started")
|
||||
|
||||
self.facemovie.list_guys()
|
||||
my_logger.debug("Guys listed")
|
||||
self.facemovie.prepare_faces() # I want to search for the faces, and characteristics of the images
|
||||
my_logger.debug("Faces prepared")
|
||||
self.facemovie.find_final_dimensions() # finds output size for desired mode.
|
||||
my_logger.debug("Final dimensions found")
|
||||
self.facemovie.save_movie()
|
||||
my_logger.debug("Movie saved")
|
||||
|
||||
print "Finished!"
|
||||
my_logger.debug("Thread terminated")
|
||||
|
||||
@@ -65,7 +65,6 @@ class FaceMovie(object):
|
||||
self.mode = face_params.mode # can be crop or conservative.
|
||||
|
||||
###
|
||||
#self.CV_MAX_PIXEL = 13000 * 13000 # experimental maximal size of an IplImage
|
||||
self.guys = [] # List of pictures in source folder
|
||||
|
||||
self.center = [0, 0] # Position of the center in output images (x, y)
|
||||
@@ -92,11 +91,11 @@ class FaceMovie(object):
|
||||
self.my_logger = logging.getLogger('FileLog')
|
||||
# create file handler which logs even debug messages
|
||||
fh = logging.FileHandler('log/fm.log')
|
||||
fh.setLevel(logging.DEBUG)
|
||||
fh.setLevel(logging.INFO)
|
||||
# create console handler with a higher log level
|
||||
self.console_logger = logging.getLogger('ConsoleLog')
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.DEBUG)
|
||||
ch.setLevel(logging.INFO)
|
||||
|
||||
# create formatter and add it to the handlers
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
@@ -110,6 +109,18 @@ class FaceMovie(object):
|
||||
self.my_logger.addHandler(fh)
|
||||
self.console_logger.addHandler(ch)
|
||||
|
||||
# DEBUG
|
||||
self.console_logger.info("MFCKR")
|
||||
self.console_logger.debug("MFCKR")
|
||||
self.console_logger.warning("MFCKR")
|
||||
self.console_logger.error("MFCKR")
|
||||
self.console_logger.critical("MFCKR")
|
||||
self.my_logger.info("MFCKR")
|
||||
self.my_logger.debug("MFCKR")
|
||||
self.my_logger.warning("MFCKR")
|
||||
self.my_logger.error("MFCKR")
|
||||
self.my_logger.critical("MFCKR")
|
||||
|
||||
def list_guys(self):
|
||||
"""
|
||||
Aims at populating the guys list, using the source folder as an input.
|
||||
@@ -154,8 +165,8 @@ class FaceMovie(object):
|
||||
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.my_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):
|
||||
"""
|
||||
@@ -381,7 +392,7 @@ class FaceMovie(object):
|
||||
|
||||
#frameSize = (652, 498)
|
||||
pace = ["slow", "normal", "fast"]
|
||||
self.console_logger.info("Speed is set to %s" %(pace[speedrate])
|
||||
self.console_logger.info("Speed is set to %s" %(pace[speedrate]))
|
||||
self.my_logger.info("Speed is set to %s" %(pace[speedrate]))
|
||||
my_video = cv.CreateVideoWriter(self.get_out_file(),
|
||||
fourcc,
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
.. moduleauthor:: Julien Lengrand-Lambert <jlengrand@gmail.com>
|
||||
|
||||
"""
|
||||
import cv
|
||||
|
||||
import time
|
||||
import logging
|
||||
|
||||
import cv
|
||||
|
||||
class Guy(object):
|
||||
"""
|
||||
@@ -94,6 +95,8 @@ class Guy(object):
|
||||
try:
|
||||
my_date = time.strptime(date, "%Y:%m:%d %H:%M:%S")
|
||||
except Exception:
|
||||
my_logger = logging.getLogger('FileLog')
|
||||
my_logger.error("Impossible to parse date for %s" %(self.name))
|
||||
my_date = time.time()
|
||||
return my_date
|
||||
|
||||
|
||||
Reference in New Issue
Block a user