7#include <unordered_map>
9#include <opencv2/core/types.hpp>
11#include <wpi/StringMap.h>
14template<
typename first_T,
typename second_T>
15using VecMap = std::vector<std::pair<first_T, second_T> >;
17#ifndef CALIB_DEFAULT_FLOAT_TYPE
18#define CALIB_DEFAULT_FLOAT_TYPE float
20#ifndef CALIB_DEFAULT_STRING_TYPE
21#define CALIB_DEFAULT_STRING_TYPE std::string
23#ifndef CALIB_DEFAULT_MAP_TYPE
24#define CALIB_DEFAULT_MAP_TYPE VecMap
26#ifndef CALIB_DEFAULT_SMAP_TYPE
27#define CALIB_DEFAULT_SMAP_TYPE wpi::StringMap
51std::array<cv::Mat_<fp_T>, 2>;
59 using map_T<cv::Size2i, Calibration_<fp_T> >::map_T;
63 template<
class,
class,
class...>
typename M>
67 using Set_T = map_T<cv::Size2i, Calibration_<fp_T> >;
71 template<
class A,
class B>
83 using smap_T<CalibSet_<fp_T, cmap_T> >::smap_T;
87 template<
class,
class,
class...>
typename C,
88 template<
class,
class...>
typename S>
93 using Map_T = smap_T<CalibSet_<fp_T, cmap_T> >;
97 template<
class A,
class B>
111 using nmap_T<str_T, CalibSet_<fp_T, cmap_T> >::nmap_T;
114 typename F,
typename S,
115 template<
class,
class,
class...>
typename C,
116 template<
class,
class...>
typename N>
121 using Map_T = nmap_T<str_T, CalibSet_<fp_T, cmap_T> >;
126 template<
class A,
class B>
128 template<
class A,
class B>
165template<
typename fp_T = CALIB_DEFAULT_FLOAT_TYPE>
208template<
typename num_T =
int>
210 cv::Size_<num_T> ret;
211 size_t a = str.find(
'x');
212 std::from_chars<num_T>(str.data(), str.data() + a, std::ref(ret.width));
213 std::from_chars<num_T>(str.data() + a + 1, str.data() + str.length(), std::ref(ret.height));
218#include <type_traits>
219#include <cpp-tools/src/types.h>
229 static constexpr inline bool
239 template<
class,
class,
class...>
typename cmap_T>
241 static_assert(std::is_floating_point<fp_T>::value,
"Template param error: fp_T must be floating point type.");
250 static constexpr inline bool
255 is_assoc_cmap = any_same_template<cmap_T, std::map, std::unordered_map>::value
260 template<
class,
class,
class...>
typename cmap_T,
261 template<
class,
class...>
typename smap_T>
263 static_assert(std::is_floating_point<fp_T>::value,
"Template param error: fp_T must be floating point type.");
272 static constexpr inline bool
277 is_assoc_cmap = any_same_template<cmap_T, std::map, std::unordered_map>::value
283 template<
class,
class,
class...>
typename cmap_T,
284 template<
class,
class,
class...>
typename nmap_T>
286 static_assert(std::is_floating_point<fp_T>::value,
"Template param error: fp_T must be floating point type.");
295 static constexpr inline bool
298 is_assoc_smap = any_same_template<nmap_T, std::map, std::multimap, std::unordered_map, std::unordered_multimap>::value,
300 is_assoc_cmap = any_same_template<cmap_T, std::map, std::multimap, std::unordered_map, std::unordered_multimap>::value
306template<
typename Map>
307const typename Map::Set_T*
findSet(std::string_view name,
const Map& map) {
308 static_assert(std::is_base_of<__CalibMap, Map>::value,
"Template param error - Map must be CalibMap type.");
310 return wpi_find_set_impl<Map>(name, map);
313 return seq_find_set_impl<Map>(name, map);
316 return assoc_find_set_impl<Map>(name, map);
321template<
typename Set>
322const typename Set::Cal_T*
findCalib(
const cv::Size2i& sz,
const Set& set) {
323 static_assert(std::is_base_of<__CalibSet, Set>::value,
"Template param error - Set must be CalibSet type.");
325 return seq_find_calib_impl<Set>(sz, set);
328 return assoc_find_calib_impl<Set>(sz, set);
332template<
typename Map>
333const typename Map::Cal_T*
findCalib(std::string_view name,
const cv::Size2i& sz,
const Map& map) {
334 static_assert(std::is_base_of<__CalibMap, Map>::value,
"Template param error - Map must be CalibMap type.");
335 if (
auto* set = findSet<Map>(name, map)) {
336 return findCalib<typename Map::Set_T>(sz, *set);
340template<
typename Map>
342 std::initializer_list<std::string_view> names,
const cv::Size2i& sz,
const Map& map
344 static_assert(std::is_base_of<__CalibMap, Map>::value,
"Template param error - Map must be CalibMap type.");
345 for (
auto n : names) {
346 if (
auto* set = findSet<Map>(n, map)) {
347 if (
auto* cal = findCalib<typename Map::Set_T>(sz, *set)) {
356template<
typename Map>
359 auto it = map.find(name);
360 if (it != map.end()) {
365template<
typename Map>
368 for(
auto& set : map) {
369 if(std::string_view(set.first) == name) {
375template<
typename Map>
385template<
typename Set>
388 for (
auto& calib : set) {
389 if (calib.first == sz) {
390 return &calib.second;
395template<
typename Set>
398 auto it = set.find(sz);
399 if (it != set.end()) {
const Map::Set_T * assoc_find_set_impl(std::string_view name, const Map &map)
const Set::Cal_T * findCalib(const cv::Size2i &sz, const Set &set)
const Map::Set_T * findSet(std::string_view name, const Map &map)
const Set::Cal_T * seq_find_calib_impl(const cv::Size2i &sz, const Set &set)
std::array< cv::Mat_< fp_T >, 2 > Calibration_
const Map::Set_T * wpi_find_set_impl(std::string_view name, const Map &map)
std::vector< std::pair< first_T, second_T > > VecMap
const Set::Cal_T * assoc_find_calib_impl(const cv::Size2i &sz, const Set &set)
const Map::Set_T * seq_find_set_impl(std::string_view name, const Map &map)
const Map::Cal_T * findAnyCalib(std::initializer_list< std::string_view > names, const cv::Size2i &sz, const Map &map)
#define CALIB_DEFAULT_FLOAT_TYPE
#define CALIB_DEFAULT_SMAP_TYPE
#define CALIB_DEFAULT_STRING_TYPE
cv::Size_< num_T > extractSize(std::string_view str)
#define CALIB_DEFAULT_MAP_TYPE
Calibration_< fp_T > Cal_T
CALIB_DEFAULT_STRING_TYPE String_T
Calibration_< fp_T > Cal_T
Calibration_< fp_T > Cal_T
static constexpr bool is_seq_smap
static constexpr bool is_seq_cmap
static constexpr bool is_assoc_smap
static constexpr bool is_assoc_cmap
static constexpr bool is_wpi_smap
nmap_T< str_T, CalibSet_< fp_T, cmap_T > > Map_T
Calibration_< fp_T > Cal_T
Calibration_< fp_T > Cal_T
smap_T< CalibSet_< fp_T, cmap_T > > Map_T
map_T< cv::Size2i, Calibration_< fp_T > > Set_T
Calibration_< fp_T > Cal_T