Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
  jtf::mesh2::meshes tmp_mesh;
  jtf::mesh2::load_obj("E:/workspace/geometry/bilateral_normal_filtering/result/2/expected.obj", tmp_mesh.mesh_, tmp_mesh.node_);
  zsw::Flann<double> flann(tmp_mesh.node_.data(), (size_t)tmp_mesh.node_.cols());
  Eigen::Matrix<double, 3, Eigen::Dynamic> query = tmp_mesh.node_;
  std::vector<size_t> indices;
  std::vector<double> dist;
  flann.queryNearest(query, indices, dist);
  for(size_t i=0; i<indices.size(); ++i) {
    std::cout << indices[i] << "/" << dist[i] << " ";
  }
  std::cout << std::endl;
  return 0;
}
Ejemplo n.º 2
0
std::vector<cv::RotatedRect> RandomFeatureFinder::removeIntersectingEllipses( const std::vector<cv::RotatedRect>& ellipses )
{
    // init stuff
    std::vector<cv::RotatedRect> result;

    // init flann
    cv::Mat_<double> centersCV( static_cast<int>(ellipses.size()), 2 );
    for( size_t i=0; i<ellipses.size(); i++ )
    {
        centersCV( i, 0 ) = ellipses[i].center.x;
        centersCV( i, 1 ) = ellipses[i].center.y;
    }
    cv::flann::GenericIndex< cv::flann::L2_Simple<double> > flann( centersCV, cvflann::KDTreeIndexParams(5) );

    // run over all points and look at the neighbors
    for( size_t i=0; i<ellipses.size(); i++ )
    {
        // get the 5 nearest neighbors of this elipse' center
        cv::Mat_<int> neighbors( 1, 5+1 );
        cv::Mat_<double> dists( 1, 5+1 );
        flann.knnSearch( centersCV.row(i).clone(), neighbors, dists, 5+1, cvflann::SearchParams(128) );
        bool skip = false;

        // have a look at the neighbors
        // if not first point in a "dense cluster", skip
        double rMax = std::max( ellipses[i].size.width, ellipses[i].size.height );
        for( size_t n=1; n<=5; n++ )
            if( dists(n) < rMax && neighbors(n) < i )
                skip = true;

        // if all went well, add the ellipse
        if( !skip )
            result.push_back( ellipses[i] );
    }

    // return
    return result;
}
Ejemplo n.º 3
0
Mat hallaCorresp(Mat im1,Mat im2,vector<KeyPoint> kp1,vector<KeyPoint> kp2,Mat descrip1,Mat descrip2,string criterio,vector<DMatch> &coincidencias){

    Mat emparejados;
    
     coincidencias.clear();   
    if(criterio.compare("BFCrossCheck")==0){

        bool crossCheck;
        
        BFMatcher m(NORM_HAMMING, crossCheck=true); 
        m.match(descrip1, descrip2,coincidencias);
        
    }else if(criterio.compare("Flann")==0){
 //       Ptr<DescriptorMatcher> flann=DescriptorMatcher::create("FlannBased");
 //       flann->match(descrip1, descrip2,coincidencias);
        
        cv::FlannBasedMatcher flann(new cv::flann::LshIndexParams(15,15,0));
        flann.match(descrip1, descrip2,coincidencias);
    } 
    drawMatches(im1,kp1,im2,kp2,coincidencias,emparejados);
    
    return emparejados;
}