Skip to content

Commit

Permalink
update so it can be built on kinetic
Browse files Browse the repository at this point in the history
  • Loading branch information
koide3 committed Feb 26, 2018
1 parent 5a8a29c commit 00365f0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/hdl_people_detection/background_subtractor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class BackgroundSubtractor {
marker->colors.reserve(8192);
marker->points.reserve(8192);

for (Eigen::SparseVector<bool>::InnerIterator itr(occupancy_map); itr; ++itr) {
for (Eigen::SparseVector<int>::InnerIterator itr(occupancy_map); itr; ++itr) {
if (itr.value() < occupancy_thresh) {
continue;
}
Expand Down
8 changes: 7 additions & 1 deletion include/hdl_people_detection/kidono_human_classifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ class KidonoHumanClassifier {
bool predict(const pcl::PointCloud<pcl::PointXYZI>::ConstPtr& cloud) const;

private:
cv::Boost boost;
#if CV_VERSION_EPOCH == 2
using CvBoost = cv::Boost;
#else
using CvBoost = cv::ml::Boost;
#endif

cv::Ptr<CvBoost> boost;
kkl::ml::SvmScale scale;
};

Expand Down
1 change: 0 additions & 1 deletion include/hdl_people_tracking/people_tracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <Eigen/Dense>
#include <boost/optional.hpp>
#include <opencv2/opencv.hpp>
#include <grace_msgs/Detection.h>

#include <kkl/alg/data_association.hpp>
#include <kkl/alg/nearest_neighbor_association.hpp>
Expand Down
26 changes: 19 additions & 7 deletions src/kidono_human_classifier.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <hdl_people_detection/kidono_human_classifier.h>

#include <ros/ros.h>
#include <hdl_people_detection/kidono_feature_extractor.hpp>


Expand All @@ -8,25 +9,36 @@ namespace hdl_people_detection {
KidonoHumanClassifier::KidonoHumanClassifier(const std::string &modelfile, const std::string &scalefile)
: scale(scalefile, 213)
{
boost.load(modelfile.c_str());
if(!boost.get_data()) {
std::cerr << "warning : failed to load boosting model!!" << std::endl;
std::cerr << " : boosting is disabled!!" << std::endl;
}
#if CV_VERSION_EPOCH == 2
boost = cv::Ptr<cv::Boost>(new cv::Boost());
boost->load(modelfile.c_str());
if(!boost->get_data()) {
ROS_ERROR("failed to read boost model!!");
ROS_ERROR("boost disabled");
boost.release();
}
#else
boost = cv::ml::Boost::load(modelfile);
if(boost->empty()) {
ROS_ERROR("failed to read boost model!!");
ROS_ERROR("boost disabled");
boost.release();
}
#endif
}

KidonoHumanClassifier::~KidonoHumanClassifier() {}

bool KidonoHumanClassifier::predict(const pcl::PointCloud<pcl::PointXYZI>::ConstPtr &cloud) const {
if(!boost.get_data()) {
if(boost.empty()) {
return true;
}

KidonoFeatureExtractor extractor;
auto feature = extractor.extract(cloud);
auto scaled = scale.scaling(feature);

return boost.predict(scaled) > 0.0f;
return boost->predict(scaled) > 0.0f;
}

}

0 comments on commit 00365f0

Please sign in to comment.