From: <da...@us...> - 2009-07-31 23:44:37
|
Revision: 20338 http://personalrobots.svn.sourceforge.net/personalrobots/?rev=20338&view=rev Author: danmuno Date: 2009-07-31 23:44:31 +0000 (Fri, 31 Jul 2009) Log Message: ----------- made rf creator return boost shared_ptr to random field Modified Paths: -------------- pkg/trunk/sandbox/functional_m3n/examples/classify_m3n.cpp pkg/trunk/sandbox/functional_m3n/examples/train_m3n.cpp pkg/trunk/sandbox/functional_m3n/include/functional_m3n/example/pt_cloud_rf_creator.h pkg/trunk/sandbox/functional_m3n/src/example/pt_cloud_rf_creator.cpp Modified: pkg/trunk/sandbox/functional_m3n/examples/classify_m3n.cpp =================================================================== --- pkg/trunk/sandbox/functional_m3n/examples/classify_m3n.cpp 2009-07-31 23:43:02 UTC (rev 20337) +++ pkg/trunk/sandbox/functional_m3n/examples/classify_m3n.cpp 2009-07-31 23:44:31 UTC (rev 20338) @@ -5,6 +5,8 @@ * Author: dmunoz */ +#include <boost/shared_ptr.hpp> + #include <robot_msgs/PointCloud.h> #include <functional_m3n/example/pt_cloud_rf_creator.h> @@ -85,7 +87,7 @@ // ---------------------------------------------------------- // Create random field PtCloudRFCreator rf_creator; - RandomField* testing_rf = rf_creator.createRandomField(pt_cloud); + boost::shared_ptr<RandomField> testing_rf = rf_creator.createRandomField(pt_cloud); // ---------------------------------------------------------- // Load M3N model Modified: pkg/trunk/sandbox/functional_m3n/examples/train_m3n.cpp =================================================================== --- pkg/trunk/sandbox/functional_m3n/examples/train_m3n.cpp 2009-07-31 23:43:02 UTC (rev 20337) +++ pkg/trunk/sandbox/functional_m3n/examples/train_m3n.cpp 2009-07-31 23:44:31 UTC (rev 20338) @@ -5,6 +5,8 @@ * Author: dmunoz */ +#include <boost/shared_ptr.hpp> + #include <robot_msgs/PointCloud.h> #include <functional_m3n/example/pt_cloud_rf_creator.h> @@ -76,7 +78,7 @@ // ---------------------------------------------------------- // Create random field PtCloudRFCreator rf_creator; - const RandomField* training_rf = rf_creator.createRandomField(pt_cloud, labels); + const boost::shared_ptr<RandomField> training_rf = rf_creator.createRandomField(pt_cloud, labels); training_rf->saveNodeFeatures("tempo/train_node_unknown.txt"); training_rf->saveCliqueFeatures("tempo/train_rf_unknown"); @@ -95,7 +97,7 @@ // Train M3N model ROS_INFO("Starting to train..."); M3NModel m3n_model; - vector<const RandomField*> training_rfs(1, training_rf); + vector<const RandomField*> training_rfs(1, training_rf.get()); if (m3n_model.train(training_rfs, m3n_learning_params) < 0) { ROS_ERROR("Failed to train M3N model"); Modified: pkg/trunk/sandbox/functional_m3n/include/functional_m3n/example/pt_cloud_rf_creator.h =================================================================== --- pkg/trunk/sandbox/functional_m3n/include/functional_m3n/example/pt_cloud_rf_creator.h 2009-07-31 23:43:02 UTC (rev 20337) +++ pkg/trunk/sandbox/functional_m3n/include/functional_m3n/example/pt_cloud_rf_creator.h 2009-07-31 23:44:31 UTC (rev 20338) @@ -36,6 +36,8 @@ #include <vector> +#include <boost/shared_ptr.hpp> + #include <robot_msgs/PointCloud.h> #include <point_cloud_clustering/kmeans.h> @@ -56,13 +58,10 @@ nbr_clique_sets_ = 2; } - RandomField* createRandomField(const robot_msgs::PointCloud& pt_cloud) - { - std::vector<float> labels; - return createRandomField(pt_cloud, labels); - } + boost::shared_ptr<RandomField> createRandomField(const robot_msgs::PointCloud& pt_cloud); - RandomField* createRandomField(const robot_msgs::PointCloud& pt_cloud, const std::vector<float>& labels); + boost::shared_ptr<RandomField> createRandomField(const robot_msgs::PointCloud& pt_cloud, + const std::vector<float>& labels); private: void createDescriptors(); Modified: pkg/trunk/sandbox/functional_m3n/src/example/pt_cloud_rf_creator.cpp =================================================================== --- pkg/trunk/sandbox/functional_m3n/src/example/pt_cloud_rf_creator.cpp 2009-07-31 23:43:02 UTC (rev 20337) +++ pkg/trunk/sandbox/functional_m3n/src/example/pt_cloud_rf_creator.cpp 2009-07-31 23:44:31 UTC (rev 20338) @@ -477,14 +477,14 @@ // -------------------------------------------------------------- /*! See function definition */ // -------------------------------------------------------------- -RandomField* PtCloudRFCreator::createRandomField(const robot_msgs::PointCloud& pt_cloud, +boost::shared_ptr<RandomField> PtCloudRFCreator::createRandomField(const robot_msgs::PointCloud& pt_cloud, const vector<float>& labels) { createDescriptors(); unsigned int nbr_clique_sets = clique_set_clusterings_.size(); cloud_kdtree::KdTreeANN pt_cloud_kdtree(pt_cloud); - RandomField* rf = new RandomField(nbr_clique_sets); + boost::shared_ptr<RandomField> rf = boost::shared_ptr<RandomField>(new RandomField(nbr_clique_sets)); ROS_INFO("=============== CREATING RANDOM FIELD ================="); @@ -512,3 +512,9 @@ ROS_INFO("=============== FINISHED RANDOM FIELD =================\n"); return rf; } + +boost::shared_ptr<RandomField> PtCloudRFCreator::createRandomField(const robot_msgs::PointCloud& pt_cloud) +{ + std::vector<float> labels; + return createRandomField(pt_cloud, labels); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |