Adds user interaction for cropping. TODO : Add corresponding option in command line. Change pixels to number of face size

This commit is contained in:
AirballTest
2012-05-11 18:08:24 +02:00
parent 95f66ae519
commit b40b38d996
2 changed files with 37 additions and 20 deletions

View File

@@ -43,9 +43,16 @@ class FaceMovie(object):
# thumbmails
self.crop = False
self.cropdims = [0, 0] # user defined desired dimensions for cropping
self.width = [0, 0]
self.height = [0, 0]
def set_crop_dims(self, crop_x, crop_y):
"""
Sets the cropping dimension in case they have been provided by the end user
"""
self.cropdims = [crop_x, crop_y]
def list_guys(self):
"""
Aims at populating the guys list, using the source folder as an input.
@@ -103,26 +110,33 @@ class FaceMovie(object):
wl = 1000000 # space left left of eyes
wr = 1000000 # space left right of eyes
for a_guy in self.guys:
if a_guy.has_face():
xc = a_guy.x_center
yc = a_guy.y_center
inx = a_guy.in_x
iny = a_guy.in_y
# finding width
if xc < wl:
wl = xc
if (inx - xc) < wr:
wr = inx - xc
# finding height
if yc < ht:
ht = yc
if (iny - yc) < hb:
hb = iny - yc
self.width = [wl, wr]
self.height = [ht, hb]
if self.cropdims != [0, 0]:
w = int(self.cropdims[0] / 2)
self.width = [w, w]
h = int(self.cropdims[1] / 2)
self.height = [h, h]
else:
for a_guy in self.guys:
if a_guy.has_face():
xc = a_guy.x_center
yc = a_guy.y_center
inx = a_guy.in_x
iny = a_guy.in_y
# finding width
if xc < wl:
wl = xc
if (inx - xc) < wr:
wr = inx - xc
# finding height
if yc < ht:
ht = yc
if (iny - yc) < hb:
hb = iny - yc
self.width = [wl, wr]
self.height = [ht, hb]
self.crop = True
def find_out_dims(self):

View File

@@ -89,6 +89,9 @@ class Facemoviefier():
# I want to know the size of the output frame, knowing initial conditions
self.facemovie.find_out_dims() # finds output minimal size to get all eyes in the same place
if self.args['crop']:
# TODO: additional parameters (2) may be added here. Add support for this
self.facemovie.set_crop_dims(100, 100) # TODO : do we need something else than pixel here ? It stinks due to face normalization.
# TODO : Change to number of face size
self.facemovie.find_crop_dims() # finds output minimal size to get all eyes in the same place
#choose your final step