FaceRecognition.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package VisionX::ArmarXObjects::FaceRecognition
17 * @author Markus Grotz ( markus dot grotz at kit dot edu )
18 * @date 2016
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include <opencv2/core/core.hpp>
26
28//#include <opencv2/contrib/contrib.hpp>
29#include <opencv2/face.hpp>
30#include <opencv2/highgui/highgui.hpp>
31#include <opencv2/imgproc/imgproc.hpp>
32#include <opencv2/objdetect/objdetect.hpp>
33
34#include <Image/StereoMatcher.h>
35
36namespace armarx
37{
38 /**
39 * @class FaceRecognitionPropertyDefinitions
40 * @brief
41 */
44 {
45 public:
48 {
50 "scaleFactor", 1.02, "scale factor for the HAAR classifier");
52 "minNeighbors", 2, "number of neighbors for the HAAR classifier");
53 defineOptionalProperty<std::string>("trainingDataPath",
54 "VisionX/examples/faces",
55 "folder containing the training images");
57 "classifierFileName",
58 "VisionX/examples/haarcascades/haarcascade_frontalface_alt.xml",
59 "path to the HAAR classifier");
60 }
61 };
62
63 /**
64 * @defgroup Component-FaceRecognition FaceRecognition
65 * @ingroup VisionX-Components
66 * A description of the component FaceRecognition.
67 *
68 * @class FaceRecognition
69 * @ingroup Component-FaceRecognition
70 * @brief Brief description of class FaceRecognition.
71 *
72 * Detailed description of class FaceRecognition.
73 */
75 {
76 public:
77 /**
78 * @see armarx::ManagedIceObject::getDefaultName()
79 */
80 std::string
81 getDefaultName() const override
82 {
83 return "FaceRecognition";
84 }
85
86 protected:
87 /**
88 * @see ObjectLocalizerProcessor::onInitObjectLocalizerProcessor()
89 */
90 void onInitObjectLocalizerProcessor() override;
91
92 /**
93 * @see ObjectLocalizerProcessor::onConnectObjectLocalizerProcessor()
94 */
96
97 /**
98 * @see ObjectLocalizerProcessor::onExitObjectLocalizerProcessor()
99 */
100 void onExitObjectLocalizerProcessor() override;
101
102 /**
103 * Add a memory entity representing the hand marker in order to set its properties
104 *
105 * @param objectClassEntity entity containing all information available for the object class
106 * @param fileManager GridFileManager required to read files associated to prior knowledge from the database.
107 *
108 * @return success of adding this entity
109 */
110 memoryx::ObjectLocalizationResultList
111 localizeObjectClasses(const std::vector<std::string>& objectClassNames,
112 CByteImage** cameraImages,
113 armarx::MetaInfoSizeBasePtr imageMetaInfo,
114 CByteImage** resultImages) override;
115
116 /**
117 * Initializes segmentable recognition
118 *
119 * @return success
120 */
121 bool initRecognizer() override;
122
123 /**
124 * Add a memory entity representing the hand marker in order to set its properties
125 *
126 * @param objectClassEntity entity containing all information available for the object class
127 * @param fileManager GridFileManager required to read files associated to prior knowledge from the database.
128 *
129 * @return success of adding this entity
130 */
131 bool addObjectClass(const memoryx::EntityPtr& objectClassEntity,
132 const memoryx::GridFileManagerPtr& fileManager) override;
133
134 /**
135 * @see PropertyUser::createPropertyDefinitions()
136 */
138
139 private:
140 cv::Ptr<cv::face::FaceRecognizer> model;
141
142 cv::CascadeClassifier classifier;
143
144 std::map<int, std::string> labels;
145
146 double scaleFactor;
147 int minNeighbors;
148
149 cv::Size faceImageSize;
150
151 CStereoMatcher* stereoMatcher;
152 };
153} // namespace armarx
Brief description of class FaceRecognition.
bool initRecognizer() override
Initializes segmentable recognition.
void onExitObjectLocalizerProcessor() override
void onInitObjectLocalizerProcessor() override
memoryx::ObjectLocalizationResultList localizeObjectClasses(const std::vector< std::string > &objectClassNames, CByteImage **cameraImages, armarx::MetaInfoSizeBasePtr imageMetaInfo, CByteImage **resultImages) override
Add a memory entity representing the hand marker in order to set its properties.
void onConnectObjectLocalizerProcessor() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
std::string getDefaultName() const override
bool addObjectClass(const memoryx::EntityPtr &objectClassEntity, const memoryx::GridFileManagerPtr &fileManager) override
Add a memory entity representing the hand marker in order to set its properties.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
armarx::MetaInfoSizeBasePtr imageMetaInfo
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< Entity > EntityPtr
Typedef of EntityPtr as IceInternal::Handle<Entity> for convenience.
Definition Entity.h:45
std::shared_ptr< GridFileManager > GridFileManagerPtr
ArmarX headers.