diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e83c8b..e399a25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ add_definitions(-DKDE_DEFAULT_DEBUG_AREA=${LIBKFACE_AREA_CODE_GENERAL}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) include(MacroOpenCV) -DETECT_OPENCV(2.4.9 core highgui objdetect contrib legacy imgproc) +DETECT_OPENCV(2.4.9 core highgui objdetect face legacy imgproc) include_directories(${OpenCV_INCLUDE_DIRS}) diff --git a/cmake/modules/modules_opencv/FindOpenCV.cmake b/cmake/modules/modules_opencv/FindOpenCV.cmake index 7580b32..6d3da76 100644 --- a/cmake/modules/modules_opencv/FindOpenCV.cmake +++ b/cmake/modules/modules_opencv/FindOpenCV.cmake @@ -173,7 +173,6 @@ find_library(OpenCV_ML_LIBRARY find_library(OpenCV_TRS_LIBRARY NAMES trs PATHS ${OpenCV_ROOT_DIR} PATH_SUFFIXES ${OpenCV_LIBDIR_SUFFIXES} ) - # # Logic selecting required libs and headers # diff --git a/libkface/detection/opencvfacedetector.cpp b/libkface/detection/opencvfacedetector.cpp index 7c420ae..28edeea 100644 --- a/libkface/detection/opencvfacedetector.cpp +++ b/libkface/detection/opencvfacedetector.cpp @@ -138,11 +138,12 @@ public: { // This is a HACK which may break any time. Work around the fact that getOriginalWindowSize() // always returns (0,0) and we need these values. +/* if (oldCascade) { return oldCascade->orig_window_size; } - +*/ return cv::Size(0, 0); } diff --git a/libkface/libopencv.h.cmake.in b/libkface/libopencv.h.cmake.in index 0a1a958..e70fc0c 100644 --- a/libkface/libopencv.h.cmake.in +++ b/libkface/libopencv.h.cmake.in @@ -51,13 +51,11 @@ #define OPENCV_VERSION OPENCV_MAKE_VERSION(CV_MAJOR_VERSION,CV_MINOR_VERSION,CV_SUBMINOR_VERSION) #define OPENCV_TEST_VERSION(major,minor,patch) ( OPENCV_VERSION >= OPENCV_MAKE_VERSION(major,minor,patch) ) -#include -#include -#include +#include +#include // for old-style code #include -#include #include #include diff --git a/libkface/recognition-opencv-lbph/facerec_borrowed.cpp b/libkface/recognition-opencv-lbph/facerec_borrowed.cpp index 935a3d0..11aee02 100644 --- a/libkface/recognition-opencv-lbph/facerec_borrowed.cpp +++ b/libkface/recognition-opencv-lbph/facerec_borrowed.cpp @@ -531,14 +531,5 @@ Ptr LBPHFaceRecognizer::create(int radius, int neighbors, in return ptr; } -CV_INIT_ALGORITHM(LBPHFaceRecognizer, "FaceRecognizer.LBPH-KFaceIface", - obj.info()->addParam(obj, "radius", obj.m_radius); - obj.info()->addParam(obj, "neighbors", obj.m_neighbors); - obj.info()->addParam(obj, "grid_x", obj.m_grid_x); - obj.info()->addParam(obj, "grid_y", obj.m_grid_y); - obj.info()->addParam(obj, "threshold", obj.m_threshold); - obj.info()->addParam(obj, "histograms", obj.m_histograms); // modification: Make Read/Write - obj.info()->addParam(obj, "labels", obj.m_labels); // modification: Make Read/Write - obj.info()->addParam(obj, "statistic", obj.m_statisticsMode)); // modification: Add parameter } // namespace KFaceIface diff --git a/libkface/recognition-opencv-lbph/facerec_borrowed.h b/libkface/recognition-opencv-lbph/facerec_borrowed.h index dd1ab16..22b14ac 100644 --- a/libkface/recognition-opencv-lbph/facerec_borrowed.h +++ b/libkface/recognition-opencv-lbph/facerec_borrowed.h @@ -45,7 +45,7 @@ namespace KFaceIface { -class LBPHFaceRecognizer : public cv::FaceRecognizer +class LBPHFaceRecognizer : public cv::face::FaceRecognizer { public: @@ -99,8 +99,8 @@ public: ~LBPHFaceRecognizer() {} - using cv::FaceRecognizer::save; - using cv::FaceRecognizer::load; + using cv::face::FaceRecognizer::save; + using cv::face::FaceRecognizer::load; static cv::Ptr create(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8, double threshold = DBL_MAX, PredictionStatistics statistics = NearestNeighbor); @@ -139,13 +139,31 @@ public: /** * Getter functions. */ - int neighbors() const { return m_neighbors; } - int radius() const { return m_radius; } - int grid_x() const { return m_grid_x; } - int grid_y() const { return m_grid_y; } + int getNeighbors() const { return m_neighbors; } + void setNeighbors(int _neighbors) { m_neighbors = _neighbors; } + + int getRadius() const { return m_radius; } + void setRadius(int radius) { m_radius = radius; } + + int getGrid_x() const { return m_grid_x; } + void setGrid_x(int _grid_x) { m_grid_x = _grid_x; } + + int getGrid_y() const { return m_grid_y; } + void setGrid_y(int _grid_y) { m_grid_y = _grid_y; } + + + double getThreshold() const { return m_threshold; } + void setThreshold(double _threshold) { m_threshold = _threshold; } + + void setHistograms(std::vector _histograms) { m_histograms = _histograms; } + std::vector getHistograms() const { return m_histograms; } + + void setLabels(cv::Mat _labels) { m_labels = _labels; } + cv::Mat getLabels() const { return m_labels; } + + void setStatistic(int _statistic) { m_statisticsMode = _statistic; } + int getStatistic() const { return m_statisticsMode; } - // NOTE: Implementation done through CV_INIT_ALGORITHM macro from OpenCV. - cv::AlgorithmInfo* info() const; private: diff --git a/libkface/recognition-opencv-lbph/lbphfacemodel.cpp b/libkface/recognition-opencv-lbph/lbphfacemodel.cpp index af8c6a5..75c5863 100644 --- a/libkface/recognition-opencv-lbph/lbphfacemodel.cpp +++ b/libkface/recognition-opencv-lbph/lbphfacemodel.cpp @@ -61,7 +61,7 @@ LBPHFaceModel::LBPHFaceModel() : cv::Ptr(LBPHFaceRecognizer::create()), databaseId(0) { - ptr()->set("threshold", 100.0); + ptr()->setThreshold(100.0); } LBPHFaceModel::~LBPHFaceModel() @@ -70,7 +70,7 @@ LBPHFaceModel::~LBPHFaceModel() LBPHFaceRecognizer* LBPHFaceModel::ptr() { - LBPHFaceRecognizer* const ptr = cv::Ptr::operator KFaceIface::LBPHFaceRecognizer*(); + LBPHFaceRecognizer* const ptr = get(); if (!ptr) kWarning() << "LBPHFaceRecognizer pointer is null"; @@ -80,7 +80,7 @@ LBPHFaceRecognizer* LBPHFaceModel::ptr() const LBPHFaceRecognizer* LBPHFaceModel::ptr() const { - const LBPHFaceRecognizer* const ptr = cv::Ptr::operator const KFaceIface::LBPHFaceRecognizer*(); + const LBPHFaceRecognizer* const ptr = get(); if (!ptr) kWarning() << "LBPHFaceRecognizer pointer is null"; @@ -90,47 +90,47 @@ const LBPHFaceRecognizer* LBPHFaceModel::ptr() const int LBPHFaceModel::radius() const { - return ptr()->get("radius"); + return ptr()->getRadius(); } void LBPHFaceModel::setRadius(int radius) { - ptr()->set("radius", radius); + ptr()->setRadius(radius); } int LBPHFaceModel::neighbors() const { - return ptr()->get("neighbors"); + return ptr()->getNeighbors(); } void LBPHFaceModel::setNeighbors(int neighbors) { - ptr()->set("neighbors", neighbors); + ptr()->setNeighbors(neighbors); } int LBPHFaceModel::gridX() const { - return ptr()->get("grid_x"); + return ptr()->getGrid_x(); } void LBPHFaceModel::setGridX(int grid_x) { - ptr()->set("grid_x", grid_x); + ptr()->setGrid_x(grid_x); } int LBPHFaceModel::gridY() const { - return ptr()->get("grid_y"); + return ptr()->getGrid_y(); } void LBPHFaceModel::setGridY(int grid_y) { - ptr()->set("grid_y", grid_y); + ptr()->setGrid_y(grid_y); } OpenCVMatData LBPHFaceModel::histogramData(int index) const { - return OpenCVMatData(ptr()->get >("histograms").at(index)); + return OpenCVMatData(ptr()->getHistograms().at(index)); } QList LBPHFaceModel::histogramMetadata() const @@ -168,12 +168,12 @@ void LBPHFaceModel::setHistograms(const QList& histograms, const m_histogramMetadata << metadata; } - std::vector currentHistograms = ptr()->get >("histograms"); - cv::Mat currentLabels = ptr()->get("labels"); + std::vector currentHistograms = ptr()->getHistograms(); + cv::Mat currentLabels = ptr()->getLabels(); currentHistograms.insert(currentHistograms.end(), newHistograms.begin(), newHistograms.end()); currentLabels.push_back(newLabels); - ptr()->set("histograms", currentHistograms); - ptr()->set("labels", currentLabels); + ptr()->setHistograms(currentHistograms); + ptr()->setLabels(currentLabels); /* //Most cumbersome and inefficient way through a file storage which we were forced to use if we used standard OpenCV @@ -215,7 +215,7 @@ void LBPHFaceModel::update(const std::vector& images, const std::vector // Update local information // We assume new labels are simply appended - cv::Mat currentLabels = ptr()->get("labels"); + cv::Mat currentLabels = ptr()->getLabels(); for (int i = m_histogramMetadata.size() ; i < currentLabels.rows ; i++) {