Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <gtest/gtest.h>
00049 #include <pcl/io/pcd_io.h>
00050 #include <pcl/point_types.h>
00051 #include <pcl/visualization/pcl_visualizer.h>
00052 #include <pcl/sample_consensus/sac_model_plane.h>
00053 #include <pcl/people/ground_based_people_detection_app.h>
00054
00055 typedef pcl::PointXYZRGB PointT;
00056 typedef pcl::PointCloud<PointT> PointCloudT;
00057
00058 enum { COLS = 640, ROWS = 480 };
00059 PointCloudT::Ptr cloud;
00060 pcl::people::PersonClassifier<pcl::RGB> person_classifier;
00061 std::string svm_filename;
00062 float min_confidence;
00063 float min_height;
00064 float max_height;
00065 float voxel_size;
00066 Eigen::Matrix3f rgb_intrinsics_matrix;
00067 Eigen::VectorXf ground_coeffs;
00068
00069 TEST (PCL, PersonClassifier)
00070 {
00071
00072 EXPECT_TRUE (person_classifier.loadSVMFromFile(svm_filename));
00073 }
00074
00075 TEST (PCL, GroundBasedPeopleDetectionApp)
00076 {
00077
00078 pcl::people::GroundBasedPeopleDetectionApp<PointT> people_detector;
00079 people_detector.setVoxelSize(voxel_size);
00080 people_detector.setIntrinsics(rgb_intrinsics_matrix);
00081 people_detector.setClassifier(person_classifier);
00082 people_detector.setHeightLimits(min_height, max_height);
00083
00084
00085 std::vector<pcl::people::PersonCluster<PointT> > clusters;
00086 people_detector.setInputCloud(cloud);
00087 people_detector.setGround(ground_coeffs);
00088 EXPECT_TRUE (people_detector.compute(clusters));
00089
00090 unsigned int k = 0;
00091 for(std::vector<pcl::people::PersonCluster<PointT> >::iterator it = clusters.begin(); it != clusters.end(); ++it)
00092 {
00093 if(it->getPersonConfidence() > min_confidence)
00094 k++;
00095 }
00096 EXPECT_EQ (k, 5);
00097 }
00098
00099 int main (int argc, char** argv)
00100 {
00101 if (argc < 2)
00102 {
00103 cerr << "No svm filename provided. Please download `trainedLinearSVMForPeopleDetectionWithHOG.yaml` and pass its path to the test." << endl;
00104 return (-1);
00105 }
00106
00107 if (argc < 3)
00108 {
00109 cerr << "No test file given. Please download 'five_people.pcd` and pass its path to the test." << endl;
00110 return (-1);
00111 }
00112
00113 cloud = PointCloudT::Ptr (new PointCloudT);
00114 if (pcl::io::loadPCDFile (argv[2], *cloud) < 0)
00115 {
00116 cerr << "Failed to read test file. Please download `five_people.pcd` and pass its path to the test." << endl;
00117 return (-1);
00118 }
00119
00120
00121 svm_filename = argv[1];
00122 min_confidence = -1.5;
00123 min_height = 1.3;
00124 max_height = 2.3;
00125 voxel_size = 0.06;
00126
00127 rgb_intrinsics_matrix << 525, 0.0, 319.5, 0.0, 525, 239.5, 0.0, 0.0, 1.0;
00128 ground_coeffs.resize(4);
00129 ground_coeffs << -0.0103586, 0.997011, 0.0765573, -1.26614;
00130
00131 testing::InitGoogleTest (&argc, argv);
00132 return (RUN_ALL_TESTS ());
00133 }