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

Fix for the leg_detector opencv3 bug #48

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ env:
- CATKIN_WS=~/catkin_ws
- CATKIN_WS_SRC=${CATKIN_WS}/src
matrix:
- CI_ROS_DISTRO="indigo"
- CI_ROS_DISTRO="kinetic"
# - CI_ROS_DISTRO="jade"
install:
- sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
- sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list'
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
- sudo apt-get update -qq
- sudo apt-get install -qq -y python-rosdep python-catkin-tools
Expand Down
6 changes: 3 additions & 3 deletions leg_detector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ catkin_package(INCLUDE_DIRS include
CATKIN_DEPENDS people_msgs sensor_msgs std_msgs geometry_msgs visualization_msgs)

## Declare a cpp executable
add_executable(leg_detector
add_executable(leg_detector
src/laser_processor.cpp
src/leg_detector.cpp
src/leg_detector.cpp
src/calc_leg_features.cpp)

## Add cmake target dependencies of the executable/library
add_dependencies(leg_detector people_msgs_gencpp ${${PROJECT_NAME}_EXPORTED_TARGETS})
add_dependencies(leg_detector ${${PROJECT_NAME}_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
target_link_libraries(leg_detector
Expand Down
File renamed without changes.
24 changes: 15 additions & 9 deletions leg_detector/src/leg_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ class LegDetector

int mask_count_;

cv::ml::RTrees forest;
// cv::ml::RTrees forest;
cv::Ptr<cv::ml::RTrees> forest;

float connected_thresh_;

Expand Down Expand Up @@ -286,8 +287,10 @@ class LegDetector
{
if (g_argc > 1)
{
forest.load(g_argv[1]);
feat_count_ = forest.get_active_var_mask()->cols;
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();
printf("Loaded forest with %d features: %s\n", feat_count_, g_argv[1]);
}
else
Expand Down Expand Up @@ -684,7 +687,7 @@ class LegDetector
processor.splitConnected(connected_thresh_);
processor.removeLessThan(5);

CvMat* tmp_mat = cvCreateMat(1, feat_count_, CV_32FC1);
cv::Mat tmp_mat = cv::Mat(1, feat_count_, CV_32FC1);

// 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 @@ -725,9 +728,14 @@ class LegDetector
vector<float> f = calcLegFeatures(*i, *scan);

for (int k = 0; k < feat_count_; k++)
tmp_mat->data.fl[k] = (float)(f[k]);

float probability = forest.predict_prob(tmp_mat);
tmp_mat.data[k] = (float)(f[k]);

// 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();
Stamped<Point> loc((*i)->center(), scan->header.stamp, scan->header.frame_id);
try
{
Expand Down Expand Up @@ -841,8 +849,6 @@ class LegDetector
}
}

cvReleaseMat(&tmp_mat);
tmp_mat = 0;
if (!use_seeds_)
pairLegs();

Expand Down
16 changes: 8 additions & 8 deletions people_tracking_filter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ include_directories(
)

## Declare a cpp library
add_library(people_tracking_filter
src/uniform_vector.cpp
src/gaussian_vector.cpp
src/gaussian_pos_vel.cpp
add_library(people_tracking_filter
src/uniform_vector.cpp
src/gaussian_vector.cpp
src/gaussian_pos_vel.cpp
src/mcpdf_pos_vel.cpp
src/mcpdf_vector.cpp
src/sysmodel_pos_vel.cpp
src/sysmodel_vector.cpp
src/measmodel_pos.cpp
src/measmodel_vector.cpp
src/tracker_particle.cpp
src/tracker_kalman.cpp
src/detector_particle.cpp
src/tracker_particle.cpp
src/tracker_kalman.cpp
src/detector_particle.cpp
)

## Declare a cpp executable
add_executable(people_tracker src/people_tracking_node.cpp)

## Add cmake target dependencies of the executable/library
add_dependencies(people_tracker people_msgs_gencpp people_tracking_filter)
add_dependencies(people_tracker people_tracking_filter)

## Specify libraries to link a library or executable target against
target_link_libraries(people_tracker
Expand Down