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

Update leg_detector to OpenCV3 #53

Merged
merged 11 commits into from
Apr 30, 2018
45 changes: 14 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
sudo: required
dist: trusty
# Force travis to use its minimal image with default Python settings
language: generic
# This config file for Travis CI utilizes ros-industrial/industrial_ci package.
# For more info for the package, see https://github.com/ros-industrial/industrial_ci/blob/master/README.rst
sudo: required
dist: trusty
language: generic
compiler:
- gcc
env:
global:
- CATKIN_WS=~/catkin_ws
- CATKIN_WS_SRC=${CATKIN_WS}/src
matrix:
- CI_ROS_DISTRO="indigo"
# - 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'
- 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
- sudo rosdep init
- rosdep update
# Use rosdep to install all dependencies (including ROS itself)
- rosdep install --from-paths ./ -i -y --rosdistro $CI_ROS_DISTRO
- USE_DEB=true ROS_DISTRO="kinetic" ROS_REPOSITORY_PATH=http://packages.ros.org/ros/ubuntu
- USE_DEB=true ROS_DISTRO="kinetic" ROS_REPOSITORY_PATH=http://packages.ros.org/ros-shadow-fixed/ubuntu
- ROS_DISTRO="kinetic" PRERELEASE=true
matrix:
allow_failures:
- env: ROS_DISTRO="kinetic" PRERELEASE=true
before_script:
- git clone https://github.com/ros-industrial/industrial_ci.git .ci_config
script:
- source /opt/ros/$CI_ROS_DISTRO/setup.bash
- mkdir -p $CATKIN_WS_SRC
- ln -s $TRAVIS_BUILD_DIR $CATKIN_WS_SRC
- cd $CATKIN_WS
- catkin init
# Enable install space
#- catkin config --install
# Build [and Install] packages
- catkin build --limit-status-rate 0.1 --no-notify -DCMAKE_BUILD_TYPE=Release
# Build tests
- catkin build --limit-status-rate 0.1 --no-notify --make-args tests
# Run tests
- catkin run_tests
- .ci_config/travis.sh
16 changes: 8 additions & 8 deletions face_detector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ if(CATKIN_ENABLE_TESTING)
DESTINATION ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/test
MD5 59126117e049e69d577b7ee27251a6f8)

add_rostest(test/wide-stereo_true_rtest.xml)
add_rostest(test/wide-stereo_false_rtest.xml)
# add_rostest(test/wide-stereo_true_rtest.xml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer just deleting these instead of commenting them out, here and below

# add_rostest(test/wide-stereo_false_rtest.xml)
add_rostest(test/rgbd_true_rtest.xml)
add_rostest(test/rgbd_false_rtest.xml)
add_rostest(test/narrow-stereo_true_rtest.xml)
add_rostest(test/narrow-stereo_false_rtest.xml)
add_rostest(test/action-wide_true_rtest.xml)
add_rostest(test/action-wide_false_rtest.xml)
add_rostest(test/action-rgbd_true_rtest.xml)
add_rostest(test/action-rgbd_false_rtest.xml)
# add_rostest(test/narrow-stereo_true_rtest.xml)
# add_rostest(test/narrow-stereo_false_rtest.xml)
# add_rostest(test/action-wide_true_rtest.xml)
# add_rostest(test/action-wide_false_rtest.xml)
# add_rostest(test/action-rgbd_true_rtest.xml)
# add_rostest(test/action-rgbd_false_rtest.xml)

endif()
1 change: 1 addition & 0 deletions face_detector/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<!-- <test_depend>image_geometry</test_depend> -->
<!-- <test_depend>actionlib_msgs</test_depend> -->
<!-- <test_depend>actionlib</test_depend> -->
<test_depend>stereo_image_proc</test_depend>

<!-- <export>
<cpp cflags="-I${prefix}/msg/cpp -I${prefix}/srv/cpp"/>
Expand Down
2 changes: 1 addition & 1 deletion face_detector/param/classifier.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
classifier_filename: /usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml
classifier_filename: /opt/ros/kinetic/share/OpenCV-3.2.0-dev/haarcascades/haarcascade_frontalface_alt.xml
6 changes: 3 additions & 3 deletions face_detector/test/action-rgbd_false_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<launch>
<arg name="expected_success" value="false" />
<arg name="testnode_name" default="hztest_action_rgbd_false" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector_action.rgbd.launch" />

<include file="$(find face_detector)/test/common_rtest.xml">
<arg name="expected_success" value="false" />
</include>
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
3 changes: 2 additions & 1 deletion face_detector/test/action-rgbd_true_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<launch>
<arg name="testnode_name" default="hztest_action_rgbd_true" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector_action.rgbd.launch" />

<include file="$(find face_detector)/test/common_rtest.xml" />
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
6 changes: 3 additions & 3 deletions face_detector/test/action-wide_false_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<launch>
<arg name="expected_success" value="false" />
<arg name="testnode_name" default="hztest_action_wide_false" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector_action.wide.launch"/>

<include file="$(find face_detector)/test/common_rtest.xml">
<arg name="expected_success" value="false" />
</include>
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
4 changes: 3 additions & 1 deletion face_detector/test/action-wide_true_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<launch>
<arg name="expected_success" value="false" />
<arg name="testnode_name" default="hztest_action_wide_true" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector_action.wide.launch"/>

<include file="$(find face_detector)/test/common_rtest.xml" />
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
35 changes: 26 additions & 9 deletions face_detector/test/common_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
<launch>
<arg name="expected_success" default="true" />
<arg name="hz" default="30.0" />
<arg name="hztest_duration" default="2.0" />
<arg name="hz_error" default="29.9" />
<arg name="RETRY_TEST" default="5" />
<arg name="testnode_name" default="hztest1" />
<arg name="topicname_hztest" default="face_detector/people_tracker_measurements_array" />

<param name ="use_sim_time" value="true" />

<group unless="$(arg expected_success)">
<node pkg="rosbag" type="play" name="play" args="-r 0.5 $(find face_detector)/test/face_detector_noface_test_diamondback.bag"/>
<param name="hztest1/hz" value="0.0" />
<node pkg="rosbag" type="play" name="play" args="--clock -l -r 0.5 $(find face_detector)/test/face_detector_noface_test_diamondback.bag"/>

<test test-name="hztest_noface_$(arg testnode_name)" pkg="rostest" type="hztest" name="$(arg testnode_name)" retry="$(arg RETRY_TEST)">
<param name="topic" value="face_detector/people_tracker_measurements_array" />
<param name="hz" value="0.0" />
<param name="test_duration" value="$(arg hztest_duration)" />
</test>
</group>
<group if="$(arg expected_success)">
<node pkg="rosbag" type="play" name="play" args="-r 0.5 $(find face_detector)/test/face_detector_withface_test_diamondback.bag"/>
<param name="hztest1/hz" value="30.0" />
<param name="hztest1/hzerror" value="29.9" />
<node pkg="rosbag" type="play" name="play" args="--clock -l -r 0.5 $(find face_detector)/test/face_detector_withface_test_diamondback.bag"/>

<test pkg="rostest" type="publishtest"
test-name="pubtest_detectedface" name="pubtest_detectedface" retry="$(arg RETRY_TEST)">
<rosparam subst_value="True">
topics:
- name: $(arg topicname_hztest)
timeout: 5
negative: False
</rosparam>
</test>
</group>

<param name="hztest1/topic" value="face_detector/people_tracker_measurements_array" />
<param name="hztest1/test_duration" value="15.0" />
<test test-name="hztest_test" pkg="rostest" type="hztest" name="hztest1" />
</launch>
6 changes: 3 additions & 3 deletions face_detector/test/narrow-stereo_false_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<launch>
<arg name="expected_success" value="false" />
<arg name="testnode_name" default="hztest_narrow_stereo_false" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector.narrow.launch"/>

<include file="$(find face_detector)/test/common_rtest.xml">
<arg name="expected_success" value="false" />
</include>
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
3 changes: 2 additions & 1 deletion face_detector/test/narrow-stereo_true_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<launch>
<arg name="testnode_name" default="hztest_narrow_stereo_true" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector.narrow.launch"/>

<include file="$(find face_detector)/test/common_rtest.xml" />
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
15 changes: 11 additions & 4 deletions face_detector/test/rgbd_false_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<launch>
<arg name="expected_success" value="false" />
<arg name="testnode_name" default="hztest_rgbd_false" />
<arg name="topicname_hztest" default="/face_detector/faces_cloud" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector.rgbd.launch"/>
<include file="$(find face_detector)/launch/face_detector.rgbd.launch">
<arg name="camera" value="wide_stereo" />
<arg name="rgb_ns" value="right" />
<arg name="image_topic" value="image_raw" />
<arg name="depth_ns" value="right" />
<arg name="depth_topic" value="image_raw" />
</include>

<include file="$(find face_detector)/test/common_rtest.xml">
<arg name="expected_success" value="false" />
</include>
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
14 changes: 12 additions & 2 deletions face_detector/test/rgbd_true_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<launch>
<arg name="hz" default="500.0" />
<arg name="hz_error" default="499.9" />
<arg name="testnode_name" default="hztest_rgbd_true" />
<arg name="topicname_hztest" default="/face_detector/faces_cloud" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector.rgbd.launch"/>
<include file="$(find face_detector)/launch/face_detector.rgbd.launch">
<arg name="camera" value="wide_stereo" />
<arg name="rgb_ns" value="right" />
<arg name="image_topic" value="image_raw" />
<arg name="depth_ns" value="right" />
<arg name="depth_topic" value="image_raw" />
</include>

<include file="$(find face_detector)/test/common_rtest.xml" />
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
6 changes: 3 additions & 3 deletions face_detector/test/wide-stereo_false_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<launch>
<arg name="expected_success" value="false" />
<arg name="testnode_name" default="hztest_wide_stereo_false" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector.wide.launch"/>

<include file="$(find face_detector)/test/common_rtest.xml">
<arg name="expected_success" value="false" />
</include>
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
3 changes: 2 additions & 1 deletion face_detector/test/wide-stereo_true_rtest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<launch>
<arg name="testnode_name" default="hztest_wide_stereo_true" />

<node ns="wide_stereo" pkg="stereo_image_proc" type="stereo_image_proc" name="stereo" />

<include file="$(find face_detector)/launch/face_detector.wide.launch"/>

<include file="$(find face_detector)/test/common_rtest.xml" />
<include file="$(find face_detector)/test/common_rtest.xml" pass_all_args="true" />
</launch>
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove

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
2 changes: 2 additions & 0 deletions people/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<!-- Dependencies needed after this package is compiled. -->
<run_depend>people_msgs</run_depend>
<run_depend>face_detector</run_depend>
<run_depend>leg_detector</run_depend>
<run_depend>people_tracking_filter</run_depend>
<run_depend>people_velocity_tracker</run_depend>

<!-- Dependencies needed only for running tests. -->

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