Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the repo compile under ROS Lunar (OpenCV 3.2.0) #72

Merged
merged 9 commits into from
Jun 21, 2017
1 change: 1 addition & 0 deletions cob_leg_detection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ include_directories(
${OpenCV_INCLUDE_DIRS}
${orocos_kdl_INCLUDE_DIRS}
${BFL_INCLUDE_DIRS}
${BFL_INCLUDE_DIRS}/bfl
${EIGEN_INCLUDE_DIRS}
)

Expand Down
3 changes: 1 addition & 2 deletions cob_leg_detection/src/calc_leg_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

#include <cob_leg_detection/calc_leg_features.h>

#include "opencv/cxcore.h"
#include "opencv/cv.h"
#include <opencv2/opencv.hpp>

using namespace laser_processor;
using namespace std;
Expand Down
39 changes: 36 additions & 3 deletions cob_leg_detection/src/leg_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@
#include <cob_leg_detection/laser_processor.h>
#include <cob_leg_detection/calc_leg_features.h>

#include <opencv/cxcore.h>
#include <opencv/cv.h>
#include <opencv/ml.h>
#include <opencv2/opencv.hpp>

#include <cob_perception_msgs/PositionMeasurement.h>
#include <cob_perception_msgs/PositionMeasurementArray.h>
Expand Down Expand Up @@ -452,7 +450,12 @@ class LegDetector
//TransformListener tflp_;
ScanMask mask_;
int mask_count_;
#if CV_MAJOR_VERSION == 2
CvRTrees forest;
#else
// OpenCV 3
cv::Ptr<cv::ml::RTrees> forest;
#endif
float connected_thresh_;
int feat_count_;
char save_[100];
Expand Down Expand Up @@ -492,8 +495,16 @@ class LegDetector
{

if (g_argc > 1) {
#if CV_MAJOR_VERSION == 2
forest.load(g_argv[1]);
feat_count_ = forest.get_active_var_mask()->cols;
#else
// OpenCV 3
forest = cv::ml::RTrees::create();
cv::String feature_file = cv::String(g_argv[1]);
forest = cv::ml::StatModel::load<cv::ml::RTrees>(feature_file);
feat_count_ = forest->getVarCount();
#endif
printf("Loaded forest with %d features: %s\n", feat_count_, g_argv[1]);
} else {
printf("Please provide a trained random forests classifier as an input.\n");
Expand Down Expand Up @@ -708,7 +719,12 @@ class LegDetector
ScanProcessor processor(*scan, mask_);
processor.splitConnected(connected_thresh_);
processor.removeLessThan(5);
#if CV_MAJOR_VERSION == 2
CvMat* tmp_mat = cvCreateMat(1,feat_count_,CV_32FC1);
#else
// OpenCV 3
cv::Mat tmp_mat = cv::Mat(1, feat_count_, CV_32FC1);
#endif

// if no measurement matches to a tracker in the last <no_observation_timeout> seconds: erase tracker
ros::Time purge = scan->header.stamp + ros::Duration().fromSec(-no_observation_timeout_s);
Expand Down Expand Up @@ -742,9 +758,24 @@ class LegDetector
vector<float> f = calcLegFeatures(*i, *scan);

for (int k = 0; k < feat_count_; k++)
#if CV_MAJOR_VERSION == 2
tmp_mat->data.fl[k] = (float)(f[k]);
#else
// OpenCV 3
tmp_mat.data[k] = (float)(f[k]);
#endif

#if CV_MAJOR_VERSION == 2
float probability = forest.predict_prob( tmp_mat );
#else
// OpenCV 3
// Probability is the fuzzy measure of the probability that the second element should be chosen,
// in opencv2 RTrees had a method predict_prob, but that disapeared in opencv3, this is the
// substitute.
float probability = 0.5 -
forest->predict(tmp_mat, cv::noArray(), cv::ml::RTrees::PREDICT_SUM) /
forest->getRoots().size();
#endif
Stamped<Point> loc((*i)->center(), scan->header.stamp, scan->header.frame_id);
try {
tfl_.transformPoint(fixed_frame, loc, loc);
Expand Down Expand Up @@ -832,7 +863,9 @@ class LegDetector
}
}

#if CV_MAJOR_VERSION == 2
cvReleaseMat(&tmp_mat); tmp_mat = 0;
#endif
// if(!use_seeds_)
pairLegs();

Expand Down
4 changes: 1 addition & 3 deletions cob_leg_detection/src/train_leg_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
#include "cob_leg_detection/laser_processor.h"
#include "cob_leg_detection/calc_leg_features.h"

#include "opencv/cxcore.h"
#include "opencv/cv.h"
#include "opencv/ml.h"
#include <opencv2/opencv.hpp>

#include "cob_perception_msgs/PositionMeasurement.h"
#include "sensor_msgs/LaserScan.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

//#include <opencv/cv.h>
//#include <opencv/highgui.h>
#include <cv_bridge/cv_bridge.h>
//boost
#include <boost/thread/mutex.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#endif

// opencv
#include <opencv/cv.h>
#include <opencv2/opencv.hpp>

namespace ipa_PeopleDetector
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
#include "cob_vision/cob_sensor_fusion/common/include/cob_sensor_fusion/ColoredPointCloud.h" // todo: necessary?
#endif

#include <opencv/ml.h>
#include <opencv/cv.h>
#include <opencv2/opencv.hpp>

namespace ipa_PeopleDetector
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include <opencv/cv.h>
#include <opencv/cvaux.h>
#include <opencv/highgui.h>
#include <opencv/ml.h>
#include <opencv2/opencv.hpp>

#include <iostream>
#include <boost/lexical_cast.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
#endif

// opencv
#include <opencv/cv.h>
#include <opencv/ml.h>
#include <opencv2/opencv.hpp>

// boost
#include <boost/thread/mutex.hpp>
Expand Down Expand Up @@ -226,7 +225,12 @@ class FaceRecognizer: public AbstractFaceRecognizer
std::vector<std::string> m_face_labels; ///< A vector containing the corresponding labels to each face image projection in m_projected_training_faces (m_face_labels[i] stores the corresponding name to the face representation in the face subspace in m_projected_training_faces.rows(i))
cv::Mat m_face_class_average_projections; ///< The average factors of the eigenvector decomposition from each face class; The average factors from each face class originating from the eigenvector decomposition.
std::vector<std::string> m_current_label_set; ///< A vector containing all different labels from the training session exactly once, order of appearance matters! (m_current_label_set[i] stores the corresponding name to the average face coordinates in the face subspace in m_face_class_average_projections.rows(i))
#if CV_MAJOR_VERSION == 2
cv::SVM m_face_classifier; ///< classifier for the identity of a person
#else
// OpenCV 3
cv::Ptr<cv::ml::SVM> m_face_classifier; ///< classifier for the identity of a person
#endif
boost::filesystem::path m_data_directory; ///< folder that contains the training data

// mutex
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#include<opencv/cv.h>
#include<iostream>
#include<opencv/highgui.h>
#include<opencv/ml.h>
#include<fstream>
#include<ostream>
#include<limits>

#include<cob_people_detection/subspace_analysis.h>

#include<boost/filesystem.hpp>
#include<boost/lexical_cast.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <ostream>
#include <limits>

#include <cob_people_detection/subspace_analysis.h>

#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>

namespace ipa_PeopleDetector
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
#include "cob_vision/cob_vision_ipa_utils/common/include/cob_vision_ipa_utils/MathUtils.h"
#include "cob_vision/cob_sensor_fusion/common/include/cob_sensor_fusion/ColoredPointCloud.h" // todo: necessary?
#endif
#include <opencv/ml.h>
#include <opencv/cv.h>
#include <opencv2/opencv.hpp>

namespace ipa_PeopleDetector
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#endif
#include <fstream>
#include <set>
#include <opencv/ml.h>
#include <opencv/cv.h>
#include <opencv2/opencv.hpp>

namespace ipa_PeopleDetector {

Expand Down Expand Up @@ -109,8 +108,14 @@ class PeopleDetector
/// @param eigenValMat Eigenvalues
/// @param personClassifier A classifier for person identification. It is trained in this function. Can be left out if a simpler identification method is used.
/// @return Return code
#if CV_MAJOR_VERSION == 2
virtual unsigned long RecognizeFace(cv::Mat& colorImage, std::vector<cv::Rect>& colorFaces, int* nEigens, std::vector<cv::Mat>& eigenVectArr, cv::Mat& avgImage, cv::Mat& projectedTrainFaceMat,
std::vector<int>& index, int *threshold, int *threshold_FS, cv::Mat& eigenValMat, cv::SVM* personClassifier = 0);
#else
// OpenCV 3
virtual unsigned long RecognizeFace(cv::Mat& colorImage, std::vector<cv::Rect>& colorFaces, int* nEigens, std::vector<cv::Mat>& eigenVectArr, cv::Mat& avgImage, cv::Mat& projectedTrainFaceMat,
std::vector<int>& index, int *threshold, int *threshold_FS, cv::Mat& eigenValMat, cv::ml::SVM* personClassifier = 0);
#endif

/// Function to find the closest face class
/// The function calculates the distance of each sample image to the trained face class
Expand All @@ -122,7 +127,12 @@ class PeopleDetector
/// @param eigenValMat Eigenvalues
/// @param personClassifier A classifier for person identification. It is trained in this function. Can be left out if a simpler identification method is used.
/// @return Return code
#if CV_MAJOR_VERSION == 2
virtual unsigned long ClassifyFace(float *projectedTestFace, int *nearest, int *nEigens, cv::Mat& projectedTrainFaceMat, int *threshold, cv::Mat& eigenValMat, cv::SVM* personClassifier = 0);
#else
// OpenCV 3
virtual unsigned long ClassifyFace(float *projectedTestFace, int *nearest, int *nEigens, cv::Mat& projectedTrainFaceMat, int *threshold, cv::Mat& eigenValMat, cv::ml::SVM* personClassifier = 0);
#endif

/// Function to calculate the FaceClasses
/// The function calculates the average eigenvector decomposition factors for each face classes.
Expand All @@ -133,7 +143,12 @@ class PeopleDetector
/// @param idUnique A vector containing all different Ids from the training session exactly once (idUnique[i] stores the corresponding id to the average face coordinates in the face subspace in faceClassAvgProjections.row(i))
/// @param personClassifier A classifier for person identification. It is trained in this function. Can be left out if a simpler identification method is used.
/// @return Return code
#if CV_MAJOR_VERSION == 2
virtual unsigned long CalculateFaceClasses(cv::Mat& projectedTrainFaceMat, std::vector<std::string>& id, int *nEigens, cv::Mat& faceClassAvgProjections, std::vector<std::string>& idUnique, cv::SVM* personClassifier = 0);
#else
// OpenCV 3
virtual unsigned long CalculateFaceClasses(cv::Mat& projectedTrainFaceMat, std::vector<std::string>& id, int *nEigens, cv::Mat& faceClassAvgProjections, std::vector<std::string>& idUnique, cv::ml::SVM* personClassifier = 0);
#endif

double m_faces_increase_search_scale; ///< The factor by which the search window is scaled between the subsequent scans
int m_faces_drop_groups; ///< Minimum number (minus 1) of neighbor rectangles that makes up an object.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#ifndef SSA_H_
#define SSA_H_

#include<opencv/cv.h>
#include<iostream>
#include<opencv/highgui.h>
#include<opencv/ml.h>
#include<fstream>
#include<ostream>
#include<limits>

#include<math.h>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <ostream>
#include <limits>
#include <math.h>

namespace SubspaceAnalysis
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#ifndef SSA_H_
#define SSA_H_

#include<iostream>
#include<opencv/cv.h>
#include<opencv/highgui.h>
#include<opencv/ml.h>
#include<fstream>
#include<ostream>
#include<limits>

#include<math.h>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <ostream>
#include <limits>
#include <math.h>

// Base class for SubSpace Analysis(SSA)
//
//
Expand Down
3 changes: 1 addition & 2 deletions cob_people_detection/common/src/abstract_face_recognizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
#include <fstream>

// opencv
#include <opencv/cv.h>
#include <opencv/cvaux.h>
#include <opencv2/opencv.hpp>

using namespace ipa_PeopleDetector;

Expand Down
8 changes: 4 additions & 4 deletions cob_people_detection/common/src/face_align_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include"cob_people_detection/face_normalizer.h"
#include<iostream>
#include<opencv/cv.h>
#include<opencv/highgui.h>
#include "cob_people_detection/face_normalizer.h"
#include <iostream>
#include <opencv2/opencv.hpp>

int main(int argc, const char *argv[])
{

Expand Down
4 changes: 1 addition & 3 deletions cob_people_detection/common/src/face_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@
#include "cob_common/cob_vision_utils/common/include/cob_vision_utils/GlobalDefines.h"
#endif

#include <opencv/cv.h>
#include <opencv/cvaux.h>
#include <opencv/highgui.h>
#include <opencv2/opencv.hpp>

using namespace ipa_PeopleDetector;

Expand Down
8 changes: 4 additions & 4 deletions cob_people_detection/common/src/face_normalizer_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include"cob_people_detection/face_normalizer.h"
#include<iostream>
#include<opencv/cv.h>
#include<opencv/highgui.h>
#include "cob_people_detection/face_normalizer.h"
#include <iostream>
#include <opencv2/opencv.hpp>

int main(int argc, const char *argv[])
{

Expand Down
Loading