creates prepare_image, designed to prepare the ouput image so that it is ready to be saved.

This commit is contained in:
2012-06-20 14:11:40 +02:00
parent c126cce049
commit 5328556d22
2 changed files with 26 additions and 36 deletions

View File

@@ -283,13 +283,7 @@ class FaceMovie(object):
for a_guy in self.guys:
ii += 1
print "Saving frame %d / %d" %(ii, self.number_guys())
if self.mode == "default":
out_im = a_guy.create_default_output(self.dims,
self.center)
elif self.mode == "crop":
out_im = a_guy.create_crop_output(self.dims,
self.center)
out_im = self.prepare_image(a_guy)
cv.WriteFrame(my_video, out_im)
def show_faces(self, mytime=1000):
@@ -301,14 +295,8 @@ class FaceMovie(object):
:type mytime: int
"""
for a_guy in self.guys:
if self.mode == "default":
out_im = a_guy.create_default_output(self.dims,
self.center)
elif self.mode == "crop":
out_im = a_guy.create_crop_output(self.dims,
self.center)
self.out_display(out_im, a_guy.name, time=mytime)
out_im = self.prepare_image(a_guy)
self.out_display(out_im, a_guy.name, time=mytime)
def save_faces(self, out_folder, im_format="png"):
"""
@@ -321,13 +309,7 @@ class FaceMovie(object):
:type im_format: string
"""
for a_guy in self.guys:
if self.mode == "default":
out_im = a_guy.create_default_output(self.dims,
self.center)
elif self.mode == "crop":
out_im = a_guy.create_crop_output(self.dims,
self.center)
out_im = self.prepare_image(a_guy)
self.save_result(out_im, a_guy.name, out_folder, im_format)
def number_guys(self):
@@ -381,4 +363,21 @@ class FaceMovie(object):
out_name = os.path.join(out_folder, file_name)
print "Saving %s" %(out_name)
cv.SaveImage(out_name, im)
cv.SaveImage(out_name, im)
def prepare_image(self, a_guy):
"""
Takes a Guy and processes its input image. Prepares the final output image for this
Guy, so that it is ready to be saved in the desired output.
:param a_guy: The Guy currently being processed.
:type a_guy: Guy
:returns: IplImage -- The ouput image, created depending on the chosen mode, ready to be saved
"""
if self.mode == "default":
out_im = a_guy.create_default_output(self.dims,
self.center)
elif self.mode == "crop":
out_im = a_guy.create_crop_output(self.dims,
self.center)
return out_im

View File

@@ -189,14 +189,10 @@ class Guy(object):
If eq_ratio is set to something different than one, input image is scaled
so that face/size = eq_ratio
:param x_size: The size of the ouput image in x (in pixels)
:type x_size: int
:param y_size: The size of the ouput image in y (in pixels)
:type y_size: int
:param x_point: The center of the output image, where the Guy image has to fit in (in pixels)
:type x_point: int
:param y_point: The center of the output image, where the Guy image has to fit in (in pixels)
:type y_point: int
:param size: The size of the ouput image in [x, y] (in pixels)
:type size: list of 2 ints
:param point: The location of the Guy image center, after image has been cropped(in pixels)
:type point: list of 2 ints
:returns: IplImage -- The ouput image, centered to fit with all other images
@@ -264,11 +260,6 @@ class Guy(object):
cv.ResetImageROI(out_im)
return out_im
def prepare_image(center, point, size, mode):
"""
"""
def num_faces(self):
"""