Skip to content

Commit dd4a87d

Browse files
author
moshiwoxin
committed
first commit
0 parents  commit dd4a87d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+11267
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# PeopleDetection-and-Facedetection-in-ROS

fdetection/CMakeLists.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(fdetection)
3+
4+
# Build options
5+
option(USE_OPENMP "Set to ON to build use openmp" ON)
6+
option(USE_SSE "Set to ON to build use SSE" ON)
7+
8+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
9+
if(WIN32 AND NOT CYGWIN)
10+
set(HOME $ENV{PROFILE})
11+
else()
12+
set(HOME $ENV{HOME})
13+
endif()
14+
15+
# Use SSE
16+
if (USE_SSE)
17+
add_definitions(-DUSE_SSE)
18+
message(STATUS "Use SSE")
19+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
20+
endif()
21+
22+
# Use OpenMP
23+
if (USE_OPENMP)
24+
find_package(OpenMP QUIET)
25+
if (OPENMP_FOUND)
26+
message(STATUS "Use OpenMP")
27+
add_definitions(-DUSE_OPENMP)
28+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
29+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
30+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
31+
endif()
32+
endif()
33+
34+
find_package(catkin REQUIRED COMPONENTS
35+
roscpp
36+
rospy
37+
std_msgs
38+
sensor_msgs
39+
cv_bridge
40+
image_transport
41+
)
42+
43+
set(OpenCV_DIR /opt/ros/kinetic/include)
44+
find_package(OpenCV REQUIRED)
45+
message("PB->OPENCV = ${OpenCV_INCLUDE_DIRS}")
46+
47+
catkin_package(CATKIN_DEPENDS
48+
roscpp
49+
std_msgs
50+
sensor_msgs
51+
)
52+
53+
include_directories(
54+
include
55+
${OpenCV_INCLUDE_DIRS}
56+
${catkin_INCLUDE_DIRS}
57+
)
58+
59+
60+
### find files
61+
62+
file(GLOB_RECURSE HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h*)
63+
file(GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c*)
64+
65+
add_executable(fdetect
66+
${HEADER_FILES}
67+
${SOURCE_FILES}
68+
)
69+
70+
71+
target_link_libraries(fdetect
72+
${catkin_LIBRARIES}
73+
${OpenCV_LIBRARIES}
74+
)
75+

fdetection/gakki.jpg

65.1 KB
Loading

fdetection/include/classifier.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
*
3+
* This file is part of the open-source SeetaFace engine, which includes three modules:
4+
* SeetaFace Detection, SeetaFace Alignment, and SeetaFace Identification.
5+
*
6+
* This file is part of the SeetaFace Detection module, containing codes implementing the
7+
* face detection method described in the following paper:
8+
*
9+
*
10+
* Funnel-structured cascade for multi-view face detection with alignment awareness,
11+
* Shuzhe Wu, Meina Kan, Zhenliang He, Shiguang Shan, Xilin Chen.
12+
* In Neurocomputing (under review)
13+
*
14+
*
15+
* Copyright (C) 2016, Visual Information Processing and Learning (VIPL) group,
16+
* Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China.
17+
*
18+
* The codes are mainly developed by Shuzhe Wu (a Ph.D supervised by Prof. Shiguang Shan)
19+
*
20+
* As an open-source face recognition engine: you can redistribute SeetaFace source codes
21+
* and/or modify it under the terms of the BSD 2-Clause License.
22+
*
23+
* You should have received a copy of the BSD 2-Clause License along with the software.
24+
* If not, see < https://opensource.org/licenses/BSD-2-Clause>.
25+
*
26+
* Contact Info: you can send an email to [email protected] for any problems.
27+
*
28+
* Note: the above information must be kept whenever or wherever the codes are used.
29+
*
30+
*/
31+
32+
#ifndef SEETA_FD_CLASSIFIER_H_
33+
#define SEETA_FD_CLASSIFIER_H_
34+
35+
#include "common.h"
36+
#include "feature_map.h"
37+
38+
namespace seeta {
39+
namespace fd {
40+
41+
enum ClassifierType {
42+
LAB_Boosted_Classifier,
43+
SURF_MLP
44+
};
45+
46+
class Classifier {
47+
public:
48+
Classifier() {}
49+
virtual ~Classifier() {}
50+
51+
virtual void SetFeatureMap(seeta::fd::FeatureMap* feat_map) = 0;
52+
virtual bool Classify(float* score = nullptr, float* outputs = nullptr) = 0;
53+
54+
virtual seeta::fd::ClassifierType type() = 0;
55+
56+
DISABLE_COPY_AND_ASSIGN(Classifier);
57+
};
58+
59+
} // namespace fd
60+
} // namespace seeta
61+
62+
#endif // SEETA_FD_CLASSIFIER_H_
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
*
3+
* This file is part of the open-source SeetaFace engine, which includes three modules:
4+
* SeetaFace Detection, SeetaFace Alignment, and SeetaFace Identification.
5+
*
6+
* This file is part of the SeetaFace Detection module, containing codes implementing the
7+
* face detection method described in the following paper:
8+
*
9+
*
10+
* Funnel-structured cascade for multi-view face detection with alignment awareness,
11+
* Shuzhe Wu, Meina Kan, Zhenliang He, Shiguang Shan, Xilin Chen.
12+
* In Neurocomputing (under review)
13+
*
14+
*
15+
* Copyright (C) 2016, Visual Information Processing and Learning (VIPL) group,
16+
* Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China.
17+
*
18+
* The codes are mainly developed by Shuzhe Wu (a Ph.D supervised by Prof. Shiguang Shan)
19+
*
20+
* As an open-source face recognition engine: you can redistribute SeetaFace source codes
21+
* and/or modify it under the terms of the BSD 2-Clause License.
22+
*
23+
* You should have received a copy of the BSD 2-Clause License along with the software.
24+
* If not, see < https://opensource.org/licenses/BSD-2-Clause>.
25+
*
26+
* Contact Info: you can send an email to [email protected] for any problems.
27+
*
28+
* Note: the above information must be kept whenever or wherever the codes are used.
29+
*
30+
*/
31+
32+
#ifndef SEETA_FD_CLASSIFIER_LAB_BOOSTED_CLASSIFIER_H_
33+
#define SEETA_FD_CLASSIFIER_LAB_BOOSTED_CLASSIFIER_H_
34+
35+
#include <algorithm>
36+
#include <cstdint>
37+
#include <memory>
38+
#include <vector>
39+
40+
#include "classifier.h"
41+
#include "feat/lab_feature_map.h"
42+
43+
namespace seeta {
44+
namespace fd {
45+
46+
/**
47+
* @class LABBaseClassifier
48+
* @brief Base classifier using LAB feature.
49+
*/
50+
class LABBaseClassifier {
51+
public:
52+
LABBaseClassifier()
53+
: num_bin_(255), thresh_(0.0f) {
54+
weights_.resize(num_bin_ + 1);
55+
}
56+
57+
~LABBaseClassifier() {}
58+
59+
void SetWeights(const float* weights, int32_t num_bin);
60+
61+
inline void SetThreshold(float thresh) { thresh_ = thresh; }
62+
63+
inline int32_t num_bin() const { return num_bin_; }
64+
inline float weights(int32_t val) const { return weights_[val]; }
65+
inline float threshold() const { return thresh_; }
66+
67+
private:
68+
int32_t num_bin_;
69+
70+
std::vector<float> weights_;
71+
float thresh_;
72+
};
73+
74+
/**
75+
* @class LABBoostedClassifier
76+
* @Brief A strong classifier constructed from base classifiers using LAB features.
77+
*/
78+
class LABBoostedClassifier : public Classifier {
79+
public:
80+
LABBoostedClassifier() : use_std_dev_(true) {}
81+
virtual ~LABBoostedClassifier() {}
82+
83+
virtual bool Classify(float* score = nullptr, float* outputs = nullptr);
84+
85+
inline virtual seeta::fd::ClassifierType type() {
86+
return seeta::fd::ClassifierType::LAB_Boosted_Classifier;
87+
}
88+
89+
void AddFeature(int32_t x, int32_t y);
90+
void AddBaseClassifier(const float* weights, int32_t num_bin, float thresh);
91+
92+
inline virtual void SetFeatureMap(seeta::fd::FeatureMap* featMap) {
93+
feat_map_ = dynamic_cast<seeta::fd::LABFeatureMap*>(featMap);
94+
}
95+
96+
inline void SetUseStdDev(bool useStdDev) { use_std_dev_ = useStdDev; }
97+
98+
private:
99+
static const int32_t kFeatGroupSize = 10;
100+
const float kStdDevThresh = 10.0f;
101+
102+
std::vector<seeta::fd::LABFeature> feat_;
103+
std::vector<std::shared_ptr<seeta::fd::LABBaseClassifier> > base_classifiers_;
104+
seeta::fd::LABFeatureMap* feat_map_;
105+
bool use_std_dev_;
106+
};
107+
108+
} // namespace fd
109+
} // namespace seeta
110+
111+
#endif // SEETA_FD_CLASSIFIER_LAB_BOOSTED_CLASSIFIER_H_

fdetection/include/classifier/mlp.h

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
*
3+
* This file is part of the open-source SeetaFace engine, which includes three modules:
4+
* SeetaFace Detection, SeetaFace Alignment, and SeetaFace Identification.
5+
*
6+
* This file is part of the SeetaFace Detection module, containing codes implementing the
7+
* face detection method described in the following paper:
8+
*
9+
*
10+
* Funnel-structured cascade for multi-view face detection with alignment awareness,
11+
* Shuzhe Wu, Meina Kan, Zhenliang He, Shiguang Shan, Xilin Chen.
12+
* In Neurocomputing (under review)
13+
*
14+
*
15+
* Copyright (C) 2016, Visual Information Processing and Learning (VIPL) group,
16+
* Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China.
17+
*
18+
* The codes are mainly developed by Shuzhe Wu (a Ph.D supervised by Prof. Shiguang Shan)
19+
*
20+
* As an open-source face recognition engine: you can redistribute SeetaFace source codes
21+
* and/or modify it under the terms of the BSD 2-Clause License.
22+
*
23+
* You should have received a copy of the BSD 2-Clause License along with the software.
24+
* If not, see < https://opensource.org/licenses/BSD-2-Clause>.
25+
*
26+
* Contact Info: you can send an email to [email protected] for any problems.
27+
*
28+
* Note: the above information must be kept whenever or wherever the codes are used.
29+
*
30+
*/
31+
32+
#ifndef SEETA_FD_CLASSIFIER_MLP_H_
33+
#define SEETA_FD_CLASSIFIER_MLP_H_
34+
35+
#include <cmath>
36+
#include <cstdint>
37+
#include <memory>
38+
#include <algorithm>
39+
#include <vector>
40+
41+
#include "util/math_func.h"
42+
43+
namespace seeta {
44+
namespace fd {
45+
46+
class MLPLayer {
47+
public:
48+
explicit MLPLayer(int32_t act_func_type = 1)
49+
: input_dim_(0), output_dim_(0), act_func_type_(act_func_type) {}
50+
~MLPLayer() {}
51+
52+
void Compute(const float* input, float* output);
53+
54+
inline int32_t GetInputDim() const { return input_dim_; }
55+
inline int32_t GetOutputDim() const { return output_dim_; }
56+
57+
inline void SetSize(int32_t inputDim, int32_t outputDim) {
58+
if (inputDim <= 0 || outputDim <= 0) {
59+
return; // @todo handle the errors!!!
60+
}
61+
input_dim_ = inputDim;
62+
output_dim_ = outputDim;
63+
weights_.resize(inputDim * outputDim);
64+
bias_.resize(outputDim);
65+
}
66+
67+
inline void SetWeights(const float* weights, int32_t len) {
68+
if (weights == nullptr || len != input_dim_ * output_dim_) {
69+
return; // @todo handle the errors!!!
70+
}
71+
std::copy(weights, weights + input_dim_ * output_dim_, weights_.begin());
72+
}
73+
74+
inline void SetBias(const float* bias, int32_t len) {
75+
if (bias == nullptr || len != output_dim_) {
76+
return; // @todo handle the errors!!!
77+
}
78+
std::copy(bias, bias + output_dim_, bias_.begin());
79+
}
80+
81+
private:
82+
inline float Sigmoid(float x) {
83+
return 1.0f / (1.0f + std::exp(x));
84+
}
85+
86+
inline float ReLU(float x) {
87+
return (x > 0.0f ? x : 0.0f);
88+
}
89+
90+
private:
91+
int32_t act_func_type_;
92+
int32_t input_dim_;
93+
int32_t output_dim_;
94+
std::vector<float> weights_;
95+
std::vector<float> bias_;
96+
};
97+
98+
99+
class MLP {
100+
public:
101+
MLP() {}
102+
~MLP() {}
103+
104+
void Compute(const float* input, float* output);
105+
106+
inline int32_t GetInputDim() const {
107+
return layers_[0]->GetInputDim();
108+
}
109+
110+
inline int32_t GetOutputDim() const {
111+
return layers_.back()->GetOutputDim();
112+
}
113+
114+
inline int32_t GetLayerNum() const {
115+
return static_cast<int32_t>(layers_.size());
116+
}
117+
118+
void AddLayer(int32_t inputDim, int32_t outputDim, const float* weights,
119+
const float* bias, bool is_output = false);
120+
121+
private:
122+
std::vector<std::shared_ptr<seeta::fd::MLPLayer> > layers_;
123+
std::vector<float> layer_buf_[2];
124+
};
125+
126+
} // namespace fd
127+
} // namespace seeta
128+
129+
#endif // SEETA_FD_CLASSIFIER_MLP_H_

0 commit comments

Comments
 (0)