Skip to content

Commit

Permalink
refinement of face scale, additional test images.
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrence Curran committed Sep 9, 2012
1 parent f1c07dc commit 88014ba
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 10 deletions.
10 changes: 9 additions & 1 deletion .cproject
Expand Up @@ -37,12 +37,17 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug.346560219" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug">
<option id="gnu.cpp.compilermacosx.exe.debug.option.optimization.level.1720099888" name="Optimization Level" superClass="gnu.cpp.compilermacosx.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.macosx.exe.debug.option.debugging.level.1217205379" name="Debug Level" superClass="gnu.cpp.compiler.macosx.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.442639566" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths"/>
<option id="gnu.cpp.compiler.option.include.paths.442639566" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1003059385" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.1826575915" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.macosx.exe.debug.option.optimization.level.226580803" name="Optimization Level" superClass="gnu.c.compiler.macosx.exe.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.macosx.exe.debug.option.debugging.level.689082904" name="Debug Level" superClass="gnu.c.compiler.macosx.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.915402005" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.322810501" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
</toolChain>
Expand Down Expand Up @@ -83,6 +88,9 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release.945218295" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.release">
<option id="gnu.cpp.compiler.macosx.exe.release.option.optimization.level.1711908702" name="Optimization Level" superClass="gnu.cpp.compiler.macosx.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.macosx.exe.release.option.debugging.level.1567253914" name="Debug Level" superClass="gnu.cpp.compiler.macosx.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.2021739771" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/c++/4.2.1"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1225328869" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release.895477205" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.release">
Expand Down
25 changes: 17 additions & 8 deletions src/EyeDetector.cpp
Expand Up @@ -49,15 +49,19 @@ void EyeDetector::find(IplImage *image, CvPoint *leftEye, CvPoint *rightEye) {
cvConvert(image, imgCopy);
}

double percentageFromTop = 6;
double percentageFromBottom = 45;

cvSetImageROI(imgCopy, /* the source image */
cvRect(0, /* x = start from leftmost */
(image->height / 5), /* y = a few pixels from the top */
image->width, /* width = same width with the face */
image->height / 2.0 - image->height / 5 /* height = 1/3 of face height */
));
cvRect(0, /* x = start from leftmost */
(image->height * percentageFromTop / 100), /* y = a few pixels from the top */
image->width, /* width = same width with the face */
image->height - (image->height * percentageFromBottom / 100) /* height = 1/3 of face height */
)
);

IplImage *eyeBlock = cvCreateImage(
cvSize(imgCopy->width, imgCopy->height / 2 - imgCopy->height / 5),
cvSize(imgCopy->width, image->height - (image->height * percentageFromBottom / 100)),
8, 1);

cvCopy(imgCopy, eyeBlock);
Expand Down Expand Up @@ -208,10 +212,10 @@ void EyeDetector::find(IplImage *image, CvPoint *leftEye, CvPoint *rightEye) {
rightEye->x = rightEye->x / eyeScale;
}
if (leftEye->y > 0) {
leftEye->y = (image->height / 5) + (leftEye->y / eyeScale);
leftEye->y = (image->height * percentageFromTop / 100) + (leftEye->y / eyeScale);
}
if (rightEye->y > 0) {
rightEye->y = (image->height / 5) + (rightEye->y / eyeScale);
rightEye->y = (image->height * percentageFromTop / 100) + (rightEye->y / eyeScale);
}

if (opt_debug) {
Expand Down Expand Up @@ -239,6 +243,7 @@ void EyeDetector::init() {
findMethod = FIND_LARGEST;
opt_show_ui = false;
opt_debug = false;
opt_show_ui = false;
width_min = 150;
width_max = 300;
}
Expand All @@ -247,6 +252,10 @@ void EyeDetector::setDebug(bool debug) {
opt_debug = debug;
}

void EyeDetector::setShowUi(bool value) {
opt_show_ui = value;
}

void EyeDetector::setLeftEyeCascade(char * classifier) {
eyeCascadeLeft = (CvHaarClassifierCascade*) cvLoad(classifier, 0, 0, 0);
if (!eyeCascadeLeft) {
Expand Down
3 changes: 2 additions & 1 deletion src/EyeDetector.hpp
Expand Up @@ -15,13 +15,13 @@ class EyeDetector {
EyeDetector();
EyeDetector(char *leftClassifier, char *rightClassifier);
void setDebug(bool opt_debug);
void setShowUi(bool value);
void setLeftEyeCascade(char *classifier);
void setRightEyeCascade(char *classifier);
void find(IplImage *image, CvPoint *leftEye, CvPoint *rightEye);

static const int FIND_AVERAGE = 1;
static const int FIND_LARGEST = 2;
bool opt_show_ui;
~EyeDetector();

private:
Expand All @@ -33,6 +33,7 @@ class EyeDetector {
CvHaarClassifierCascade* eyeCascadeLeft;
CvHaarClassifierCascade* eyeCascadeRight;
bool opt_debug;
bool opt_show_ui;
int width_min;
int width_max;

Expand Down
2 changes: 2 additions & 0 deletions src/Main.cpp
Expand Up @@ -71,6 +71,8 @@ int main(int argc, char** argv) {

// load the eye detector cascades
eyeDetector = new EyeDetector();
eyeDetector->setDebug(opt_debug);
eyeDetector->setShowUi(opt_show_ui);

if (opt_cascade_eye_left) {
eyeDetector->setLeftEyeCascade(opt_cascade_eye_left);
Expand Down
Binary file added testimages/155888_1747578334547_83286_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/163967_484044053479_8209700_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/166845_10150091459468480_395426_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/168000_10150395397470335_7893062_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/188615_1856045010737_5839264_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/196426_198112170210394_1494900_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/215639_5689580274_9599_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/262415_10150757188735335_3029373_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/420113_3160221937524_614586401_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/45542_1511609823179_3977878_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/59357_150775848278462_5929966_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimages/6370_120658728479_8131956_n.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 88014ba

Please sign in to comment.