diff --git a/ivolution/FacemovieThread.py b/ivolution/FacemovieThread.py index b2cbf76..27d8b57 100644 --- a/ivolution/FacemovieThread.py +++ b/ivolution/FacemovieThread.py @@ -98,6 +98,8 @@ class FacemovieThread(threading.Thread, Observable, Observer): self.facemovie.save_movie() self.my_logger.debug("Movie saved") self.notify(["PROGRESS", "Movie saved, Finished!", 1.0]) + # updating status to avoid remanent messages + self.notify(["STATUS", " ", 1.0]) if not self.stop_process: self.my_logger.debug("Thread terminated") diff --git a/ivolution/Facemovie_lib.py b/ivolution/Facemovie_lib.py index fec7b08..721b03f 100644 --- a/ivolution/Facemovie_lib.py +++ b/ivolution/Facemovie_lib.py @@ -106,14 +106,8 @@ class FaceMovie(object, Observable): for root, _, files in os.walk(self.source): for a_file in files: ptr += 1 - # notifying the Observers - try: - message = "Processing file %d / %d" %(ptr, len(files)) - self.notify([message, self.percent(ptr, len(files))]) - except (ArithmeticError, ZeroDivisionError): - #pass - self.notify(["Error", 0]) + self.notify_progress("Processing file", ptr, len(files)) if self.run : # as long as we want to continue guy_source = os.path.join(root, a_file) @@ -171,12 +165,7 @@ class FaceMovie(object, Observable): a_guy.search_face(self.face_params) # notifying the Observers - try: - message = "Processing picture %d / %d" %(ptr, len(self.guys)) - self.notify([message, self.percent(ptr, len(self.guys))]) - except (ArithmeticError, ZeroDivisionError): - #pass - self.notify(["Error", 0]) + 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)) @@ -196,6 +185,18 @@ class FaceMovie(object, Observable): return (num / float(den)) + def notify_progress(self, message_root, num, den): + """ + A notification scheme to quickly notify most common messages + """ + # notifying the Observers + try: + message = message_root + " %d / %d" %(num, den) + self.notify([message, self.percent(num, den)]) + except (ArithmeticError, ZeroDivisionError): + #pass + self.notify(["Error", 0]) + def clean_guys(self): """ Removes all guys for who no face has been found. @@ -310,11 +311,17 @@ class FaceMovie(object, Observable): the image input image is placed in the output at the correct position. Black borders are set everywhere else. """ - # FIXME: badly done ! + # TODO: badly done ! x_af = 0 y_af = 0 + + ptr = 0 for a_guy in self.guys: if self.run : + ptr +=1 + # notifying the Observers + self.notify_progress("Processing picture", ptr, self.number_guys()) + (xc, yc) = a_guy.resized_center() (inx, iny) = a_guy.resized_dims() @@ -336,13 +343,21 @@ class FaceMovie(object, Observable): Calculates smallest output image that can be used to avoid adding black borders on image It will later be used to create the final image. """ - # FIXME: badly done ! + # TODO: badly done ! ht = 1000000 # space left above eyes hb = 1000000 # space left beneath eyes wl = 1000000 # space left left of eyes wr = 1000000 # space left right of eyes + + tr = 0 + + ptr = 0 for a_guy in self.guys: if self.run: + ptr +=1 + # notifying the Observers + self.notify_progress("Processing picture", ptr, self.number_guys()) + (xc, yc) = a_guy.resized_center() (inx, iny) = a_guy.resized_dims() @@ -402,6 +417,8 @@ class FaceMovie(object, Observable): for a_guy in self.guys: if self.run: ii += 1 + self.notify_progress("Saving frame", 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) diff --git a/ivolution/data/samples/output.avi b/ivolution/data/samples/output.avi index 57e07f0..fb2dc1a 100644 Binary files a/ivolution/data/samples/output.avi and b/ivolution/data/samples/output.avi differ diff --git a/ivolution/gui/IvolutionWindow.py b/ivolution/gui/IvolutionWindow.py index 026f07b..2e62767 100755 --- a/ivolution/gui/IvolutionWindow.py +++ b/ivolution/gui/IvolutionWindow.py @@ -248,16 +248,16 @@ class IvolutionWindow(Observer, Observable): GLib.idle_add(self.progressbar.set_fraction, float(message[2])) GLib.idle_add(self.progressbar.set_text, message[1]) + 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.process_running = False + elif message[0] == "STATUS": # status label # intermediate results GLib.idle_add(self.statuslabel.set_text, message[1]) #pass - 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.process_running = False - else: self.console_logger.debug("Unrecognized command") self.my_logger.debug("Unrecognized command")