starts refactoring

This commit is contained in:
2012-06-19 08:11:48 +02:00
parent 228d4253c1
commit cdd2879529
2 changed files with 20 additions and 5 deletions

View File

@@ -226,11 +226,8 @@ class FaceMovie(object):
"""
# FIXME: badly done !
for a_guy in self.guys:
# TODO : change to a_guy.get_def_dims
xc = int(a_guy.ratio * a_guy.x_center)
yc = int(a_guy.ratio * a_guy.y_center)
inx = int(a_guy.ratio * a_guy.in_x)
iny = int(a_guy.ratio * a_guy.in_y)
(xc, yc) = a_guy.resized_center()
(inx, iny) = a_guy.resized_dims()
# update center
if xc > self.x_center:

View File

@@ -52,6 +52,24 @@ class Guy(object):
self.normalize = False
self.ratio = 1.0
def resized_dims(self):
"""
Calculates the dimensions of the full image after having been resized using ratio.
:returns list of int - list of two integers, being (resized_x, resized_y)
"""
inx = int(self.ratio * self.in_x)
iny = int(self.ratio * self.in_y)
return (inx, iny)
def resized_center(self):
"""
Calculates the center position of the full image after having been resized using ratio.
:returns list of int - list of two integers, being (new_center_x, new_center_y)
"""
inx = int(self.ratio * self.x_center)
iny = int(self.ratio * self.y_center)
return (inx, iny)
def load_image(self):
"""
This function is used to load the image when needed. To reduce memory load, only its location is saved in real time