From 31fe7c41fcc76e97a0ef036b80ce96b9941f73d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Haberth=C3=BCr?= Date: Sat, 10 Jan 2015 23:04:25 +0100 Subject: [PATCH 1/3] Version used for *my* timelapse --- src/config.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/config.py b/src/config.py index a73e105..70ad8d5 100644 --- a/src/config.py +++ b/src/config.py @@ -1,5 +1,5 @@ #: The path to the opencv install's Haar cascade folder -HCDIR = 'C:/opencv/sources/data/haarcascades/' +HCDIR = '/usr/local/Cellar/opencv/2.4.9/share/OpenCV/haarcascades' #: The name of the eyepair Haar cascade file to use HC_EYEPAIR_NAME = 'haarcascade_mcs_eyepair_big.xml' @@ -14,20 +14,20 @@ HC_FACE_NAME = 'haarcascade_frontalface_alt2.xml' #: The final image height -HEIGHT_TARGET = 720 +HEIGHT_TARGET = 640 #: The final image width -WIDTH_TARGET = 960 +WIDTH_TARGET = 640 #: What is used when the image must be offset too far? 0 for black border, 1 for stretch colors -GAP_BORDER = 1 +GAP_BORDER = 0 # Debugging parameters #: If True, print debug info -DEBUG = True +DEBUG = False #: If true, will mark on the image the eyes/eyepairs which were selected to be used for calculations MARKUSED = False @@ -39,7 +39,7 @@ NOTRANSFORM = False #: If true, skip individual eye/eyepair detection, and go to face detection -FORCE_FULL_FACE = True +FORCE_FULL_FACE = False @@ -65,10 +65,10 @@ FACE_WIDTH_TO_EYE_WIDTH = .41 #: The minimum size detection threshold for eyepair as a fraction of the image size -EYEPAIR_MIN_SIZE = (.15, .03) +EYEPAIR_MIN_SIZE = (.05, .03) #: The maximum size detection threshold for eyepair as a fraction of the image size -EYEPAIR_MAX_SIZE = (.55, 1) +EYEPAIR_MAX_SIZE = (.65, 1) @@ -108,4 +108,4 @@ MID_Y_TARGET = HEIGHT_TARGET*MID_Y_TARGET_RATIO #: Reject a left/right pair of eyes if one is larger by this factor or more -EYE_MAX_SIZE_DIFFERENCE = 2 \ No newline at end of file +EYE_MAX_SIZE_DIFFERENCE = 2 From 3ea2ed0ef98dc965d808eaf0af1543e8cbde419e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Haberth=C3=BCr?= Date: Sat, 10 Jan 2015 23:04:42 +0100 Subject: [PATCH 2/3] Added OS X installation/config --- README.md | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e770f4b..8869195 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,45 @@ FaceAlign -======== - -FaceAlign is a tool that can be used to align a set of images containing faces. It is particularly useful for creating "time-lapse" face videos, such as this one : http://youtube.com/watch?v=7SXErQ4eYGU +==== +FaceAlign is a tool that can be used to align a set of images containing faces. +It is particularly useful for creating time-lapse face videos, such as [this one](http://youtube.com/watch?v=7SXErQ4eYGU). How it works ------------- +---- +FaceAlign is a Python script that uses [OpenCV python bindings](http://OpenCV.willowgarage.com/wiki/) (which requires >= Python 2.6). +It detects the location of the face in each image (OpenCV tends to err on the side of over-detection, and this tool will use the largest detected face) and will scale and offset the image so that the centers of the faces in all images match up. +This is based on parameters that can be easily set in [config.py](src/config.py). -FaceAlign is a Python script that uses [opencv python bindings](http://opencv.willowgarage.com/wiki/), which requires >= Python 2.6. It detects the location of the face in each image (opencv tends to err on the side of over-detection, and this tool will use the largest detected face) and will scale and offset the image so that the centers of the faces in all images will match up. This is based on parameters that can be easily set in config.py. +On OS X, OpenCV can be installed with [homebrew](http://brew.sh). +To do so, install homebrew and run the following command in your terminal. + $ brew install OpenCV --32-bit + Usage ------ +---- +Once Python and [OpenCV](http://OpenCV.org) are installed, open [config.py](src/config.py) and set HCDIR to the folder containing your OpenCV installation's Haar cascade files. -Once python and opencv are installed, open config.py and set HCDIR to the folder containing your opencv installation's Haar cascade files. +On OS X, you can find the Haar cascade files under `/usr/local/Cellar/OpenCV/2.4.9/share/OpenCV/haarcascades` if you've used homebrew to install OpenCV. -Run sizeToFace.py. It takes a required input directory parameter, and an optional output directory parameter. The output directory will be created if it does not already exist. By default, images will be output to the current directory. Output file names will be numbered starting with 0001.jpg. +Run sizeToFace.py. +It takes a required input directory parameter, and an optional output directory parameter. +The output directory will be created if it does not already exist. +By default, images will be output to the current directory. +Output file names will be numbered starting with 0001.jpg. $ python src/sizeToFace.py ../in-images - $ python src/sizeToFace.py ../in-images ../out-images Eventual plans --------------- - +---- * Brightness/contrast normalization * Integration with ffmpeg for automatic video generation * A GUI Common Errors/Solutions ------------------------ +---- ImportError: No module named cv -**Solution**: You have not installed OpenCV or the OpenCV Python bindings - +**Solution**: You have not installed OpenCV or the OpenCV Python bindings. Traceback (most recent call last): File "<...>/src/facealign/src/FaceImage.py", line 133, in runFaceImage @@ -42,11 +50,14 @@ Common Errors/Solutions cascade = cv.Load(HCPATH) TypeError: OpenCV returned NULL -**Solution**: This means you have not set your HCDIR variable correctly. Open src/config.py and set HCDIR to -[yourOpenCVDir]/opencv/data/haarcascades/, for example: -HCDIR = '/home/doriad/src/OpenCV/opencv/data/haarcascades/' +**Solution**: This means you have not set your HCDIR variable correctly. +*Open src/config.py and set HCDIR to +[yourOpenCVDir]/OpenCV/data/haarcascades/, for example: +HCDIR = '/home/doriad/src/OpenCV/OpenCV/data/haarcascades/' So what's up? -------------- - -Feedback, ideas, issue reports, and contributions are invited. Welcomed. Demanded, even. FaceAlign is fairly simple at the moment but I would be interested to hear if you found it useful. +---- +Feedback, ideas, issue reports, and contributions are invited. +Welcomed. +Demanded, even. +FaceAlign is fairly simple at the moment but I would be interested to hear if you found it useful. From 05927fcc63b13b8f711d096aaa253818e192add3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Haberth=C3=BCr?= Date: Mon, 11 Jan 2016 22:39:04 +0100 Subject: [PATCH 3/3] Make it bigger in 2015! --- src/config.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/config.py b/src/config.py index 70ad8d5..1f6cd79 100644 --- a/src/config.py +++ b/src/config.py @@ -14,16 +14,15 @@ HC_FACE_NAME = 'haarcascade_frontalface_alt2.xml' #: The final image height -HEIGHT_TARGET = 640 +HEIGHT_TARGET = 1088 #: The final image width -WIDTH_TARGET = 640 +WIDTH_TARGET = 816 #: What is used when the image must be offset too far? 0 for black border, 1 for stretch colors GAP_BORDER = 0 - # Debugging parameters #: If True, print debug info @@ -42,7 +41,6 @@ FORCE_FULL_FACE = False - # Face characteristics, may need to be tweaked per face #: An eyepair is probably valid with this width/height ratio