vws_alg.cpp
Go to the documentation of this file.
00001 #include "vws_alg.h"
00002 
00003 VwsAlgorithm::VwsAlgorithm(void)
00004 {
00005 }
00006 
00007 VwsAlgorithm::~VwsAlgorithm(void)
00008 {
00009 }
00010 
00011 void VwsAlgorithm::config_update(Config& new_cfg, uint32_t level)
00012 {
00013   this->lock();
00014 
00015   // save the current configuration
00016   this->config_=new_cfg;
00017   
00018   this->unlock();
00019 }
00020 
00021 // VwsAlgorithm Public API
00022 cv::Mat VwsAlgorithm::descriptors_srv_to_mat(iri_perception_msgs::DescriptorsToVws::Request &req)
00023 {
00024 //         cv::Mat descriptors;
00025         cv::Mat descriptors;
00026         descriptors = cv::Mat::zeros(req.descriptor_set.num, req.descriptor_set.len, CV_32FC1); // (rows, cols)
00027         
00028         for(int i=0; i < req.descriptor_set.num; i++) {
00029                 for(int j=0; j< req.descriptor_set.len; j++) {
00030                         descriptors.at<float>(i,j) = (float)req.descriptor_set.descriptors[i].descriptor[j];
00031                 }
00032         }
00033         return descriptors;
00034 }
00035 
00036 
00037 iri_perception_msgs::GeoVwSet VwsAlgorithm::get_geo_vw_from_descriptors(iri_perception_msgs::DescriptorsToVws::Request &req)
00038 {
00039         iri_perception_msgs::GeoVwSet result;
00040         std::vector<cv::DMatch> matches;
00041         cv::Mat descriptors;
00042         
00043         /*  ---------------------
00044         
00045         Header header
00046         int32 num_orient_bins
00047         int32 num_spa_bins
00048         int32 num
00049         int32 len
00050         int32 width
00051         int32 height
00052         iri_perception_msgs/Descriptor[] descriptors
00053         
00054         */
00055         
00056         descriptors = descriptors_srv_to_mat(req);
00057         
00058         ROS_INFO("MATCHING! %d, %d", descriptors.rows, centroids_.rows);
00059         
00060         cv::Ptr<cv::DescriptorMatcher> matcher = cv::DescriptorMatcher::create("BruteForce");
00061         matcher->match( descriptors, centroids_, matches);
00062         
00063         for ( std::vector<cv::DMatch>::iterator it=matches.begin() ; it < matches.end(); it++ ) {
00064                 iri_perception_msgs::GeoVw geo_vw;
00065                 geo_vw.x = req.descriptor_set.descriptors[it->queryIdx].u;
00066                 geo_vw.y = req.descriptor_set.descriptors[it->queryIdx].v;
00067                 geo_vw.word = it->trainIdx;
00068                 result.geo_vws.push_back(geo_vw);
00069         }
00070         
00071         return result;
00072 }


iri_vws
Author(s): dmartinez
autogenerated on Fri Dec 6 2013 22:49:05