mirror of
https://github.com/jlengrand/Ivolution.git
synced 2026-03-10 08:21:18 +00:00
Bug fixed for default mode. Code has to be greatly enhanced
This commit is contained in:
@@ -47,7 +47,7 @@ class FaceMovie(object):
|
||||
|
||||
###
|
||||
|
||||
#self.CV_MAX_PIXEL = 13000 * 13000 # experimental maximal size of an IplImage
|
||||
self.CV_MAX_PIXEL = 13000 * 13000 # experimental maximal size of an IplImage
|
||||
|
||||
|
||||
self.guys = [] # List of pictures in source folder
|
||||
@@ -421,6 +421,9 @@ class FaceMovie(object):
|
||||
print "You may want to switch to crop mode or reduce image resolution !"
|
||||
sys.exit(0)
|
||||
|
||||
print "MAX DIMS : "
|
||||
print self.dim_x, self.dim_y
|
||||
|
||||
# finishes by calculating average face size
|
||||
self.calc_mean_face()
|
||||
|
||||
|
||||
@@ -250,6 +250,55 @@ class Guy(object):
|
||||
|
||||
return out_im
|
||||
|
||||
def create_output(self, x_size, y_size, x_point, y_point):
|
||||
"""
|
||||
Creates image output, centering the face center with the required position
|
||||
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
|
||||
|
||||
:returns: IplImage -- The ouput image, centered to fit with all other images
|
||||
|
||||
"""
|
||||
out_im = cv.CreateImage((x_size, y_size),cv.IPL_DEPTH_8U, self.in_channels)
|
||||
cv.Zero(out_im)
|
||||
|
||||
# We want to place the input image so that the center of the face matches
|
||||
# x_center and y_center
|
||||
x_center = int(self.ratio * self.x_center)
|
||||
y_center = int(self.ratio * self.y_center)
|
||||
|
||||
in_x = int(self.ratio * self.in_x)
|
||||
in_y = int(self.ratio * self.in_y)
|
||||
|
||||
xtl = x_point - x_center
|
||||
ytl = y_point - y_center
|
||||
w = in_x
|
||||
h = in_y
|
||||
|
||||
rect = (xtl, ytl, w, h)
|
||||
cv.SetImageROI(out_im, rect)
|
||||
|
||||
# Load input image
|
||||
in_image = self.load_image()
|
||||
norm_im = cv.CreateImage((in_x, in_y),cv.IPL_DEPTH_8U, self.in_channels)
|
||||
cv.Resize(in_image, norm_im)
|
||||
|
||||
print cv.GetSize(in_image), cv.GetSize(out_im), cv.GetSize(norm_im)
|
||||
|
||||
cv.Copy(norm_im, out_im)
|
||||
cv.ResetImageROI(out_im)
|
||||
|
||||
return out_im
|
||||
|
||||
def create_debug_output(self):
|
||||
"""
|
||||
Creates output image
|
||||
|
||||
4
to_v2.py
4
to_v2.py
@@ -26,8 +26,10 @@ facemovie.list_guys()
|
||||
facemovie.prepare_faces()
|
||||
facemovie.find_final_dimensions("default", cropdims=(0, 0))
|
||||
|
||||
print "###"
|
||||
print facemovie.dim_x, facemovie.dim_y
|
||||
print facemovie.x_center, facemovie.y_center
|
||||
print facemovie.save_out_movie(out_fo, 3)
|
||||
print "###"
|
||||
facemovie.save_out_movie(out_fo, 3)
|
||||
|
||||
print "Exiting..."
|
||||
Reference in New Issue
Block a user