📄 rowley.cpp
字号:
// $rowley.cpp 1.5 milbo$ interface between ASM software and Rowley face detector//-----------------------------------------------------------------------------// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// A copy of the GNU General Public License is available at// http://www.r-project.org/Licenses///-----------------------------------------------------------------------------#include "all.hpp"//-----------------------------------------------------------------------------// Returns with face and eye positions in Shape.// Face is a "Rowley global detector shape", with NBR_ROWLEY_POINTS points.// See DETECTOR_ defs in landmarks.hpp for point names.// If it can't find a face (with two eyes), we exit with an error message.boolfRowleyFindFace (SHAPE &Shape, // out Image &Img, const char sImageFile[], const char sDataDir[]) // in{bool fSuccess = true;Shape.dimClear(NBR_ROWLEY_POINTS, 2);tFaceEyeLocation *pLocations; // found face and eye coords go into this arrayint nFaces = Track_FindAllFaces(&pLocations, Img, sDataDir);// choose biggest face with both eyesint iBest = 0, nMaxWidth = 0;for (int iFace = 0; iFace < nFaces; iFace++) if (pLocations[iFace].xLeftEye > 0 && pLocations[iFace].xRightEye > 0 && pLocations[iFace].x2 - pLocations[iFace].x1 > nMaxWidth) { iBest = iFace; nMaxWidth = pLocations[iFace].x2 - pLocations[iFace].x1; }if (nFaces < 1) { fSuccess = false; lprintf("\nRowley detector found no faces in %s\n", sImageFile); }if (pLocations[iBest].xLeftEye <= 0) { fSuccess = false; lprintf("\nRowley detector didn't find the left eye in %s\n", sImageFile); }if (pLocations[iBest].xRightEye <= 0) { fSuccess = false; lprintf("\nRowley detector didn't find the right eye in %s\n", sImageFile); }// Write the global detector shape into Shape.// The macros convert Rowley shape coords to our internal shape coords.#define X(x) (double)((x) - Img.width / 2)#define Y(y) (double)(Img.height / 2 - (y))Shape(DETECTOR_TopLeft, VX) = X(pLocations[iBest].x1);Shape(DETECTOR_TopLeft, VY) = Y(pLocations[iBest].y1);Shape(DETECTOR_BotRight, VX) = X(pLocations[iBest].x2);Shape(DETECTOR_BotRight, VY) = Y(pLocations[iBest].y2);Shape(DETECTOR_LEye, VX) = X(pLocations[iBest].xRightEye);Shape(DETECTOR_LEye, VY) = Y(pLocations[iBest].yRightEye);Shape(DETECTOR_REye, VX) = X(pLocations[iBest].xLeftEye);Shape(DETECTOR_REye, VY) = Y(pLocations[iBest].yLeftEye);free(pLocations);return fSuccess;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -