コード例 #1
0
ファイル: tracks.hpp プロジェクト: kjaylee/openMVG
  /**
   * @brief Find common tracks between images.
   *
   * @param[in] set_imageIndex: set of images we are looking for common tracks
   * @param[in] map_tracksIn: all tracks of the scene
   * @param[out] map_tracksOut: output with only the common tracks
   */
  static bool GetTracksInImages(
    const std::set<size_t> & set_imageIndex,
    const STLMAPTracks & map_tracksIn,
    STLMAPTracks & map_tracksOut)
  {
    map_tracksOut.clear();

    // Go along the tracks
    for (STLMAPTracks::const_iterator iterT = map_tracksIn.begin();
      iterT != map_tracksIn.end(); ++iterT)
    {
      // Look if the track contains the provided view index & save the point ids
      submapTrack map_temp;
      bool bTest = true;
      for (std::set<size_t>::const_iterator iterIndex = set_imageIndex.begin();
        iterIndex != set_imageIndex.end() && bTest; ++iterIndex)
      {
        submapTrack::const_iterator iterSearch = iterT->second.find(*iterIndex);
        if (iterSearch != iterT->second.end())
          map_temp[iterSearch->first] = iterSearch->second;
        else
          bTest = false;
      }

      if (!map_temp.empty() && map_temp.size() == set_imageIndex.size())
        map_tracksOut[iterT->first] = std::move(map_temp);
    }
    return !map_tracksOut.empty();
  }
コード例 #2
0
  /**
   * @brief Convert a trackId to a vector of indexed Matches.
   *
   * @param[in]  map_tracks: set of tracks with only 2 elements
   *             (image A and image B) in each submapTrack.
   * @param[in]  vec_filterIndex: the track indexes to retrieve.
   *             Only track indexes contained in this filter vector are kept.
   * @param[out] pvec_index: list of matches
   *             (feature index in image A, feature index in image B).
   *
   * @warning The input tracks must be composed of only two images index.
   * @warning Image index are considered sorted (increasing order).
   */
  static void TracksToIndexedMatches
  (
    const STLMAPTracks & map_tracks,
    const std::vector<IndexT> & vec_filterIndex,
    std::vector<IndMatch> * pvec_index
  )
  {

    std::vector<IndMatch> & vec_indexref = *pvec_index;
    vec_indexref.clear();
    for ( const auto & filter_index : vec_filterIndex )
    {
      // Retrieve the track information from the current index i.
      auto itF =
        find_if(map_tracks.begin(), map_tracks.end(), FunctorMapFirstEqual( filter_index ) ) ;
      // The current track.
      const submapTrack & map_ref = itF->second;

      // We have 2 elements for a track.
      assert(map_ref.size() == 2);
      const IndexT indexI = (map_ref.begin())->second;
      const IndexT indexJ = (++map_ref.begin())->second;

      vec_indexref.emplace_back(indexI, indexJ);
    }
  }
コード例 #3
0
ファイル: tracks.hpp プロジェクト: autosquid/openMVG
  /**
   * @brief Convert a trackId to a vector of indexed Matches.
   *
   * @param[in]  map_tracks: set of tracks with only 2 elements
   *             (image A and image B) in each submapTrack.
   * @param[in]  vec_filterIndex: the track indexes to retrieve.
   *             Only track indexes contained in this filter vector are kept.
   * @param[out] pvec_index: list of matches
   *             (feature index in image A, feature index in image B).
   *
   * @warning The input tracks must be composed of only two images index.
   * @warning Image index are considered sorted (increasing order).
   */
  static void TracksToIndexedMatches
  (
    const STLMAPTracks & map_tracks,
    const std::vector<IndexT> & vec_filterIndex,
    std::vector<matching::IndMatch> * pvec_index
  )
  {
    std::vector<matching::IndMatch> & vec_indexref = *pvec_index;
    vec_indexref.clear();
    for ( const auto & id : vec_filterIndex )
    {
      // Retrieve the track information from the current index id.
      auto itF =
        find_if(
          map_tracks.begin(), map_tracks.end(),
          [id] (const std::pair<uint32_t, submapTrack> & s) { return (id == s.first); }
        );
      // The current track.
      const submapTrack & map_ref = itF->second;

      // We have 2 elements for a track.
      assert(map_ref.size() == 2);
      const IndexT indexI = (map_ref.begin())->second;
      const IndexT indexJ = (++map_ref.begin())->second;

      vec_indexref.emplace_back(indexI, indexJ);
    }
  }
コード例 #4
0
ファイル: tracks.hpp プロジェクト: kjaylee/openMVG
 /// Return the tracksId as a set (sorted increasing)
 static void GetTracksIdVector(
   const STLMAPTracks & map_tracks,
   std::set<size_t> * set_tracksIds)
 {
   set_tracksIds->clear();
   for (STLMAPTracks::const_iterator iterT = map_tracks.begin();
     iterT != map_tracks.end(); ++iterT)
   {
     set_tracksIds->insert(iterT->first);
   }
 }
コード例 #5
0
ファイル: tracks.hpp プロジェクト: kjaylee/openMVG
 /// Return a set containing the image Id considered in the tracks container.
 static void ImageIdInTracks(const STLMAPTracks & map_tracks,
   std::set<size_t> & set_imagesId)
 {
   for (STLMAPTracks::const_iterator iterT = map_tracks.begin();
     iterT != map_tracks.end(); ++iterT)
   {
     const submapTrack & map_ref = iterT->second;
     for (submapTrack::const_iterator iter = map_ref.begin();
       iter != map_ref.end();
       ++iter)
     {
       set_imagesId.insert(iter->first);
     }
   }
 }
コード例 #6
0
ファイル: tracks.hpp プロジェクト: kjaylee/openMVG
 /// Return the occurrence of tracks length.
 static void TracksLength(const STLMAPTracks & map_tracks,
   std::map<size_t, size_t> & map_Occurence_TrackLength)
 {
   for (STLMAPTracks::const_iterator iterT = map_tracks.begin();
     iterT != map_tracks.end(); ++iterT)
   {
     const size_t trLength = iterT->second.size();
     if (map_Occurence_TrackLength.end() ==
       map_Occurence_TrackLength.find(trLength))
     {
       map_Occurence_TrackLength[trLength] = 1;
     }
     else
     {
       map_Occurence_TrackLength[trLength] += 1;
     }
   }
 }
コード例 #7
0
ファイル: tracks.hpp プロジェクト: kjaylee/openMVG
 /// Get feature index PerView and TrackId
 static bool GetFeatIndexPerViewAndTrackId(
   const STLMAPTracks & map_tracks,
   const std::set<size_t> & set_trackId,
   size_t nImageIndex,
   std::vector<size_t> * pvec_featIndex)
 {
   for (STLMAPTracks::const_iterator iterT = map_tracks.begin();
     iterT != map_tracks.end(); ++iterT)
   {
     const size_t trackId = iterT->first;
     if (set_trackId.find(trackId) != set_trackId.end())
     {
       //try to find imageIndex
       const submapTrack & map_ref = iterT->second;
       submapTrack::const_iterator iterSearch = map_ref.find(nImageIndex);
       if (iterSearch != map_ref.end())
       {
         pvec_featIndex->emplace_back(iterSearch->second);
       }
     }
   }
   return !pvec_featIndex->empty();
 }