NDEVR
API Documentation
InMemoryRegionsProvider.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2026, NDEVR LLC
3tyler.parke@ndevr.org
4 *-----------------------------------------------------------------------------------------**/
5#pragma once
6#include "DLLInfo.h"
7#include <NDEVR/BaseValues.h>
8#include <NDEVR/Dictionary.h>
9
10// OpenMVG
11#include <openMVG/sfm/pipelines/sfm_regions_provider.hpp>
12#include <openMVG/features/regions.hpp>
13#include <openMVG/matching/indMatch.hpp>
14#include <openMVG/matching/indMatchDecoratorXY.hpp>
15#include <openMVG/sfm/pipelines/sfm_matches_provider.hpp>
16
17#include <memory>
18
19namespace NDEVR
20{
39 // No DRONE_PHOTOGRAMMETRY_API: inherits from a non-DLL openMVG type (C4275).
40 // This class is used only internally via shared_ptr and never exported directly.
41 class InMemoryRegionsProvider
42 : public openMVG::sfm::Regions_Provider
43 {
44 public:
45 InMemoryRegionsProvider() = default;
46
52 void add(openMVG::IndexT view_id,
53 std::unique_ptr<openMVG::features::Regions> regions)
54 {
55 // Set the base-class region_type_ once so the non-virtual Type_id() / IsBinary()
56 // / IsScalar() methods return the correct values. Cascade_Hashing_Matcher_Regions
57 // calls Type_id() to decide whether to dispatch to impl::Match<float> or
58 // impl::Match<unsigned char>; leaving region_type_ null causes it to fall into the
59 // "not implemented" branch and produce 0 matches.
60 if (!region_type_)
61 region_type_.reset(regions->EmptyClone());
62 cache_[view_id] = std::shared_ptr<openMVG::features::Regions>(std::move(regions));
63 }
64
68 std::shared_ptr<openMVG::features::Regions>
69 get(const openMVG::IndexT x) const override
70 {
71 auto it = cache_.find(x);
72 return (it != cache_.end()) ? it->second : nullptr;
73 }
74
78 {
79 return static_cast<uint04>(cache_.size());
80 }
81
82 private:
83 // openMVG's Regions_Provider already declares the map; we shadow it here with a
84 // direct std::unordered_map for O(1) lookup by view ID.
85 std::unordered_map<openMVG::IndexT,
86 std::shared_ptr<openMVG::features::Regions>> cache_;
87 };
88
95 // No DRONE_PHOTOGRAMMETRY_API: same reason as InMemoryRegionsProvider (C4275).
96 class InMemoryMatchesProvider
97 : public openMVG::sfm::Matches_Provider
98 {
99 public:
100 InMemoryMatchesProvider() = default;
101
105 void setMatches(openMVG::matching::PairWiseMatches matches)
106 {
107 pairWise_matches_ = std::move(matches);
108 }
109
111 bool load(const openMVG::sfm::SfM_Data&, const std::string&) override
112 {
113 return true; // already in memory, nothing to load
114 }
115 };
116}
bool load(const openMVG::sfm::SfM_Data &, const std::string &) override
Required override — no loading from disk.
void setMatches(openMVG::matching::PairWiseMatches matches)
Overwrite the internal matches map with the result from a matcher.
std::shared_ptr< openMVG::features::Regions > get(const openMVG::IndexT x) const override
Return the regions for a given view.
void add(openMVG::IndexT view_id, std::unique_ptr< openMVG::features::Regions > regions)
Store regions for a view.
uint04 viewCount() const
Return the number of views stored.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...