Adds max image limit to avoid errors; start searching for image orientation in exif files

This commit is contained in:
2012-06-05 18:24:20 +02:00
parent 7c969fd9b3
commit 92a45fe285
4 changed files with 71 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ class FaceMovie(object):
Takes a bunch of parameters and a list of images and tries to create a
video out of it.
Contains general methods, aimed at being used trough an interface.
'''
'''
def __init__(self, in_folder, out_folder, face_params):
"""
Initializes all parameters of the application. Input and output folders
@@ -37,6 +37,8 @@ class FaceMovie(object):
:param face_param: the location of the profile file used to train the classifier
:type face_param: string
"""
self.CV_MAX_PIXEL = 13000 * 13000 # experimental maximal size of an IplImage
self.source= in_folder # Source folder for pictures
self.out = out_folder # Folder to save outputs
@@ -98,7 +100,7 @@ class FaceMovie(object):
guy_source = os.path.join(self.source, token)
image = cv.LoadImage(guy_source)
guy_name = os.path.splitext(token)[0]
print guy_source
try:
guy_date = exif.parse(guy_source)['DateTime']
except Exception:
@@ -245,6 +247,11 @@ class FaceMovie(object):
self.dim_x = self.x_af + self.x_center
self.dim_y = self.y_af + self.y_center
if self.dim_x * self.dim_y > self.CV_MAX_PIXEL:
print "Max size reached for large mode!"
print "You may want to switch to crop mode or reduce image resolution !"
sys.exit(0)
# finishes by calculating average face size
self.calc_mean_face()

View File

@@ -39,11 +39,9 @@ class Guy(object):
# Some operations on variables
#image = self.load_image() # used to get size
self.in_x = 1280
self.in_y = 960
image = self.load_image()
(self.or_x, self.or_y) = cv.GetSize(image) # image size in x, y
#(self.in_x, self.in_y) = cv.GetSize(image) # image size in x, y
#(self.or_x, self.or_y) = cv.GetSize(image) # image size in x, y
(self.in_x, self.in_y) = cv.GetSize(image) # image size in x, y
# FIXME : Time for me to find a better solution
self.in_channels = image.nChannels
@@ -61,10 +59,10 @@ class Guy(object):
"""
# FIXME : Time for me to find a better solution
image = cv.LoadImage(self.source)
out = cv.CreateImage((self.in_x, self.in_y), cv.IPL_DEPTH_8U, image.nChannels)
cv.Resize(image, out)
#out = cv.CreateImage((self.in_x, self.in_y), cv.IPL_DEPTH_8U, image.nChannels)
#cv.Resize(image, out)
return out
return image
def load_normalized_image(self):
"""

22
test/exif_landscape.py Normal file
View File

@@ -0,0 +1,22 @@
"""
.. module:: max_size
:platform: Unix, Windows
:synopsis: Test class aiming at finding the maximum image size that can be generated to create a FaceMovie using OpenCV
.. moduleauthor:: Julien Lengrand-Lambert <jlengrand@gmail.com>
"""
from facemovie.lib import exif
import cv
guy_source = "C:\Users\jll\perso\workspace\FaceMovie\data\inputs\moi\DSC04869.JPG"
aa = cv.LoadImage(guy_source)
cv.NamedWindow("a")
cv.ShowImage("a", aa)
cv.WaitKey(100)
data = exif.parse(guy_source)
print data.keys()
print data["Orientation"] # portrait/ paysage? ? ?

35
test/max_size.py Normal file
View File

@@ -0,0 +1,35 @@
"""
.. module:: max_size
:platform: Unix, Windows
:synopsis: Test class aiming at finding the maximum image size that can be generated to create a FaceMovie using OpenCV
.. moduleauthor:: Julien Lengrand-Lambert <jlengrand@gmail.com>
"""
import cv
#x = 1000
#y = 169000
x = 13000
y = 13000
max_pix = x * y
bb = cv.LoadImage("../data/inputs/moi/DSC04862.JPG")
aa = cv.CreateImage((x, y), cv.IPL_DEPTH_8U, 3)
#cv.Resize(bb, aa)
cv.Zero(aa)
cv.NamedWindow("a", 1)
cv.ShowImage("a", aa)
cv.WaitKey(1000)
print "Done!"
print max_pix
print 13000 * 13000