place_matcher_mcc_node.cpp
Go to the documentation of this file.
00001 /********************************************
00002  * Server for polygon dissimilarity service based on the Multi-scale Convexity
00003  * Concavity (MCC) representation.
00004  *
00005  * Based on article 
00006  * @ARTICLE{Adamek2004,
00007  *    author={Adamek, T. and O''Connor, N.E.},
00008  *    journal={Circuits and Systems for Video Technology, IEEE Transactions on}, 
00009  *    title={A multiscale representation method for nonrigid shapes with a single closed contour},
00010  *    year={2004},
00011  *    volume={14},
00012  *    number={5},
00013  *    pages={742-753},
00014  *    doi={10.1109/TCSVT.2004.826776},
00015  *    ISSN={1051-8215},
00016  *    }
00017  *************************************/
00018 
00019 #include <ros/ros.h>
00020 
00021 #include <place_matcher_msgs/GetCapability.h>
00022 
00023 #include <place_matcher_mcc/dissimilarity_getter.h>
00024 
00025 bool callback_getCapability(place_matcher_msgs::GetCapabilityRequest& req, place_matcher_msgs::GetCapabilityResponse& res)
00026 {
00027   res.scale_invariance = place_matcher_msgs::GetCapabilityResponse::TRUE;
00028   res.translation_invariance = place_matcher_msgs::GetCapabilityResponse::TRUE;
00029   res.rotation_invariance = place_matcher_msgs::GetCapabilityResponse::OPTIONAL;
00030   res.provides_dissimilarity = true;
00031   res.provides_pose = false;
00032   return true;
00033 }
00034 
00035 int main(int argc, char **argv)
00036 {
00037   int max_thread;
00038   ros::init(argc, argv, "polygon_dissimilarity_server_mcc");
00039   ros::NodeHandle nh("~");
00040 
00041   nh.param<int>("max_thread", max_thread, 1);
00042 
00043   place_matcher_mcc::DissimilarityGetter dissimilarity_getter;
00044 
00045   // Number of points to keep for the mcc computation.
00046   if (nh.hasParam("sample_count"))
00047   {
00048     int sample_count;
00049     nh.getParam("sample_count", sample_count);
00050     if (sample_count > 0)
00051     {
00052       dissimilarity_getter.sample_count = sample_count;
00053     }
00054     else
00055     {
00056       ROS_WARN_STREAM(nh.getNamespace() <<
00057           "/sample_count must be positive, setting to default (" <<
00058           dissimilarity_getter.sample_count << ")");
00059     }
00060   }
00061 
00062   // Number of scales to compute.
00063   if (nh.hasParam("scale_count"))
00064   {
00065     int scale_count;
00066     nh.getParam("scale_count", scale_count);
00067     if (scale_count > 0)
00068     {
00069       dissimilarity_getter.scale_count = scale_count;
00070     }
00071     else
00072     {
00073       ROS_WARN_STREAM(nh.getNamespace() <<
00074           "/scale_count must be positive, setting to default (" <<
00075           dissimilarity_getter.scale_count << ")");
00076     }
00077   }
00078 
00079   // With rotation_invariance = true, no cyclic optimization will be done in compare.
00080   nh.getParam("rotation_invariance", dissimilarity_getter.rotation_invariance);
00081 
00082   ros::ServiceServer get_capability_server = nh.advertiseService("get_capability", callback_getCapability);
00083   ros::ServiceServer compute_dissimilarity_server = nh.advertiseService("compute_dissimilarity",
00084       &place_matcher_mcc::DissimilarityGetter::getDissimilarity, &dissimilarity_getter);
00085 
00086   ROS_INFO("Ready to work (with %i threads)", max_thread);
00087 
00088   ros::MultiThreadedSpinner spinner(max_thread);
00089   spinner.spin();
00090 
00091   return 0;
00092 }


place_matcher_mcc
Author(s): Gaël Ecorchard , Karel Košnar
autogenerated on Sat Jun 8 2019 19:53:05