Exemplo n.º 1
0
    /**
     * Fill mask from corresponding points (each point pictured by a disk of radius _radius)
     *
     * \param[out] maskLeft Mask of the left image (initialized to corresponding image size).
     * \param[out] maskRight  Mask of the right image  (initialized to corresponding image size).
     *
     * \return True if some pixel have been set to true.
     */
    virtual bool computeMask( image::Image< unsigned char > & maskLeft, image::Image< unsigned char > & maskRight )
    {
        maskLeft.fill(0);
        maskRight.fill(0);
        for( std::vector< matching::IndMatch >::const_iterator
                iter_putativeMatches = _vec_PutativeMatches.begin();
                iter_putativeMatches != _vec_PutativeMatches.end();
                ++iter_putativeMatches )
        {
            const features::SIOPointFeature & L = _vec_featsL[ iter_putativeMatches->i_ ];
            const features::SIOPointFeature & R = _vec_featsR[ iter_putativeMatches->j_ ];

            image::FilledCircle( L.x(), L.y(), ( int )_radius, ( unsigned char ) 255, &maskLeft );
            image::FilledCircle( R.x(), R.y(), ( int )_radius, ( unsigned char ) 255, &maskRight );
        }
        return _vec_PutativeMatches.size() > 0;
    }
Exemplo n.º 2
0
  /**
   * Put masks to white, images are conserved
   *
   * \param[out] maskLeft Mask of the left image (initialized to corresponding image size).
   * \param[out] maskRight  Mask of the right image (initialized to corresponding image size).
   *
   * \return True.
   */
  virtual bool computeMask(
    image::Image< unsigned char > & maskLeft,
    image::Image< unsigned char > & maskRight )
  {
    std::vector< matching::IndMatch > vec_KVLDMatches;

    image::Image< unsigned char > imageL, imageR;
    image::ReadImage( _sLeftImage.c_str(), &imageL );
    image::ReadImage( _sRightImage.c_str(), &imageR );

    image::Image< float > imgA ( imageL.GetMat().cast< float >() );
    image::Image< float > imgB(imageR.GetMat().cast< float >());

    std::vector< Pair > matchesFiltered, matchesPair;

    for( std::vector< matching::IndMatch >::const_iterator iter_match = _vec_PutativeMatches.begin();
          iter_match != _vec_PutativeMatches.end();
          ++iter_match )
    {
      matchesPair.push_back( std::make_pair( iter_match->i_, iter_match->j_ ) );
    }

    std::vector< double > vec_score;

    //In order to illustrate the gvld(or vld)-consistant neighbors, the following two parameters has been externalized as inputs of the function KVLD.
    openMVG::Mat E = openMVG::Mat::Ones( _vec_PutativeMatches.size(), _vec_PutativeMatches.size() ) * ( -1 );
    // gvld-consistancy matrix, intitialized to -1,  >0 consistancy value, -1=unknow, -2=false
    std::vector< bool > valide( _vec_PutativeMatches.size(), true );// indices of match in the initial matches, if true at the end of KVLD, a match is kept.

    size_t it_num = 0;
    KvldParameters kvldparameters;//initial parameters of KVLD
    //kvldparameters.K = 5;
    while (
      it_num < 5 &&
      kvldparameters.inlierRate >
      KVLD(
        imgA, imgB,
        _vec_featsL, _vec_featsR,
        matchesPair, matchesFiltered,
        vec_score, E, valide, kvldparameters ) )
    {
      kvldparameters.inlierRate /= 2;
      std::cout<<"low inlier rate, re-select matches with new rate="<<kvldparameters.inlierRate<<std::endl;
      kvldparameters.K = 2;
      it_num++;
    }

    bool bOk = false;
    if( !matchesPair.empty())
    {
      // Get mask
      getKVLDMask(
        &maskLeft, &maskRight,
        _vec_featsL, _vec_featsR,
        matchesPair,
        valide,
        E);
      bOk = true;
    }
    else{
      maskLeft.fill( 0 );
      maskRight.fill( 0 );
    }

    return bOk;
  }
Exemplo n.º 3
0
 /**
  * Put masks to white, all image is considered as valid pixel selection
  *
  * \param[out] maskLeft Mask of the left image (initialized to corresponding image size).
  * \param[out] maskRight  Mask of the right image (initialized to corresponding image size).
  *
  * \return True.
  */
 bool computeMask( image::Image< unsigned char > & maskLeft, image::Image< unsigned char > & maskRight ) override 
 {
   maskLeft.fill( image::WHITE );
   maskRight.fill( image::WHITE );
   return true;
 }