IDSpeakAFL  v1.1.0
peak_afl.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include "peak_afl/peak_afl.h"
14 #include "peak_ipl/types/peak_ipl_image.hpp"
15 #include "peak/node_map/peak_node_map.hpp"
16 
17 #include <type_traits>
18 #include <cstdint>
19 #include <exception>
20 #include <string>
21 #include <tuple>
22 #include <utility>
23 #include <vector>
24 #include <memory>
25 #include <functional>
26 
27 #if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
28 # define PEAK_AFL_NO_DISCARD [[nodiscard]]
29 # define PEAK_AFL_MAYBE_UNUSED [[maybe_unused]]
30 #else
31 # ifdef _MSC_VER
32 # define PEAK_AFL_NO_DISCARD _Check_return_
33 # define PEAK_AFL_MAYBE_UNUSED
34 # elif defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
35 # define PEAK_AFL_NO_DISCARD __attribute__((warn_unused_result))
36 # define PEAK_AFL_MAYBE_UNUSED __attribute__((unused))
37 # else
38 # define PEAK_AFL_NO_DISCARD
39 # define PEAK_AFL_MAYBE_UNUSED
40 # endif
41 #endif
42 
55 namespace peak
56 {
57 namespace afl
58 {
59 namespace library
60 {
61 
66 struct Version_t
67 {
68  std::uint32_t major;
69  std::uint32_t minor;
70  std::uint32_t subminor;
71  std::uint32_t patch;
72 
77  PEAK_AFL_NO_DISCARD std::string ToString() const
78  {
79  return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(subminor) + "."
80  + std::to_string(patch);
81  }
82 
88  PEAK_AFL_NO_DISCARD uint32_t Major() const
89  {
90  return major;
91  }
92 
98  PEAK_AFL_NO_DISCARD uint32_t Minor() const
99  {
100  return minor;
101  }
107  PEAK_AFL_NO_DISCARD uint32_t Subminor() const
108  {
109  return subminor;
110  }
111 
117  PEAK_AFL_NO_DISCARD uint32_t Patch() const
118  {
119  return patch;
120  }
121 };
122 
136 inline void Init();
137 
151 inline void Exit();
152 
160 PEAK_AFL_NO_DISCARD inline std::string GetLastError();
161 
174 PEAK_AFL_NO_DISCARD inline Version_t Version();
175 } // namespace library
176 
177 namespace error
178 {
179 
180 
185 class Exception : public std::exception
186 {
187 public:
188  explicit Exception(peak_afl_status code, bool get_text=true)
189  : m_code(code)
190  {
191  if (get_text)
192  {
193  m_text = library::GetLastError();
194  }
195  }
196 
202  PEAK_AFL_NO_DISCARD peak_afl_status code() const
203  {
204  return m_code;
205  }
206 
212  PEAK_AFL_NO_DISCARD const char* what() const noexcept override
213  {
214  if(m_text.empty())
215  {
216  return "-";
217  }
218  else
219  {
220  return m_text.c_str();
221  }
222  }
223 
231  PEAK_AFL_NO_DISCARD static std::string translateCode(peak_afl_status status)
232  {
233  switch(status)
234  {
236  return "PEAK_AFL_STATUS_SUCCESS";
237 
239  return "PEAK_AFL_STATUS_ERROR";
240 
242  return "PEAK_AFL_STATUS_NOT_INITIALIZED";
243 
245  return "PEAK_AFL_STATUS_INVALID_PARAMETER";
246 
248  return "PEAK_AFL_STATUS_ACCESS_DENIED";
249 
251  return "PEAK_AFL_STATUS_BUSY";
252 
254  return "PEAK_AFL_STATUS_BUFFER_TOO_SMALL";
255 
257  return "PEAK_AFL_STATUS_INVALID_IMAGE_FORMAT";
258 
260  return "PEAK_AFL_STATUS_NOT_SUPPORTED";
261 
262  default:
263  return "Unknown Status code";
264  }
265  }
266 
267 private:
268  peak_afl_status m_code{};
269  std::string m_text{};
270 };
271 } // namespace error
272 
273 class Controller;
274 
279 class Manager
280 {
281 public:
291  inline explicit Manager(const std::shared_ptr<peak::core::NodeMap>& node_map);
292 
296  inline ~Manager();
297 
298  Manager(const Manager&) = delete;
299  inline Manager(Manager&&) noexcept;
300 
301  Manager& operator=(const Manager&) noexcept = delete;
302  inline Manager& operator=(Manager&&) noexcept;
303 
314  inline void AddController(const std::shared_ptr<Controller>& controller);
315 
326  inline void RemoveController(const std::shared_ptr<Controller>& controller);
327 
337  inline void Process(const peak::ipl::Image& img) const;
338 
351  PEAK_AFL_NO_DISCARD inline std::shared_ptr<Controller> CreateController(peak_afl_controllerType type);
352 
360  inline void DestroyAllController();
361 
371  inline void DestroyController(const std::shared_ptr<Controller>& controller);
372 
382  PEAK_AFL_NO_DISCARD inline bool Status() const;
383 
389  PEAK_AFL_NO_DISCARD inline std::vector<std::shared_ptr<Controller>> ControllerList() const;
390 
396  PEAK_AFL_NO_DISCARD inline size_t ControllerCount() const;
397 
407  PEAK_AFL_NO_DISCARD inline std::shared_ptr<Controller> GetController(peak_afl_controllerType type) const;
408 
409 private:
410  std::vector<std::shared_ptr<Controller>> m_controllerList;
411  mutable std::mutex m_mutex{};
412  peak_afl_manager_handle m_handle{};
413 };
414 
424 template<typename... ControllerTypes>
425 std::tuple<Manager, std::vector<std::shared_ptr<Controller>>>
426 CreateManager(const std::shared_ptr<peak::core::NodeMap>& node_map, ControllerTypes... types)
427 {
428  constexpr int size = sizeof...(types);
429  constexpr std::array<peak_afl_controllerType, size> controller_types{types...};
430  std::vector<std::shared_ptr<Controller>> controller{};
431  Manager manager{node_map};
432  controller.reserve(size);
433 
434  std::for_each(controller_types.cbegin(), controller_types.cend(), [&manager, &controller](peak_afl_controllerType type) {
435  controller.emplace_back(std::move(manager.CreateController(type)));
436  });
437 
438  return { std::move(manager), std::move(controller) };
439 }
440 
441 
446 template <typename T, typename std::enable_if_t<std::is_arithmetic<T>::value, int> = 0>
447 struct Range
448 {
449  T min;
450  T max;
451  T inc;
452 };
453 
454 namespace callback
455 {
456 using FinishedCallback = std::function<void(void)>;
457 using DataProcessingCallback = std::function<void(int, int)>;
458 }
459 
464 class Controller : public std::enable_shared_from_this<Controller>
465 {
466  friend class Manager;
467 
468  template<class T, enum peak_afl_callback_type type>
469  class Callback
470  {
471 #ifndef SWIG
472  public:
473  template<typename R, typename ...Args>
474  Callback(const std::shared_ptr<peak::afl::Controller>& controller, std::function<R(Args...)> callback) :
475  m_callback(std::move(callback))
476  {
477  const auto ret = peak_afl_AutoController_Callback_Set(controller->m_handle, type,
478  reinterpret_cast<void*>(&Callback::Func<Args...>), this);
479  if (ret != PEAK_AFL_STATUS_SUCCESS)
480  {
481  throw error::Exception(ret);
482  }
483  m_controller = controller;
484  }
485 
486  virtual ~Callback()
487  {
488  if (auto controller = m_controller.lock())
489  {
490  peak_afl_AutoController_Callback_Set(controller->m_handle, type, nullptr, nullptr);
491  }
492  }
493 
494  private:
495  template<typename ...Args>
496  static void Func(Args&&... args, void* ptr)
497  {
498  static_cast<Callback *>(ptr)->m_callback(std::forward<Args>(args)...);
499  };
500 #endif
501 
502  std::weak_ptr<peak::afl::Controller> m_controller;
503  T m_callback;
504  };
505 
513  inline explicit Controller(peak_afl_controller_handle handle)
514  : m_handle(handle) {};
515 
516 public:
520  inline ~Controller();
521 
522  Controller(const Controller&) = delete;
523  Controller(Controller&&) = delete;
524  Controller& operator=(const Controller&) = delete;
525  Controller& operator=(Controller&&) = delete;
526 
536  PEAK_AFL_NO_DISCARD inline static std::shared_ptr<Controller> Create(peak_afl_controllerType type);
537 
545  PEAK_AFL_NO_DISCARD inline bool IsSkipFramesSupported() const;
546 
556  inline void SetSkipFrames(std::uint32_t count);
557 
567  PEAK_AFL_NO_DISCARD inline std::uint32_t GetSkipFrames() const;
568 
576  PEAK_AFL_NO_DISCARD inline Range<std::uint32_t> GetSkipFramesRange() const;
577 
587  PEAK_AFL_NO_DISCARD inline bool IsROISupported() const;
588 
598  inline void SetROI(peak_afl_rectangle rect);
599 
609  PEAK_AFL_NO_DISCARD inline peak_afl_rectangle GetROI() const;
610 
620  PEAK_AFL_NO_DISCARD inline bool IsROIPresetSupported() const;
621 
631  inline void SetROIPreset(peak_afl_roi_preset preset);
632 
642  PEAK_AFL_NO_DISCARD inline bool IsModeSupported() const;
643 
653  inline void SetMode(peak_afl_controller_automode mode);
654 
662  PEAK_AFL_NO_DISCARD inline peak_afl_controller_automode GetMode() const;
663 
673  PEAK_AFL_NO_DISCARD inline peak_afl_controller_status Status() const;
674 
684  PEAK_AFL_NO_DISCARD inline std::uint8_t GetLastAutoAverage() const;
685 
695  PEAK_AFL_NO_DISCARD inline std::tuple<std::uint8_t, std::uint8_t, std::uint8_t> GetLastAutoAverages() const;
696 
706  PEAK_AFL_NO_DISCARD inline bool IsAutoTargetSupported() const;
707 
718  inline void SetAutoTarget(uint32_t target);
719 
727  PEAK_AFL_NO_DISCARD inline std::uint32_t GetAutoTarget() const;
728 
739  PEAK_AFL_NO_DISCARD inline Range<std::uint32_t> GetAutoTargetRange() const;
740 
750  PEAK_AFL_NO_DISCARD inline bool IsAutoToleranceSupported() const;
751 
761  inline void SetAutoTolerance(std::uint32_t tolerance);
762 
770  PEAK_AFL_NO_DISCARD inline std::uint32_t GetAutoTolerance() const;
771 
782  PEAK_AFL_NO_DISCARD inline Range<std::uint32_t> GetAutoToleranceRange() const;
783 
793  PEAK_AFL_NO_DISCARD inline bool IsAutoPercentileSupported() const;
794 
805  inline void SetAutoPercentile(double tolerance);
806 
814  PEAK_AFL_NO_DISCARD inline double GetAutoPercentile() const;
815 
826  PEAK_AFL_NO_DISCARD inline Range<double> GetAutoPercentileRange() const;
827 
837  PEAK_AFL_NO_DISCARD inline peak_afl_controllerType Type() const;
838 
850  PEAK_AFL_NO_DISCARD inline bool IsAlgorithmSupported() const;
851 
861  inline void SetAlgorithm(peak_afl_controller_algorithm algorithm);
862 
869  PEAK_AFL_NO_DISCARD inline peak_afl_controller_algorithm GetAlgorithm() const;
870 
880  PEAK_AFL_NO_DISCARD inline std::vector<peak_afl_controller_algorithm> GetAlgorithmList() const;
881 
893  PEAK_AFL_NO_DISCARD inline bool IsSharpnessAlgorithmSupported() const;
894 
904  inline void SetSharpnessAlgorithm(peak_afl_controller_sharpness_algorithm algorithm);
905 
913  PEAK_AFL_NO_DISCARD inline peak_afl_controller_sharpness_algorithm GetSharpnessAlgorithm() const;
914 
924  PEAK_AFL_NO_DISCARD inline std::vector<peak_afl_controller_sharpness_algorithm> GetSharpnessAlgorithmList() const;
925 
929  inline void RegisterFinishedCallback(const callback::FinishedCallback& callback);
930 
934  inline void UnRegisterFinishedCallback();
935 
940  inline void RegisterDataProcessingCallback(const callback::DataProcessingCallback& callback);
941 
945  inline void UnRegisterDataProcessingCallback();
946 
956  PEAK_AFL_NO_DISCARD inline bool IsWeightedROISupported() const;
957 
967  inline void SetWeightedROIs(const std::vector<peak_afl_weighted_rectangle>& list);
968 
978  inline void SetWeightedROI(const peak_afl_weighted_rectangle& rect);
979 
987  PEAK_AFL_NO_DISCARD inline peak_afl_size GetWeightedROIMinSize() const;
988 
996  PEAK_AFL_NO_DISCARD inline std::vector<peak_afl_weighted_rectangle> GetWeightedROIs() const;
997 
1007  PEAK_AFL_NO_DISCARD inline bool IsLimitSupported() const;
1008 
1018  inline void SetLimit(peak_afl_controller_limit limit);
1019 
1027  PEAK_AFL_NO_DISCARD inline peak_afl_controller_limit GetLimit() const;
1028 
1036  PEAK_AFL_NO_DISCARD inline peak_afl_controller_limit GetDefaultLimit() const;
1037 
1047  PEAK_AFL_NO_DISCARD inline bool IsHysteresisSupported() const;
1048 
1058  inline void SetHysteresis(std::uint8_t hysteresis);
1059 
1067  PEAK_AFL_NO_DISCARD inline std::uint8_t GetHysteresis() const;
1068 
1076  PEAK_AFL_NO_DISCARD inline std::uint8_t GetDefaultHysteresis() const;
1077 
1085  PEAK_AFL_NO_DISCARD inline Range<std::uint8_t> GetHysteresisRange() const;
1086 
1087 private:
1088  using FinishedCallbackType = Callback<callback::FinishedCallback, PEAK_AFL_CONTROLLER_CALLBACK_FINISHED>;
1089  using DataProcessingCallbackType = Callback<callback::DataProcessingCallback, PEAK_AFL_CONTROLLER_CALLBACK_PROCESSING_DATA>;
1090 
1091  peak_afl_controller_handle m_handle{};
1092  std::unique_ptr<FinishedCallbackType> m_finishedCallback{};
1093  std::unique_ptr<DataProcessingCallbackType> m_dataProcessingCallback{};
1094 };
1095 
1096 namespace library
1097 {
1098 inline void Init()
1099 {
1100  const auto ret = peak_afl_Init();
1101  if (ret != PEAK_AFL_STATUS_SUCCESS)
1102 
1103  {
1104  throw error::Exception(ret, false);
1105  }
1106 }
1107 
1108 inline void Exit()
1109 {
1110  const auto ret = peak_afl_Exit();
1111  if (ret != PEAK_AFL_STATUS_SUCCESS)
1112  {
1113  throw error::Exception(ret, false);
1114  }
1115 }
1116 
1118 {
1119  Version_t version{};
1120 
1121  const auto ret = peak_afl_GetVersion(&version.major, &version.minor, &version.subminor, &version.patch);
1122  if (ret != PEAK_AFL_STATUS_SUCCESS)
1123  {
1124  throw error::Exception(ret, false);
1125  }
1126 
1127  return version;
1128 }
1129 
1130 inline std::string GetLastError()
1131 {
1132  std::size_t lastErrorMessageSize;
1133  peak_afl_status code;
1134 
1135  auto ret = peak_afl_GetLastError(&code, nullptr, &lastErrorMessageSize);
1136  if (ret != PEAK_AFL_STATUS_SUCCESS)
1137  {
1138  return "Cannot get last error!";
1139  }
1140 
1141  std::vector<char> text;
1142  text.resize(lastErrorMessageSize);
1143 
1144  ret = peak_afl_GetLastError(&code, text.data(), &lastErrorMessageSize);
1145  if (ret != PEAK_AFL_STATUS_SUCCESS)
1146  {
1147  return "Cannot get last error!";
1148  }
1149 
1150  return { text.begin(), text.end() };
1151 }
1152 } // namespace library
1153 
1154 inline Manager::Manager(const std::shared_ptr<peak::core::NodeMap>& node_map)
1155 {
1156  if(!node_map)
1157  {
1158  throw std::runtime_error("Invalid node map handle!");
1159  }
1160 
1161  const auto ret = peak_afl_AutoFeatureManager_Create(&m_handle, node_map->Handle());
1162  if (ret != PEAK_AFL_STATUS_SUCCESS)
1163  {
1164  throw error::Exception(ret);
1165  }
1166 }
1167 
1169 {
1170  if (m_handle != nullptr)
1171  {
1173 
1174  {
1175  std::lock_guard<std::mutex> lck(m_mutex);
1176  for (auto& c : m_controllerList)
1177  {
1178  c->m_handle = nullptr;
1179  }
1180  }
1181 
1183  m_handle = nullptr;
1184  }
1185 }
1186 
1187 inline Manager::Manager(Manager&& other) noexcept {
1188  m_handle = other.m_handle;
1189  other.m_handle = nullptr;
1190 
1191  std::lock_guard<std::mutex> lck(other.m_mutex);
1192  m_controllerList = std::move(other.m_controllerList);
1193 }
1194 
1195 inline Manager& Manager::operator=(Manager&& other) noexcept
1196 {
1197  m_handle = other.m_handle;
1198  other.m_handle = nullptr;
1199 
1200  std::lock_guard<std::mutex> lck(other.m_mutex);
1201  m_controllerList = std::move(other.m_controllerList);
1202 
1203  return *this;
1204 }
1205 
1206 inline void Manager::AddController(const std::shared_ptr<Controller>& controller)
1207 {
1208  std::lock_guard<std::mutex> lck(m_mutex);
1209 
1210  auto cnt = std::any_of(m_controllerList.begin(), m_controllerList.end(), [controller](const std::shared_ptr<Controller>& c) {
1211  return c == controller;
1212  });
1213 
1214  if(cnt)
1215  {
1216  return;
1217  }
1218 
1219  const auto ret = peak_afl_AutoFeatureManager_AddController(m_handle, controller->m_handle);
1220  if (ret != PEAK_AFL_STATUS_SUCCESS)
1221  {
1222  throw error::Exception(ret);
1223  }
1224 
1225  m_controllerList.emplace_back(controller);
1226 }
1227 
1228 inline void Manager::RemoveController(const std::shared_ptr<Controller>& controller)
1229 {
1230  std::lock_guard<std::mutex> lck(m_mutex);
1231 
1232  const auto ret = peak_afl_AutoFeatureManager_RemoveController(m_handle, controller->m_handle);
1233  if (ret != PEAK_AFL_STATUS_SUCCESS)
1234  {
1235  throw error::Exception(ret);
1236  }
1237 
1238  auto it = std::remove_if(m_controllerList.begin(), m_controllerList.end(), [controller](const std::shared_ptr<Controller>& c) {
1239  return c == controller;
1240  });
1241 
1242  m_controllerList.erase(it, m_controllerList.end());
1243 }
1244 
1245 inline void Manager::Process(const peak::ipl::Image& img) const
1246 {
1247  const auto ret = peak_afl_AutoFeatureManager_Process(m_handle, ImageBackendAccessor::BackendHandle(img));
1248  if (ret != PEAK_AFL_STATUS_SUCCESS)
1249  {
1250  throw error::Exception(ret);
1251  }
1252 }
1253 
1254 inline std::shared_ptr<Controller> Manager::CreateController(peak_afl_controllerType type)
1255 {
1256  std::lock_guard<std::mutex> lck(m_mutex);
1257 
1258  peak_afl_controller_handle handle{};
1259  const auto ret = peak_afl_AutoFeatureManager_CreateController(m_handle, &handle, type);
1260  if (ret != PEAK_AFL_STATUS_SUCCESS)
1261  {
1262  throw error::Exception(ret);
1263  }
1264 
1265  auto shared = std::shared_ptr<Controller>(new Controller(handle));
1266  m_controllerList.emplace_back(shared);
1267 
1268  return shared;
1269 }
1270 
1272 {
1273  std::lock_guard<std::mutex> lck(m_mutex);
1274 
1275  const auto ret = peak_afl_AutoFeatureManager_DestroyAllController(m_handle);
1276  if (ret != PEAK_AFL_STATUS_SUCCESS)
1277  {
1278  throw error::Exception(ret);
1279  }
1280 
1281  for(auto& c : m_controllerList)
1282  {
1283  c->m_handle = nullptr;
1284  }
1285 
1286  m_controllerList.clear();
1287 }
1288 
1289 inline void Manager::DestroyController(const std::shared_ptr<Controller>& controller)
1290 {
1291  std::lock_guard<std::mutex> lck(m_mutex);
1292 
1293  const auto ret = peak_afl_AutoFeatureManager_DestroyController(m_handle, controller->m_handle);
1294  if (ret != PEAK_AFL_STATUS_SUCCESS)
1295  {
1296  throw error::Exception(ret);
1297  }
1298 
1299  auto it = std::remove_if(m_controllerList.begin(), m_controllerList.end(), [controller](const std::shared_ptr<Controller>& c) {
1300  return c == controller;
1301  });
1302 
1303  m_controllerList.erase(it, m_controllerList.end());
1304 
1305  controller->m_handle = nullptr;
1306 }
1307 
1308 inline bool Manager::Status() const
1309 {
1310  std::uint8_t status;
1311  const auto ret = peak_afl_AutoFeatureManager_Status(m_handle, &status);
1312  if (ret != PEAK_AFL_STATUS_SUCCESS)
1313  {
1314  throw error::Exception(ret);
1315  }
1316 
1317  return status;
1318 }
1319 
1320 inline std::vector<std::shared_ptr<Controller>> Manager::ControllerList() const
1321 {
1322  std::lock_guard<std::mutex> lck(m_mutex);
1323 
1324  std::vector<std::shared_ptr<Controller>> controller{};
1325 
1326  std::copy(m_controllerList.begin(), m_controllerList.end(), controller.begin());
1327 
1328  return controller;
1329 }
1330 
1331 inline size_t Manager::ControllerCount() const
1332 {
1333  return m_controllerList.size();
1334 }
1335 
1336 inline std::shared_ptr<Controller> Manager::GetController(peak_afl_controllerType type) const
1337 {
1338  std::lock_guard<std::mutex> lck(m_mutex);
1339 
1340  auto it = std::find_if(m_controllerList.cbegin(), m_controllerList.cend(), [=](const std::shared_ptr<Controller>& controller) {
1341  return type == controller->Type();
1342  });
1343 
1344  if(it != m_controllerList.cend())
1345  {
1346  return *it;
1347  }
1348  else
1349  {
1351  }
1352 }
1353 
1354 inline std::shared_ptr<Controller> Controller::Create(peak_afl_controllerType type)
1355 {
1356  peak_afl_controller_handle handle{};
1357  const auto ret = peak_afl_AutoController_Create(&handle, type);
1358  if (ret != PEAK_AFL_STATUS_SUCCESS)
1359  {
1360  throw error::Exception(ret);
1361  }
1362 
1363  return std::shared_ptr<Controller>(new Controller(handle));
1364 }
1365 
1367 {
1368  if (m_handle != nullptr)
1369  {
1371  m_handle = nullptr;
1372  }
1373 }
1374 
1376 {
1377  peak_afl_BOOL8 supported{};
1378  const auto ret = peak_afl_AutoController_SkipFrames_IsSupported(m_handle, &supported);
1379  if (ret != PEAK_AFL_STATUS_SUCCESS)
1380  {
1381  throw error::Exception(ret);
1382  }
1383 
1384  return supported;
1385 }
1386 
1387 inline void Controller::SetSkipFrames(std::uint32_t count)
1388 {
1389  const auto ret = peak_afl_AutoController_SkipFrames_Set(m_handle, count);
1390  if (ret != PEAK_AFL_STATUS_SUCCESS)
1391  {
1392  throw error::Exception(ret);
1393  }
1394 }
1395 
1396 inline std::uint32_t Controller::GetSkipFrames() const
1397 {
1398  std::uint32_t count{};
1399  const auto ret = peak_afl_AutoController_SkipFrames_Get(m_handle, &count);
1400  if (ret != PEAK_AFL_STATUS_SUCCESS)
1401  {
1402  throw error::Exception(ret);
1403  }
1404 
1405  return count;
1406 }
1407 
1409 {
1410  Range<std::uint32_t> range{};
1411  const auto ret = peak_afl_AutoController_SkipFrames_GetRange(m_handle, &range.min, &range.max, &range.inc);
1412  if (ret != PEAK_AFL_STATUS_SUCCESS)
1413  {
1414  throw error::Exception(ret);
1415  }
1416 
1417  return range;
1418 }
1419 
1420 inline bool Controller::IsROISupported() const
1421 {
1422  peak_afl_BOOL8 supported{};
1423  const auto ret = peak_afl_AutoController_ROI_IsSupported(m_handle, &supported);
1424  if (ret != PEAK_AFL_STATUS_SUCCESS)
1425  {
1426  throw error::Exception(ret);
1427  }
1428 
1429  return supported;
1430 }
1431 
1433 {
1434  const auto ret = peak_afl_AutoController_ROI_Set(m_handle, rect);
1435  if (ret != PEAK_AFL_STATUS_SUCCESS)
1436  {
1437  throw error::Exception(ret);
1438  }
1439 }
1440 
1442 {
1443  peak_afl_rectangle rect{};
1444  const auto ret = peak_afl_AutoController_ROI_Get(m_handle, &rect);
1445  if (ret != PEAK_AFL_STATUS_SUCCESS)
1446  {
1447  throw error::Exception(ret);
1448  }
1449  return rect;
1450 }
1451 
1453 {
1454  peak_afl_BOOL8 supported{};
1455  const auto ret = peak_afl_AutoController_ROI_Preset_IsSupported(m_handle, &supported);
1456  if (ret != PEAK_AFL_STATUS_SUCCESS)
1457  {
1458  throw error::Exception(ret);
1459  }
1460 
1461  return supported;
1462 }
1463 
1465 {
1466  const auto ret = peak_afl_AutoController_ROI_Preset_Set(m_handle, preset);
1467  if (ret != PEAK_AFL_STATUS_SUCCESS)
1468  {
1469  throw error::Exception(ret);
1470  }
1471 }
1472 
1473 inline bool Controller::IsModeSupported() const
1474 {
1475  peak_afl_BOOL8 supported{};
1476  const auto ret = peak_afl_AutoController_Mode_IsSupported(m_handle, &supported);
1477  if (ret != PEAK_AFL_STATUS_SUCCESS)
1478  {
1479  throw error::Exception(ret);
1480  }
1481 
1482  return supported;
1483 }
1484 
1486 {
1487  const auto ret = peak_afl_AutoController_Mode_Set(m_handle, mode);
1488  if (ret != PEAK_AFL_STATUS_SUCCESS)
1489  {
1490  throw error::Exception(ret);
1491  }
1492 }
1493 
1495 {
1497  const auto ret = peak_afl_AutoController_Mode_Get(m_handle, &mode);
1498  if (ret != PEAK_AFL_STATUS_SUCCESS)
1499  {
1500  throw error::Exception(ret);
1501  }
1502  return mode;
1503 }
1504 
1506 {
1507  peak_afl_controller_status status{};
1508  const auto ret = peak_afl_AutoController_Status(m_handle, &status);
1509  if (ret != PEAK_AFL_STATUS_SUCCESS)
1510  {
1511  throw error::Exception(ret);
1512  }
1513  return status;
1514 }
1515 
1516 
1517 inline std::uint8_t Controller::GetLastAutoAverage() const
1518 {
1519  std::uint8_t average{};
1520  const auto ret = peak_afl_AutoController_GetLastAutoAverage(m_handle, &average);
1521  if (ret != PEAK_AFL_STATUS_SUCCESS)
1522  {
1523  throw error::Exception(ret);
1524  }
1525  return average;
1526 }
1527 
1528 inline std::tuple<std::uint8_t, std::uint8_t, std::uint8_t> Controller::GetLastAutoAverages() const
1529 {
1530  std::uint8_t averageRed{}, averageGreen{}, averageBlue{};
1531  const auto ret = peak_afl_AutoController_GetLastAutoAverages(m_handle, &averageRed, &averageGreen, &averageBlue);
1532  if (ret != PEAK_AFL_STATUS_SUCCESS)
1533  {
1534  throw error::Exception(ret);
1535  }
1536  return { averageRed, averageGreen, averageBlue };
1537 }
1538 
1540 {
1541  peak_afl_BOOL8 supported{};
1542  const auto ret = peak_afl_AutoController_AutoTarget_IsSupported(m_handle, &supported);
1543  if (ret != PEAK_AFL_STATUS_SUCCESS)
1544  {
1545  throw error::Exception(ret);
1546  }
1547 
1548  return supported;
1549 }
1550 
1551 inline void Controller::SetAutoTarget(std::uint32_t target)
1552 {
1553  const auto ret = peak_afl_AutoController_AutoTarget_Set(m_handle, target);
1554  if (ret != PEAK_AFL_STATUS_SUCCESS)
1555  {
1556  throw error::Exception(ret);
1557  }
1558 }
1559 
1560 inline std::uint32_t Controller::GetAutoTarget() const
1561 {
1562  std::uint32_t target{};
1563  const auto ret = peak_afl_AutoController_AutoTarget_Get(m_handle, &target);
1564  if (ret != PEAK_AFL_STATUS_SUCCESS)
1565  {
1566  throw error::Exception(ret);
1567  }
1568  return target;
1569 }
1570 
1572 {
1573  Range<std::uint32_t> range{};
1574  const auto ret = peak_afl_AutoController_AutoTarget_GetRange(m_handle, &range.min, &range.max, &range.inc);
1575  if (ret != PEAK_AFL_STATUS_SUCCESS)
1576  {
1577  throw error::Exception(ret);
1578  }
1579  return range;
1580 }
1581 
1583 {
1584  peak_afl_BOOL8 supported{};
1585  const auto ret = peak_afl_AutoController_AutoTolerance_IsSupported(m_handle, &supported);
1586  if (ret != PEAK_AFL_STATUS_SUCCESS)
1587  {
1588  throw error::Exception(ret);
1589  }
1590 
1591  return supported;
1592 }
1593 
1594 inline void Controller::SetAutoTolerance(uint32_t tolerance)
1595 {
1596  const auto ret = peak_afl_AutoController_AutoTolerance_Set(m_handle, tolerance);
1597  if (ret != PEAK_AFL_STATUS_SUCCESS)
1598  {
1599  throw error::Exception(ret);
1600  }
1601 }
1602 
1603 inline uint32_t Controller::GetAutoTolerance() const
1604 {
1605  std::uint32_t tolerance;
1606  const auto ret = peak_afl_AutoController_AutoTarget_Get(m_handle, &tolerance);
1607  if (ret != PEAK_AFL_STATUS_SUCCESS)
1608  {
1609  throw error::Exception(ret);
1610  }
1611  return tolerance;
1612 }
1613 
1615 {
1616  Range<uint32_t> range{};
1617  const auto ret = peak_afl_AutoController_AutoTolerance_GetRange(m_handle, &range.min, &range.max, &range.inc);
1618  if (ret != PEAK_AFL_STATUS_SUCCESS)
1619  {
1620  throw error::Exception(ret);
1621  }
1622  return range;
1623 }
1624 
1626 {
1627  peak_afl_BOOL8 supported{};
1628  const auto ret = peak_afl_AutoController_AutoPercentile_IsSupported(m_handle, &supported);
1629  if (ret != PEAK_AFL_STATUS_SUCCESS)
1630  {
1631  throw error::Exception(ret);
1632  }
1633 
1634  return supported;
1635 }
1636 
1637 inline void Controller::SetAutoPercentile(double tolerance)
1638 {
1639  const auto ret = peak_afl_AutoController_AutoPercentile_Set(m_handle, tolerance);
1640  if (ret != PEAK_AFL_STATUS_SUCCESS)
1641  {
1642  throw error::Exception(ret);
1643  }
1644 }
1645 
1646 inline double Controller::GetAutoPercentile() const
1647 {
1648  double tolerance;
1649  const auto ret = peak_afl_AutoController_AutoPercentile_Get(m_handle, &tolerance);
1650  if (ret != PEAK_AFL_STATUS_SUCCESS)
1651  {
1652  throw error::Exception(ret);
1653  }
1654  return tolerance;
1655 }
1656 
1658 {
1659  Range<double> range{};
1660  const auto ret = peak_afl_AutoController_AutoPercentile_GetRange(m_handle, &range.min, &range.max, &range.inc);
1661  if (ret != PEAK_AFL_STATUS_SUCCESS)
1662  {
1663  throw error::Exception(ret);
1664  }
1665  return range;
1666 }
1667 
1669 {
1670  peak_afl_controllerType type{};
1671  const auto ret = peak_afl_AutoController_Type_Get(m_handle, &type);
1672  if (ret != PEAK_AFL_STATUS_SUCCESS)
1673  {
1674  throw error::Exception(ret);
1675  }
1676  return type;
1677 }
1678 
1680 {
1681  peak_afl_BOOL8 supported{};
1682  const auto ret = peak_afl_AutoController_Algorithm_IsSupported(m_handle, &supported);
1683  if (ret != PEAK_AFL_STATUS_SUCCESS)
1684  {
1685  throw error::Exception(ret);
1686  }
1687 
1688  return supported;
1689 }
1690 
1692 {
1693  const auto ret = peak_afl_AutoController_Algorithm_Set(m_handle, alg);
1694  if (ret != PEAK_AFL_STATUS_SUCCESS)
1695  {
1696  throw error::Exception(ret);
1697  }
1698 }
1699 
1701 {
1703  const auto ret = peak_afl_AutoController_Algorithm_Get(m_handle, &alg);
1704  if (ret != PEAK_AFL_STATUS_SUCCESS)
1705  {
1706  throw error::Exception(ret);
1707  }
1708 
1709  return alg;
1710 }
1711 
1712 inline std::vector<peak_afl_controller_algorithm> Controller::GetAlgorithmList() const
1713 {
1714  std::vector<peak_afl_controller_algorithm> algList{};
1715  std::uint32_t listSize{};
1716 
1717  auto ret = peak_afl_AutoController_Algorithm_GetList(m_handle, nullptr, &listSize);
1718  if (ret != PEAK_AFL_STATUS_SUCCESS)
1719  {
1720  throw error::Exception(ret);
1721  }
1722 
1723  algList.resize(listSize);
1724 
1725  ret = peak_afl_AutoController_Algorithm_GetList(m_handle, algList.data(), &listSize);
1726  if (ret != PEAK_AFL_STATUS_SUCCESS)
1727  {
1728  throw error::Exception(ret);
1729  }
1730 
1731  return algList;
1732 }
1733 
1735 {
1736  peak_afl_BOOL8 supported{};
1737  const auto ret = peak_afl_AutoController_SharpnessAlgorithm_IsSupported(m_handle, &supported);
1738  if (ret != PEAK_AFL_STATUS_SUCCESS)
1739  {
1740  throw error::Exception(ret);
1741  }
1742 
1743  return supported;
1744 }
1745 
1747 {
1748  const auto ret = peak_afl_AutoController_SharpnessAlgorithm_Set(m_handle, alg);
1749  if (ret != PEAK_AFL_STATUS_SUCCESS)
1750  {
1751  throw error::Exception(ret);
1752  }
1753 }
1754 
1756 {
1758  const auto ret = peak_afl_AutoController_SharpnessAlgorithm_Get(m_handle, &alg);
1759  if (ret != PEAK_AFL_STATUS_SUCCESS)
1760  {
1761  throw error::Exception(ret);
1762  }
1763 
1764  return alg;
1765 }
1766 
1767 inline std::vector<peak_afl_controller_sharpness_algorithm> Controller::GetSharpnessAlgorithmList() const
1768 {
1769  std::vector<peak_afl_controller_sharpness_algorithm> algList{};
1770  std::uint32_t listSize{};
1771 
1772  auto ret = peak_afl_AutoController_SharpnessAlgorithm_GetList(m_handle, nullptr, &listSize);
1773  if (ret != PEAK_AFL_STATUS_SUCCESS)
1774  {
1775  throw error::Exception(ret);
1776  }
1777 
1778  algList.resize(listSize);
1779 
1780  ret = peak_afl_AutoController_SharpnessAlgorithm_GetList(m_handle, algList.data(), &listSize);
1781  if (ret != PEAK_AFL_STATUS_SUCCESS)
1782  {
1783  throw error::Exception(ret);
1784  }
1785 
1786  return algList;
1787 }
1788 
1789 inline void Controller::RegisterFinishedCallback(const callback::FinishedCallback& callback)
1790 {
1791  m_finishedCallback = std::make_unique<FinishedCallbackType>(shared_from_this(), callback);
1792 }
1793 
1795 {
1796  m_finishedCallback.reset();
1797 }
1798 
1799 inline void Controller::RegisterDataProcessingCallback(const callback::DataProcessingCallback& callback)
1800 {
1801  m_dataProcessingCallback = std::make_unique<DataProcessingCallbackType>(shared_from_this(), callback);
1802 }
1803 
1805 {
1806  m_dataProcessingCallback.reset();
1807 }
1808 
1810 {
1811  peak_afl_BOOL8 supported{};
1812  const auto ret = peak_afl_AutoController_Weighted_ROI_IsSupported(m_handle, &supported);
1813  if (ret != PEAK_AFL_STATUS_SUCCESS)
1814  {
1815  throw error::Exception(ret);
1816  }
1817 
1818  return supported;
1819 }
1820 
1821 inline void Controller::SetWeightedROIs(const std::vector<peak_afl_weighted_rectangle>& list)
1822 {
1823  const auto ret = peak_afl_AutoController_Weighted_ROI_Set(m_handle, list.data(), static_cast<uint32_t>(list.size()));
1824  if (ret != PEAK_AFL_STATUS_SUCCESS)
1825  {
1826  throw error::Exception(ret);
1827  }
1828 }
1829 
1831 {
1832  const auto ret = peak_afl_AutoController_Weighted_ROI_Set(m_handle, &rect, 1);
1833  if (ret != PEAK_AFL_STATUS_SUCCESS)
1834  {
1835  throw error::Exception(ret);
1836  }
1837 }
1838 
1840 {
1841  peak_afl_size minSize{};
1842  const auto ret = peak_afl_AutoController_Weighted_ROI_Min_Size(m_handle, &minSize);
1843  if (ret != PEAK_AFL_STATUS_SUCCESS)
1844  {
1845  throw error::Exception(ret);
1846  }
1847  return minSize;
1848 }
1849 
1850 inline std::vector<peak_afl_weighted_rectangle> Controller::GetWeightedROIs() const
1851 {
1852  std::vector<peak_afl_weighted_rectangle> list;
1853  std::uint32_t listSize{};
1854 
1855  auto ret = peak_afl_AutoController_Weighted_ROI_Get(m_handle, nullptr, &listSize);
1856  if (ret != PEAK_AFL_STATUS_SUCCESS)
1857  {
1858  throw error::Exception(ret);
1859  }
1860 
1861  list.resize(listSize);
1862 
1863  ret = peak_afl_AutoController_Weighted_ROI_Get(m_handle, list.data(), &listSize);
1864  if (ret != PEAK_AFL_STATUS_SUCCESS)
1865  {
1866  throw error::Exception(ret);
1867  }
1868 
1869  return list;
1870 }
1871 
1872 inline bool Controller::IsLimitSupported() const
1873 {
1874  peak_afl_BOOL8 supported{};
1875  const auto ret = peak_afl_AutoController_Limit_IsSupported(m_handle, &supported);
1876  if (ret != PEAK_AFL_STATUS_SUCCESS)
1877  {
1878  throw error::Exception(ret);
1879  }
1880 
1881  return supported;
1882 }
1883 
1885 {
1886  const auto ret = peak_afl_AutoController_Limit_Set(m_handle, limit);
1887  if (ret != PEAK_AFL_STATUS_SUCCESS)
1888  {
1889  throw error::Exception(ret);
1890  }
1891 }
1892 
1894 {
1895  peak_afl_controller_limit limit{};
1896  const auto ret = peak_afl_AutoController_Limit_Get(m_handle, &limit);
1897  if (ret != PEAK_AFL_STATUS_SUCCESS)
1898  {
1899  throw error::Exception(ret);
1900  }
1901  return limit;
1902 }
1903 
1905 {
1906  peak_afl_controller_limit limit{};
1907  const auto ret = peak_afl_AutoController_Limit_Default(m_handle, &limit);
1908  if (ret != PEAK_AFL_STATUS_SUCCESS)
1909  {
1910  throw error::Exception(ret);
1911  }
1912  return limit;
1913 }
1914 
1916 {
1917  peak_afl_BOOL8 supported{};
1918  const auto ret = peak_afl_AutoController_Hysteresis_IsSupported(m_handle, &supported);
1919  if (ret != PEAK_AFL_STATUS_SUCCESS)
1920  {
1921  throw error::Exception(ret);
1922  }
1923 
1924  return supported;
1925 }
1926 
1927 inline void Controller::SetHysteresis(std::uint8_t hysteresis)
1928 {
1929  const auto ret = peak_afl_AutoController_Hysteresis_Set(m_handle, hysteresis);
1930  if (ret != PEAK_AFL_STATUS_SUCCESS)
1931  {
1932  throw error::Exception(ret);
1933  }
1934 }
1935 
1936 inline std::uint8_t Controller::GetHysteresis() const
1937 {
1938  std::uint8_t hysteresis{};
1939  const auto ret = peak_afl_AutoController_Hysteresis_Get(m_handle, &hysteresis);
1940  if (ret != PEAK_AFL_STATUS_SUCCESS)
1941  {
1942  throw error::Exception(ret);
1943  }
1944 
1945  return hysteresis;
1946 }
1947 
1948 inline std::uint8_t Controller::GetDefaultHysteresis() const
1949 {
1950  std::uint8_t hysteresis{};
1951  const auto ret = peak_afl_AutoController_Hysteresis_Default(m_handle, &hysteresis);
1952  if (ret != PEAK_AFL_STATUS_SUCCESS)
1953  {
1954  throw error::Exception(ret);
1955  }
1956 
1957  return hysteresis;
1958 }
1959 
1961 {
1962  Range<std::uint8_t> hysteresis{};
1964  m_handle, &hysteresis.min, &hysteresis.max, &hysteresis.inc);
1965  if (ret != PEAK_AFL_STATUS_SUCCESS)
1966  {
1967  throw error::Exception(ret);
1968  }
1969 
1970  return hysteresis;
1971 }
1972 
1973 } /* namespace afl */
1974 } /* namespace peak */
peak_afl_status peak_afl_GetVersion(uint32_t *majorVersion, uint32_t *minorVersion, uint32_t *subminorVersion, uint32_t *patchVersion)
Query the library version.
std::vector< std::shared_ptr< Controller > > ControllerList() const
Get the list of the controller associated with the manager.
Definition: peak_afl.hpp:1320
peak_afl_status peak_afl_AutoController_SharpnessAlgorithm_Get(peak_afl_controller_handle controller, peak_afl_controller_sharpness_algorithm *algorithm)
Get the used sharpness algorithm for a controller.
peak_afl_status peak_afl_AutoFeatureManager_AddController(peak_afl_manager_handle handle, peak_afl_manager_handle controller)
Add a controller to an automanager instance.
peak_afl_controller_algorithm GetAlgorithm() const
Get the used algorithm for a controller.
Definition: peak_afl.hpp:1700
~Controller()
Definition: peak_afl.hpp:1366
Range< std::uint8_t > GetHysteresisRange() const
Get autofeature hysteresis range for a controller.
Definition: peak_afl.hpp:1960
std::vector< peak_afl_controller_algorithm > GetAlgorithmList() const
Get the list of supported algorithms for a controller.
Definition: peak_afl.hpp:1712
void SetWeightedROIs(const std::vector< peak_afl_weighted_rectangle > &list)
Set the autofeature weighted region of interest for a controller.
Definition: peak_afl.hpp:1821
void SetHysteresis(std::uint8_t hysteresis)
Set the autofeature hysteresis for a controller.
Definition: peak_afl.hpp:1927
peak_afl_status peak_afl_AutoController_SkipFrames_Get(peak_afl_controller_handle controller, uint32_t *count)
Get number of frames skipped for a controller.
peak_afl_status peak_afl_AutoController_SkipFrames_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
Check if skip frames is supported for a controller.
peak_afl_controller_sharpness_algorithm
controller sharpness algorithm (focus)
Definition: peak_afl.h:199
peak_afl_status peak_afl_AutoController_AutoPercentile_GetRange(peak_afl_controller_handle controller, double *min, double *max, double *inc)
Get the auto percentile range for a controller.
size_t ControllerCount() const
Get the list count of the controller associated with the manager.
Definition: peak_afl.hpp:1331
peak_afl_status peak_afl_AutoController_SkipFrames_Set(peak_afl_controller_handle controller, uint32_t count)
Set number of frames skipped for a controller.
bool IsAlgorithmSupported() const
check if setting an algorithm is supported for a controller.
Definition: peak_afl.hpp:1679
peak_afl_status peak_afl_AutoController_Limit_Default(peak_afl_controller_handle controller, peak_afl_controller_limit *limit)
Get the autofeature default limit.
peak_afl_status peak_afl_AutoController_Algorithm_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
check if setting an algorithm is supported for a controller.
peak_afl_status peak_afl_AutoController_ROI_Get(peak_afl_controller_handle controller, peak_afl_rectangle *roi)
Get the autofeature region of interest for a controller.
void Exit()
Exit the peak_afl auto feature library.
Definition: peak_afl.hpp:1108
peak_afl_status peak_afl_AutoController_Algorithm_Get(peak_afl_controller_handle controller, peak_afl_controller_algorithm *algorithm)
Get the used algorithm for a controller.
peak_afl_status peak_afl_AutoController_Weighted_ROI_Get(peak_afl_controller_handle controller, peak_afl_weighted_rectangle *weightedRoiList, uint32_t *listSize)
Get the autofeature weighted region of interest for a controller.
peak_afl_status peak_afl_AutoFeatureManager_Status(peak_afl_manager_handle handle, peak_afl_BOOL8 *running)
Get the status of a manager.
std::shared_ptr< Controller > GetController(peak_afl_controllerType type) const
Get the controller for a type.
Definition: peak_afl.hpp:1336
peak_afl_controller_limit GetLimit() const
Get the autofeature limit for a controller.
Definition: peak_afl.hpp:1893
Library not Initialized.
Definition: peak_afl.h:95
peak_afl_status
peak_afl Status codes
Definition: peak_afl.h:86
Definition: peak_afl.hpp:55
std::uint8_t GetDefaultHysteresis() const
Get the autofeature hysteresis default.
Definition: peak_afl.hpp:1948
peak_afl Size (2D)
Definition: peak_afl.h:270
void Init()
Init the peak_afl auto feature library.
Definition: peak_afl.hpp:1098
std::uint32_t GetAutoTarget() const
Get the currently set auto target for a controller.
Definition: peak_afl.hpp:1560
peak_afl_status peak_afl_AutoController_Mode_Get(peak_afl_controller_handle controller, peak_afl_controller_automode *mode)
Get the current autofeature mode for a controller.
std::string GetLastError()
Get the last error message.
Definition: peak_afl.hpp:1130
void SetAutoTolerance(std::uint32_t tolerance)
Set the auto tolerance for a controller.
Definition: peak_afl.hpp:1594
Error.
Definition: peak_afl.h:92
uint32_t Patch() const
Returns the patch part of the version which is the fourth part of the version scheme separated by dot...
Definition: peak_afl.hpp:117
std::uint8_t GetHysteresis() const
Get the autofeature hysteresis for a controller.
Definition: peak_afl.hpp:1936
void SetWeightedROI(const peak_afl_weighted_rectangle &rect)
Set single autofeature weighted region of interest for a controller.
Definition: peak_afl.hpp:1830
void RegisterDataProcessingCallback(const callback::DataProcessingCallback &callback)
Set the data callback for a controller.
Definition: peak_afl.hpp:1799
void SetAutoPercentile(double tolerance)
Set the auto percentile for a controller.
Definition: peak_afl.hpp:1637
peak_afl_status peak_afl_AutoController_ROI_Set(peak_afl_controller_handle controller, peak_afl_rectangle roi)
Set the autofeature region of interest for a controller.
peak_afl_status peak_afl_AutoController_Weighted_ROI_Set(peak_afl_controller_handle controller, const peak_afl_weighted_rectangle *weightedRoiList, uint32_t listSize)
Set the autofeature weighted region of interest for a controller.
peak_afl_status peak_afl_AutoController_Limit_Get(peak_afl_controller_handle controller, peak_afl_controller_limit *limit)
Get the autofeature limit for a controller.
uint32_t Minor() const
Returns the minor part of the version which is the second part of the version scheme separated by dot...
Definition: peak_afl.hpp:98
Invalid image format.
Definition: peak_afl.h:110
void UnRegisterFinishedCallback()
Reset the finished callback for a controller.
Definition: peak_afl.hpp:1794
peak_afl Rectangle (2D)
Definition: peak_afl.h:304
peak_afl_status peak_afl_AutoController_Callback_Set(peak_afl_controller_handle controller, peak_afl_callback_type type, void *funcPtr, void *context)
Set a callback for a controller.
peak_afl_status peak_afl_AutoController_GetLastAutoAverages(peak_afl_controller_handle controller, uint8_t *averageRed, uint8_t *averageGreen, uint8_t *averageBlue)
Get the last auto average for a controller.
std::vector< peak_afl_controller_sharpness_algorithm > GetSharpnessAlgorithmList() const
Get the list of supported sharpness algorithms for a controller.
Definition: peak_afl.hpp:1767
void SetAutoTarget(uint32_t target)
Set the auto target for a controller.
Definition: peak_afl.hpp:1551
peak_afl_status peak_afl_AutoController_Mode_Set(peak_afl_controller_handle controller, peak_afl_controller_automode mode)
Set the autofeature mode for a controller.
peak_afl_status peak_afl_AutoController_SharpnessAlgorithm_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
check setting a sharpness algorithm is supported by a controller.
peak_afl_status peak_afl_AutoController_Type_Get(peak_afl_controller_handle controller, peak_afl_controllerType *type)
Get the controller type.
peak_afl_status peak_afl_AutoController_AutoPercentile_Get(peak_afl_controller_handle controller, double *percentile)
Get the auto percentile for a controller.
std::uint32_t patch
Subminor.
Definition: peak_afl.hpp:71
peak_afl_status peak_afl_AutoController_ROI_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
Check if setting a region of interest is supported for a controller.
peak_afl Focus Limit
Definition: peak_afl.h:342
void SetSharpnessAlgorithm(peak_afl_controller_sharpness_algorithm algorithm)
Set the used sharpness algorithm for a controller.
Definition: peak_afl.hpp:1746
void SetAlgorithm(peak_afl_controller_algorithm algorithm)
Set the used algorithm for a controller.
Definition: peak_afl.hpp:1691
bool IsWeightedROISupported() const
Check if weighted region of interest is supported for a controller.
Definition: peak_afl.hpp:1809
std::uint32_t GetSkipFrames() const
Get number of frames skipped for a controller.
Definition: peak_afl.hpp:1396
peak_afl_status peak_afl_AutoController_Weighted_ROI_Min_Size(peak_afl_controller_handle controller, peak_afl_size *size)
Get the autofeature minimum size of weighted region of interest for a controller. ...
std::string ToString() const
Patch.
Definition: peak_afl.hpp:77
std::uint32_t subminor
Minor.
Definition: peak_afl.hpp:70
peak_afl_status peak_afl_AutoFeatureManager_Destroy(peak_afl_manager_handle handle)
Destroy an automanager instance.
peak_afl_status peak_afl_AutoFeatureManager_RemoveController(peak_afl_manager_handle handle, peak_afl_manager_handle controller)
Remove a controller to an automanager instance.
void SetROIPreset(peak_afl_roi_preset preset)
Set the autofeature region of interest preset for a controller.
Definition: peak_afl.hpp:1464
peak_afl_status peak_afl_AutoController_AutoTarget_GetRange(peak_afl_controller_handle controller, uint32_t *min, uint32_t *max, uint32_t *inc)
Get the auto target range for a controller.
peak_afl_roi_preset
controller roi preset
Definition: peak_afl.h:256
peak_afl_status peak_afl_AutoController_Limit_Set(peak_afl_controller_handle controller, peak_afl_controller_limit limit)
Set the autofeature limit for a controller.
void RegisterFinishedCallback(const callback::FinishedCallback &callback)
Set finished callback for a controller.
Definition: peak_afl.hpp:1789
peak_afl_controller_automode
controller automode
Definition: peak_afl.h:133
std::vector< peak_afl_weighted_rectangle > GetWeightedROIs() const
Get the autofeature weighted region of interest for a controller.
Definition: peak_afl.hpp:1850
Definition: peak_afl.hpp:464
peak_afl_controller_automode GetMode() const
Get the current autofeature mode for a controller.
Definition: peak_afl.hpp:1494
void SetSkipFrames(std::uint32_t count)
Set number of frames skipped for a controller.
Definition: peak_afl.hpp:1387
void SetROI(peak_afl_rectangle rect)
Set the autofeature region of interest for a controller.
Definition: peak_afl.hpp:1432
peak_afl_status peak_afl_AutoController_SkipFrames_GetRange(peak_afl_controller_handle controller, uint32_t *min, uint32_t *max, uint32_t *inc)
Get range for frames skipped for a controller.
static std::shared_ptr< Controller > Create(peak_afl_controllerType type)
Create a new controller.
Definition: peak_afl.hpp:1354
uint8_t peak_afl_BOOL8
custom boolean type
Definition: peak_afl.h:352
peak_afl_status peak_afl_AutoFeatureManager_CreateController(peak_afl_manager_handle handle, peak_afl_controller_handle *controller, peak_afl_controllerType controllerType)
Create a controller and append it to Manager.
void * peak_afl_manager_handle
opaque manager handle type
Definition: peak_afl.h:50
Success.
Definition: peak_afl.h:89
bool IsModeSupported() const
Check if auto mode is supported for a controller.
Definition: peak_afl.hpp:1473
std::uint32_t GetAutoTolerance() const
Get the current auto tolerance for a controller.
Definition: peak_afl.hpp:1603
Definition: peak_afl.hpp:66
bool IsAutoToleranceSupported() const
check if auto tolerance is supported for a controller.
Definition: peak_afl.hpp:1582
peak_afl_rectangle GetROI() const
Get the autofeature region of interest for a controller.
Definition: peak_afl.hpp:1441
peak_afl_status peak_afl_AutoController_Hysteresis_GetRange(peak_afl_controller_handle controller, uint8_t *min, uint8_t *max, uint8_t *inc)
Get autofeature hysteresis range for a controller.
peak_afl_status peak_afl_AutoFeatureManager_DestroyAllController(peak_afl_manager_handle handle)
Destroy all controllers for a manager.
peak_afl_status peak_afl_AutoController_AutoTarget_Set(peak_afl_controller_handle controller, uint32_t target)
Set the auto target for a controller.
std::tuple< Manager, std::vector< std::shared_ptr< Controller > > > CreateManager(const std::shared_ptr< peak::core::NodeMap > &node_map, ControllerTypes... types)
Convenience function to create a manager with the supplied controllers.
Definition: peak_afl.hpp:426
bool IsSharpnessAlgorithmSupported() const
check setting a sharpness algorithm is supported by a controller.
Definition: peak_afl.hpp:1734
peak_afl_status peak_afl_Init(void)
Init the peak_afl auto feature library.
peak_afl_status peak_afl_AutoController_SharpnessAlgorithm_Set(peak_afl_controller_handle controller, peak_afl_controller_sharpness_algorithm algorithm)
Set the used sharpness algorithm for a controller.
peak_afl_status peak_afl_AutoController_GetLastAutoAverage(peak_afl_controller_handle controller, uint8_t *average)
Get the last auto average for a controller.
peak_afl_controller_algorithm
controller algorithm
Definition: peak_afl.h:177
std::tuple< std::uint8_t, std::uint8_t, std::uint8_t > GetLastAutoAverages() const
Get the last auto average for a controller.
Definition: peak_afl.hpp:1528
uint32_t Major() const
Returns the major part of the version which is the first part of the version scheme separated by dots...
Definition: peak_afl.hpp:88
Not supported.
Definition: peak_afl.h:113
Version_t Version()
Query the library version.
Definition: peak_afl.hpp:1117
peak_afl_status peak_afl_Exit(void)
Exit the peak_afl auto feature library.
peak_afl_status peak_afl_AutoController_AutoTolerance_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
check if auto tolerance is supported for a controller.
peak_afl_status peak_afl_AutoController_ROI_Preset_Set(peak_afl_controller_handle controller, peak_afl_roi_preset roiPreset)
Set the autofeature region of interest preset for a controller.
peak_afl_status peak_afl_AutoController_ROI_Preset_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
Check if ROI preset is supported for a controller.
peak_afl_controllerType Type() const
Get the controller type.
Definition: peak_afl.hpp:1668
std::uint8_t GetLastAutoAverage() const
Get the last auto average for a controller.
Definition: peak_afl.hpp:1517
bool IsAutoTargetSupported() const
check if auto target is supported for a controller.
Definition: peak_afl.hpp:1539
peak_afl_status peak_afl_AutoController_AutoTarget_Get(peak_afl_controller_handle controller, uint32_t *target)
Get the currently set auto target for a controller.
std::shared_ptr< Controller > CreateController(peak_afl_controllerType type)
Create a controller and append it to Manager.
Definition: peak_afl.hpp:1254
peak_afl_status peak_afl_AutoController_Destroy(peak_afl_controller_handle controller)
Destroy a controller. Will fail if it is queued inside a manager.
Manager(const std::shared_ptr< peak::core::NodeMap > &node_map)
Create an automanager instance.
Definition: peak_afl.hpp:1154
Definition: peak_afl.hpp:447
Range< std::uint32_t > GetAutoTargetRange() const
Get the auto target range for a controller.
Definition: peak_afl.hpp:1571
void RemoveController(const std::shared_ptr< Controller > &controller)
Remove a controller from an automanager.
Definition: peak_afl.hpp:1228
peak_afl_controller_sharpness_algorithm GetSharpnessAlgorithm() const
Get the used sharpness algorithm for a controller.
Definition: peak_afl.hpp:1755
peak_afl_status peak_afl_AutoFeatureManager_Create(peak_afl_manager_handle *handle, PEAK_NODE_MAP_HANDLE nodeMapHandle)
Create an automanager instance.
void Process(const peak::ipl::Image &img) const
Process an image.
Definition: peak_afl.hpp:1245
peak_afl_status peak_afl_AutoController_AutoTarget_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
check if auto target is supported for a controller.
bool IsROISupported() const
Check if setting a region of interest is supported for a controller.
Definition: peak_afl.hpp:1420
bool IsHysteresisSupported() const
Check if hysteresis is supported for a controller.
Definition: peak_afl.hpp:1915
void UnRegisterDataProcessingCallback()
Reset the finished callback for a controller.
Definition: peak_afl.hpp:1804
Definition: peak_afl.hpp:185
peak_afl_status peak_afl_AutoController_Algorithm_Set(peak_afl_controller_handle controller, peak_afl_controller_algorithm algorithm)
Set the used algorithm for a controller.
Definition: peak_afl.hpp:279
peak_afl_controller_limit GetDefaultLimit() const
Get the autofeature default limit.
Definition: peak_afl.hpp:1904
bool IsLimitSupported() const
Check if limit is supported for a controller.
Definition: peak_afl.hpp:1872
peak_afl_controller_status Status() const
Get the status for a controller.
Definition: peak_afl.hpp:1505
peak_afl_status peak_afl_AutoController_AutoPercentile_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
check if auto percentile is supported for a controller.
Access Denied.
Definition: peak_afl.h:101
peak_afl_status peak_afl_AutoController_Limit_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
Check if limit is supported for a controller.
void SetMode(peak_afl_controller_automode mode)
Set the autofeature mode for a controller.
Definition: peak_afl.hpp:1485
void DestroyController(const std::shared_ptr< Controller > &controller)
Destroy a controller.
Definition: peak_afl.hpp:1289
peak_afl_status peak_afl_AutoController_Status(peak_afl_controller_handle controller, peak_afl_controller_status *status)
Get the status for a controller.
Buffer too small.
Definition: peak_afl.h:107
Range< std::uint32_t > GetSkipFramesRange() const
Get range for frames skipped for a controller.
Definition: peak_afl.hpp:1408
peak_afl_status peak_afl_AutoController_Hysteresis_Default(peak_afl_controller_handle controller, uint8_t *hysteresis)
Get the autofeature hysteresis default.
std::uint32_t minor
Major.
Definition: peak_afl.hpp:69
peak_afl_status peak_afl_AutoController_AutoTolerance_Set(peak_afl_controller_handle controller, uint32_t tolerance)
Set the auto tolerance for a controller.
bool IsROIPresetSupported() const
Check if ROI preset is supported for a controller.
Definition: peak_afl.hpp:1452
void SetLimit(peak_afl_controller_limit limit)
Set the autofeature limit for a controller.
Definition: peak_afl.hpp:1884
peak_afl Focus Rectangle
Definition: peak_afl.h:326
peak_afl_status peak_afl_AutoController_SharpnessAlgorithm_GetList(peak_afl_controller_handle controller, peak_afl_controller_sharpness_algorithm *typeList, uint32_t *listSize)
Get the list of supported sharpness algorithms for a controller.
peak_afl_size GetWeightedROIMinSize() const
Get the autofeature minimum size of weighted region of interest for a controller. ...
Definition: peak_afl.hpp:1839
uint32_t Subminor() const
Returns the subminor part of the version which is the third part of the version scheme separated by d...
Definition: peak_afl.hpp:107
void AddController(const std::shared_ptr< Controller > &controller)
Add a controller to an automanager.
Definition: peak_afl.hpp:1206
double GetAutoPercentile() const
Get the auto percentile for a controller.
Definition: peak_afl.hpp:1646
Range< std::uint32_t > GetAutoToleranceRange() const
Get the auto tolerance range for a controller.
Definition: peak_afl.hpp:1614
Invalid Parameter.
Definition: peak_afl.h:98
peak_afl_status peak_afl_AutoController_Weighted_ROI_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
Check if weighted region of interest is supported for a controller.
peak_afl_status peak_afl_AutoController_Create(peak_afl_controller_handle *controller, peak_afl_controllerType controllerType)
Create a new controller.
peak_afl_controller_status
controller status
Definition: peak_afl.h:149
peak_afl_status peak_afl_AutoFeatureManager_Process(peak_afl_manager_handle handle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Process an image.
peak_afl_status peak_afl_AutoController_Hysteresis_Get(peak_afl_controller_handle controller, uint8_t *hysteresis)
Get the autofeature hysteresis for a controller.
Busy.
Definition: peak_afl.h:104
peak_afl_status peak_afl_AutoController_AutoTolerance_GetRange(peak_afl_controller_handle controller, uint32_t *min, uint32_t *max, uint32_t *inc)
Get the auto tolerance range for a controller.
void * peak_afl_controller_handle
opaque controller handle type
Definition: peak_afl.h:48
bool IsAutoPercentileSupported() const
check if auto percentile is supported for a controller.
Definition: peak_afl.hpp:1625
peak_afl_status peak_afl_GetLastError(peak_afl_status *lastErrorCode, char *lastErrorMessage, size_t *lastErrorMessageSize)
Get the last error message.
peak_afl_status peak_afl_AutoController_Algorithm_GetList(peak_afl_controller_handle controller, peak_afl_controller_algorithm *typeList, uint32_t *listSize)
Get the list of supported algorithms for a controller.
void DestroyAllController()
Destroy all controllers for a manager.
Definition: peak_afl.hpp:1271
peak_afl_status peak_afl_AutoController_Hysteresis_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
Check if hysteresis is supported for a controller.
peak_afl_controllerType
controller types
Definition: peak_afl.h:120
peak_afl_status peak_afl_AutoController_Mode_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
Check if auto mode is supported for a controller.
Range< double > GetAutoPercentileRange() const
Get the auto percentile range for a controller.
Definition: peak_afl.hpp:1657
peak_afl_status peak_afl_AutoController_AutoPercentile_Set(peak_afl_controller_handle controller, double percentile)
Set the auto percentile for a controller.
peak_afl_status peak_afl_AutoController_Hysteresis_Set(peak_afl_controller_handle controller, uint8_t hysteresis)
Set the autofeature hysteresis for a controller.
~Manager()
Destructor of an automanager instance.
Definition: peak_afl.hpp:1168
bool Status() const
Get the status of a manager.
Definition: peak_afl.hpp:1308
bool IsSkipFramesSupported() const
Check if skip frames is supported for a controller.
Definition: peak_afl.hpp:1375
peak_afl_status peak_afl_AutoFeatureManager_DestroyController(peak_afl_manager_handle handle, peak_afl_controller_handle controller)
Destroy a controller.