Skip to content

Commit

Permalink
Added unit tests for GroundBasedPeopleDetectionApp and PersonClassifi…
Browse files Browse the repository at this point in the history
…er of people module.
  • Loading branch information
mmunaro committed Apr 15, 2013
1 parent 977a3e7 commit fc89e09
Show file tree
Hide file tree
Showing 7 changed files with 307,369 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ namespace pcl
* \brief Perform people detection on the input data and return people clusters information.
*
* \param[out] clusters Vector of PersonCluster.
*
* \return true if the compute operation is succesful, false otherwise.
*/
void
bool
compute (std::vector<pcl::people::PersonCluster<PointT> >& clusters);

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,29 +203,29 @@ pcl::people::GroundBasedPeopleDetectionApp<PointT>::swapDimensions (pcl::PointCl
cloud = output_cloud;
}

template <typename PointT> void
template <typename PointT> bool
pcl::people::GroundBasedPeopleDetectionApp<PointT>::compute (std::vector<pcl::people::PersonCluster<PointT> >& clusters)
{
// Check if all mandatory variables have been set:
if (sqrt_ground_coeffs_ != sqrt_ground_coeffs_)
{
PCL_ERROR ("[pcl::people::GroundBasedPeopleDetectionApp::compute] Floor parameters have not been set or they are not valid!\n");
return;
return (false);
}
if (cloud_ == NULL)
{
PCL_ERROR ("[pcl::people::GroundBasedPeopleDetectionApp::compute] Input cloud has not been set!\n");
return;
return (false);
}
if (intrinsics_matrix_(0) == 0)
{
PCL_ERROR ("[pcl::people::GroundBasedPeopleDetectionApp::compute] Camera intrinsic parameters have not been set!\n");
return;
return (false);
}
if (!person_classifier_set_flag_)
{
PCL_ERROR ("[pcl::people::GroundBasedPeopleDetectionApp::compute] Person classifier has not been set!\n");
return;
return (false);
}

if (!dimension_limits_set_) // if dimension limits have not been set by the user
Expand Down Expand Up @@ -300,6 +300,8 @@ pcl::people::GroundBasedPeopleDetectionApp<PointT>::compute (std::vector<pcl::pe
bottom /= bottom(2);
it->setPersonConfidence(person_classifier_.evaluate(rgb_image_, bottom, top, centroid, intrinsics_matrix_, vertical_));
}

return (true);
}

template <typename PointT>
Expand Down
12 changes: 11 additions & 1 deletion people/include/pcl/people/impl/person_classifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pcl::people::PersonClassifier<PointT>::PersonClassifier () {}
template <typename PointT>
pcl::people::PersonClassifier<PointT>::~PersonClassifier () {}

template <typename PointT> void
template <typename PointT> bool
pcl::people::PersonClassifier<PointT>::loadSVMFromFile (std::string svm_filename)
{
std::string line;
Expand Down Expand Up @@ -79,6 +79,16 @@ pcl::people::PersonClassifier<PointT>::loadSVMFromFile (std::string svm_filename
SVM_weights_.push_back(std::atof(line.substr(prev_tok_pos+1, tok_pos-prev_tok_pos-1).c_str()));
}
SVM_file.close();

if (SVM_weights_.size() == 0)
{
PCL_ERROR ("[pcl::people::PersonClassifier::loadSVMFromFile] Invalid SVM file!\n");
return (false);
}
else
{
return (true);
}
}

template <typename PointT> void
Expand Down
4 changes: 3 additions & 1 deletion people/include/pcl/people/person_classifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ namespace pcl
/** \brief Load SVM parameters from a text file.
*
* \param[in] svm_filename Filename containing SVM parameters.
*
* \return true if SVM has been correctly set, false otherwise.
*/
void
bool
loadSVMFromFile (std::string svm_filename);

/**
Expand Down
8 changes: 6 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ set(SUBSYS_DESC "Point cloud library global unit tests")

if(BUILD_visualization)
include (${VTK_USE_FILE})
set(SUBSYS_DEPS 2d common sample_consensus io kdtree features filters geometry keypoints search surface registration segmentation octree recognition outofcore visualization)
set(SUBSYS_DEPS 2d common sample_consensus io kdtree features filters geometry keypoints search surface registration segmentation octree recognition people outofcore visualization)
set(OPT_DEPS vtk)
else()
set(SUBSYS_DEPS 2d common sample_consensus io kdtree features filters geometry keypoints search surface registration segmentation octree recognition outofcore)
set(SUBSYS_DEPS 2d common sample_consensus io kdtree features filters geometry keypoints search surface registration segmentation octree recognition people outofcore)
endif()

set(DEFAULT ON)
Expand Down Expand Up @@ -72,6 +72,10 @@ if(build)
LINK_WITH pcl_gtest pcl_common pcl_io pcl_kdtree pcl_features pcl_recognition pcl_keypoints
ARGUMENTS ${PCL_SOURCE_DIR}/test/milk.pcd ${PCL_SOURCE_DIR}/test/milk_cartoon_all_small_clorox.pcd)

PCL_ADD_TEST(a_people_detection_test test_people_detection
FILES test_people_groundBasedPeopleDetectionApp.cpp
LINK_WITH pcl_gtest pcl_common pcl_io pcl_kdtree pcl_search pcl_features pcl_sample_consensus pcl_filters pcl_io pcl_segmentation
ARGUMENTS ${PCL_SOURCE_DIR}/test/five_people.pcd)

if(BUILD_visualization AND (NOT UNIX OR (UNIX AND DEFINED ENV{DISPLAY})))
PCL_ADD_TEST(a_visualization_test test_visualization
Expand Down
Loading

0 comments on commit fc89e09

Please sign in to comment.