IDSpeakAFL  v1.2.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_ipl/algorithm/peak_ipl_gain.hpp"
16 #include "peak/node_map/peak_node_map.hpp"
17 
18 #include <type_traits>
19 #include <cstdint>
20 #include <exception>
21 #include <string>
22 #include <tuple>
23 #include <utility>
24 #include <vector>
25 #include <memory>
26 #include <functional>
27 
28 #if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
29 # define PEAK_AFL_NO_DISCARD [[nodiscard]]
30 # define PEAK_AFL_MAYBE_UNUSED [[maybe_unused]]
31 #else
32 # ifdef _MSC_VER
33 # define PEAK_AFL_NO_DISCARD _Check_return_
34 # define PEAK_AFL_MAYBE_UNUSED
35 # elif defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
36 # define PEAK_AFL_NO_DISCARD __attribute__((warn_unused_result))
37 # define PEAK_AFL_MAYBE_UNUSED __attribute__((unused))
38 # else
39 # define PEAK_AFL_NO_DISCARD
40 # define PEAK_AFL_MAYBE_UNUSED
41 # endif
42 #endif
43 
56 namespace peak
57 {
58 namespace afl
59 {
60 namespace library
61 {
62 
67 struct Version_t
68 {
69  std::uint32_t major;
70  std::uint32_t minor;
71  std::uint32_t subminor;
72  std::uint32_t patch;
73 
78  PEAK_AFL_NO_DISCARD std::string ToString() const
79  {
80  return std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(subminor) + "."
81  + std::to_string(patch);
82  }
83 
89  PEAK_AFL_NO_DISCARD uint32_t Major() const
90  {
91  return major;
92  }
93 
99  PEAK_AFL_NO_DISCARD uint32_t Minor() const
100  {
101  return minor;
102  }
108  PEAK_AFL_NO_DISCARD uint32_t Subminor() const
109  {
110  return subminor;
111  }
112 
118  PEAK_AFL_NO_DISCARD uint32_t Patch() const
119  {
120  return patch;
121  }
122 };
123 
137 inline void Init();
138 
152 inline void Exit();
153 
161 PEAK_AFL_NO_DISCARD inline std::string GetLastError();
162 
175 PEAK_AFL_NO_DISCARD inline Version_t Version();
176 } // namespace library
177 
178 namespace error
179 {
180 
181 
186 class Exception : public std::exception
187 {
188 public:
189  explicit Exception(peak_afl_status code, bool get_text=true)
190  : m_code(code)
191  {
192  if (get_text)
193  {
194  m_text = library::GetLastError();
195  }
196  }
197 
203  PEAK_AFL_NO_DISCARD peak_afl_status code() const
204  {
205  return m_code;
206  }
207 
213  PEAK_AFL_NO_DISCARD const char* what() const noexcept override
214  {
215  if(m_text.empty())
216  {
217  return "-";
218  }
219  else
220  {
221  return m_text.c_str();
222  }
223  }
224 
232  PEAK_AFL_NO_DISCARD static std::string translateCode(peak_afl_status status)
233  {
234  switch(status)
235  {
237  return "PEAK_AFL_STATUS_SUCCESS";
238 
240  return "PEAK_AFL_STATUS_ERROR";
241 
243  return "PEAK_AFL_STATUS_NOT_INITIALIZED";
244 
246  return "PEAK_AFL_STATUS_INVALID_PARAMETER";
247 
249  return "PEAK_AFL_STATUS_ACCESS_DENIED";
250 
252  return "PEAK_AFL_STATUS_BUSY";
253 
255  return "PEAK_AFL_STATUS_BUFFER_TOO_SMALL";
256 
258  return "PEAK_AFL_STATUS_INVALID_IMAGE_FORMAT";
259 
261  return "PEAK_AFL_STATUS_NOT_SUPPORTED";
262 
263  default:
264  return "Unknown Status code";
265  }
266  }
267 
268 private:
269  peak_afl_status m_code{};
270  std::string m_text{};
271 };
272 } // namespace error
273 
274 class Controller;
275 
280 class Manager
281 {
282 public:
292  inline explicit Manager(const std::shared_ptr<peak::core::NodeMap>& node_map);
293 
297  inline ~Manager();
298 
299  Manager(const Manager&) = delete;
300  inline Manager(Manager&&) noexcept;
301 
302  Manager& operator=(const Manager&) noexcept = delete;
303  inline Manager& operator=(Manager&&) noexcept;
304 
315  inline void AddController(const std::shared_ptr<Controller>& controller);
316 
327  inline void RemoveController(const std::shared_ptr<Controller>& controller);
328 
338  inline void Process(const peak::ipl::Image& image) const;
339 
352  PEAK_AFL_NO_DISCARD inline std::shared_ptr<Controller> CreateController(peak_afl_controllerType type);
353 
361  inline void DestroyAllController();
362 
372  inline void DestroyController(const std::shared_ptr<Controller>& controller);
373 
381  inline void SetGainIPL(const peak::ipl::Gain& gain);
382 
392  PEAK_AFL_NO_DISCARD inline bool Status() const;
393 
399  PEAK_AFL_NO_DISCARD inline std::vector<std::shared_ptr<Controller>> ControllerList() const;
400 
406  PEAK_AFL_NO_DISCARD inline size_t ControllerCount() const;
407 
417  PEAK_AFL_NO_DISCARD inline std::shared_ptr<Controller> GetController(peak_afl_controllerType type) const;
418 
419 private:
420  std::vector<std::shared_ptr<Controller>> m_controllerList;
421  mutable std::mutex m_mutex{};
422  peak_afl_manager_handle m_handle{};
423 };
424 
434 template<typename... ControllerTypes>
435 std::tuple<Manager, std::vector<std::shared_ptr<Controller>>>
436 CreateManager(const std::shared_ptr<peak::core::NodeMap>& node_map, ControllerTypes... types)
437 {
438  constexpr int size = sizeof...(types);
439  constexpr std::array<peak_afl_controllerType, size> controller_types{types...};
440  std::vector<std::shared_ptr<Controller>> controller{};
441  Manager manager{node_map};
442  controller.reserve(size);
443 
444  std::for_each(controller_types.cbegin(), controller_types.cend(), [&manager, &controller](peak_afl_controllerType type) {
445  controller.emplace_back(std::move(manager.CreateController(type)));
446  });
447 
448  return { std::move(manager), std::move(controller) };
449 }
450 
451 
456 template <typename T, typename std::enable_if_t<std::is_arithmetic<T>::value, int> = 0>
457 struct Range
458 {
459  T min;
460  T max;
461  T inc;
462 };
463 
464 namespace callback
465 {
466 using FinishedCallback = std::function<void(void)>;
467 using DataProcessingCallback = std::function<void(int, int)>;
468 using ComponentCallback = std::function<void(void)>;
469 
470 using RegisterFunction = std::function<PEAK_AFL_API_STATUS(void*, void*)>;
471 using UnRegisterFunction = std::function<void()>;
472 }
473 
478 class Controller : public std::enable_shared_from_this<Controller>
479 {
480  friend class Manager;
481 
482  template<class T>
483  class Callback
484  {
485 #ifndef SWIG
486  public:
487  template<typename R, typename ...Args>
488  Callback(const std::shared_ptr<peak::afl::Controller>& controller, callback::RegisterFunction register_function,
489  callback::UnRegisterFunction unregister_function, std::function<R(Args...)> callback) :
490  m_callback(std::move(callback)),
491  m_unregister_function(std::move(unregister_function))
492  {
493  const auto ret = register_function(reinterpret_cast<void*>(&Callback::Func<Args...>), this);
494  if (ret != PEAK_AFL_STATUS_SUCCESS)
495  {
496  throw error::Exception(ret);
497  }
498  m_controller = controller;
499  }
500 
501  virtual ~Callback()
502  {
503  if (auto controller = m_controller.lock())
504  {
505  m_unregister_function();
506  }
507  }
508 
509  private:
510  template<typename ...Args>
511  static void Func(Args... args, void* ptr)
512  {
513  static_cast<Callback *>(ptr)->m_callback(args...);
514  };
515 #endif
516 
517  std::weak_ptr<peak::afl::Controller> m_controller{};
518  callback::UnRegisterFunction m_unregister_function{};
519  T m_callback{};
520  };
521 
522 
530  inline explicit Controller(peak_afl_controller_handle handle)
531  : m_handle(handle) {};
532 
533 public:
537  inline ~Controller();
538 
539  Controller(const Controller&) = delete;
540  Controller(Controller&&) = delete;
541  Controller& operator=(const Controller&) = delete;
542  Controller& operator=(Controller&&) = delete;
543 
553  PEAK_AFL_NO_DISCARD inline static std::shared_ptr<Controller> Create(peak_afl_controllerType type);
554 
562  PEAK_AFL_NO_DISCARD inline bool IsSkipFramesSupported() const;
563 
573  inline void SetSkipFrames(std::uint32_t count);
574 
584  PEAK_AFL_NO_DISCARD inline std::uint32_t GetSkipFrames() const;
585 
593  PEAK_AFL_NO_DISCARD inline Range<std::uint32_t> GetSkipFramesRange() const;
594 
604  PEAK_AFL_NO_DISCARD inline bool IsROISupported() const;
605 
615  inline void SetROI(peak_afl_rectangle rect);
616 
626  PEAK_AFL_NO_DISCARD inline peak_afl_rectangle GetROI() const;
627 
637  PEAK_AFL_NO_DISCARD inline bool IsROIPresetSupported() const;
638 
648  inline void SetROIPreset(peak_afl_roi_preset preset);
649 
659  PEAK_AFL_NO_DISCARD inline bool IsModeSupported() const;
660 
670  inline void SetMode(peak_afl_controller_automode mode);
671 
679  PEAK_AFL_NO_DISCARD inline peak_afl_controller_automode GetMode() const;
680 
690  PEAK_AFL_NO_DISCARD inline peak_afl_controller_status Status() const;
691 
701  PEAK_AFL_NO_DISCARD inline std::uint8_t GetLastAutoAverage() const;
702 
712  PEAK_AFL_NO_DISCARD inline std::tuple<std::uint8_t, std::uint8_t, std::uint8_t> GetLastAutoAverages() const;
713 
723  PEAK_AFL_NO_DISCARD inline bool IsAutoTargetSupported() const;
724 
735  inline void SetAutoTarget(uint32_t target);
736 
744  PEAK_AFL_NO_DISCARD inline std::uint32_t GetAutoTarget() const;
745 
756  PEAK_AFL_NO_DISCARD inline Range<std::uint32_t> GetAutoTargetRange() const;
757 
767  PEAK_AFL_NO_DISCARD inline bool IsAutoToleranceSupported() const;
768 
778  inline void SetAutoTolerance(std::uint32_t tolerance);
779 
787  PEAK_AFL_NO_DISCARD inline std::uint32_t GetAutoTolerance() const;
788 
799  PEAK_AFL_NO_DISCARD inline Range<std::uint32_t> GetAutoToleranceRange() const;
800 
810  PEAK_AFL_NO_DISCARD inline bool IsAutoPercentileSupported() const;
811 
822  inline void SetAutoPercentile(double percentile);
823 
831  PEAK_AFL_NO_DISCARD inline double GetAutoPercentile() const;
832 
843  PEAK_AFL_NO_DISCARD inline Range<double> GetAutoPercentileRange() const;
844 
854  PEAK_AFL_NO_DISCARD inline peak_afl_controllerType Type() const;
855 
867  PEAK_AFL_NO_DISCARD inline bool IsAlgorithmSupported() const;
868 
878  inline void SetAlgorithm(peak_afl_controller_algorithm algorithm);
879 
886  PEAK_AFL_NO_DISCARD inline peak_afl_controller_algorithm GetAlgorithm() const;
887 
897  PEAK_AFL_NO_DISCARD inline std::vector<peak_afl_controller_algorithm> GetAlgorithmList() const;
898 
910  PEAK_AFL_NO_DISCARD inline bool IsSharpnessAlgorithmSupported() const;
911 
921  inline void SetSharpnessAlgorithm(peak_afl_controller_sharpness_algorithm algorithm);
922 
930  PEAK_AFL_NO_DISCARD inline peak_afl_controller_sharpness_algorithm GetSharpnessAlgorithm() const;
931 
941  PEAK_AFL_NO_DISCARD inline std::vector<peak_afl_controller_sharpness_algorithm> GetSharpnessAlgorithmList() const;
942 
946  inline void RegisterFinishedCallback(const callback::FinishedCallback& callback);
947 
951  inline void UnRegisterFinishedCallback();
952 
956  inline void RegisterComponentCallback(peak_afl_controller_brightness_component component, const callback::FinishedCallback& callback);
957 
961  inline void UnRegisterComponentCallback(peak_afl_controller_brightness_component component);
962 
967  inline void RegisterDataProcessingCallback(const callback::DataProcessingCallback& callback);
968 
972  inline void UnRegisterDataProcessingCallback();
973 
983  PEAK_AFL_NO_DISCARD inline bool IsWeightedROISupported() const;
984 
994  inline void SetWeightedROIs(const std::vector<peak_afl_weighted_rectangle>& list);
995 
1005  inline void SetWeightedROI(const peak_afl_weighted_rectangle& rect);
1006 
1014  PEAK_AFL_NO_DISCARD inline peak_afl_size GetWeightedROIMinSize() const;
1015 
1023  PEAK_AFL_NO_DISCARD inline std::vector<peak_afl_weighted_rectangle> GetWeightedROIs() const;
1024 
1034  PEAK_AFL_NO_DISCARD inline bool IsLimitSupported() const;
1035 
1045  inline void SetLimit(peak_afl_controller_limit limit);
1046 
1054  PEAK_AFL_NO_DISCARD inline peak_afl_controller_limit GetLimit() const;
1055 
1063  PEAK_AFL_NO_DISCARD inline peak_afl_controller_limit GetDefaultLimit() const;
1064 
1074  PEAK_AFL_NO_DISCARD inline bool IsHysteresisSupported() const;
1075 
1085  inline void SetHysteresis(std::uint8_t hysteresis);
1086 
1094  PEAK_AFL_NO_DISCARD inline std::uint8_t GetHysteresis() const;
1095 
1103  PEAK_AFL_NO_DISCARD inline std::uint8_t GetDefaultHysteresis() const;
1104 
1112  PEAK_AFL_NO_DISCARD inline Range<std::uint8_t> GetHysteresisRange() const;
1113 
1123  PEAK_AFL_NO_DISCARD inline bool IsBrightnessComponentModeSupported() const;
1124 
1135  inline void BrightnessComponentSetMode(peak_afl_controller_brightness_component component, peak_afl_controller_automode mode);
1136 
1145  PEAK_AFL_NO_DISCARD inline peak_afl_controller_automode BrightnessComponentGetMode(peak_afl_controller_brightness_component component) const;
1146 
1157  PEAK_AFL_NO_DISCARD inline peak_afl_controller_status BrightnessComponentStatus(peak_afl_controller_brightness_component component) const;
1158 
1159 private:
1160  using FinishedCallbackType = Callback<callback::FinishedCallback>;
1161  using DataProcessingCallbackType = Callback<callback::DataProcessingCallback>;
1162  using ComponentCallbackType = Callback<callback::ComponentCallback>;
1163 
1164  peak_afl_controller_handle m_handle{};
1165  std::unique_ptr<FinishedCallbackType> m_finishedCallback{};
1166  std::unique_ptr<DataProcessingCallbackType> m_dataProcessingCallback{};
1167  std::unique_ptr<ComponentCallbackType> m_finishedExposureCallback{};
1168  std::unique_ptr<ComponentCallbackType> m_finishedGainCallback{};
1169 };
1170 
1171 namespace library
1172 {
1173 inline void Init()
1174 {
1175  const auto ret = peak_afl_Init();
1176  if (ret != PEAK_AFL_STATUS_SUCCESS)
1177 
1178  {
1179  throw error::Exception(ret, false);
1180  }
1181 }
1182 
1183 inline void Exit()
1184 {
1185  const auto ret = peak_afl_Exit();
1186  if (ret != PEAK_AFL_STATUS_SUCCESS)
1187  {
1188  throw error::Exception(ret, false);
1189  }
1190 }
1191 
1193 {
1194  Version_t version{};
1195 
1196  const auto ret = peak_afl_GetVersion(&version.major, &version.minor, &version.subminor, &version.patch);
1197  if (ret != PEAK_AFL_STATUS_SUCCESS)
1198  {
1199  throw error::Exception(ret, false);
1200  }
1201 
1202  return version;
1203 }
1204 
1205 inline std::string GetLastError()
1206 {
1207  std::size_t lastErrorMessageSize;
1208  peak_afl_status code;
1209 
1210  auto ret = peak_afl_GetLastError(&code, nullptr, &lastErrorMessageSize);
1211  if (ret != PEAK_AFL_STATUS_SUCCESS)
1212  {
1213  return "Cannot get last error!";
1214  }
1215 
1216  std::vector<char> text;
1217  text.resize(lastErrorMessageSize);
1218 
1219  ret = peak_afl_GetLastError(&code, text.data(), &lastErrorMessageSize);
1220  if (ret != PEAK_AFL_STATUS_SUCCESS)
1221  {
1222  return "Cannot get last error!";
1223  }
1224 
1225  return { text.begin(), text.end() };
1226 }
1227 } // namespace library
1228 
1229 inline Manager::Manager(const std::shared_ptr<peak::core::NodeMap>& node_map)
1230 {
1231  if(!node_map)
1232  {
1233  throw std::runtime_error("Invalid node map handle!");
1234  }
1235 
1236  const auto ret = peak_afl_AutoFeatureManager_Create(&m_handle, node_map->Handle());
1237  if (ret != PEAK_AFL_STATUS_SUCCESS)
1238  {
1239  throw error::Exception(ret);
1240  }
1241 }
1242 
1244 {
1245  if (m_handle != nullptr)
1246  {
1248 
1249  {
1250  std::lock_guard<std::mutex> lck(m_mutex);
1251  for (auto& c : m_controllerList)
1252  {
1253  c->m_handle = nullptr;
1254  }
1255  }
1256 
1258  m_handle = nullptr;
1259  }
1260 }
1261 
1262 inline Manager::Manager(Manager&& other) noexcept {
1263  m_handle = other.m_handle;
1264  other.m_handle = nullptr;
1265 
1266  std::lock_guard<std::mutex> lck(other.m_mutex);
1267  m_controllerList = std::move(other.m_controllerList);
1268 }
1269 
1270 inline Manager& Manager::operator=(Manager&& other) noexcept
1271 {
1272  m_handle = other.m_handle;
1273  other.m_handle = nullptr;
1274 
1275  std::lock_guard<std::mutex> lck(other.m_mutex);
1276  m_controllerList = std::move(other.m_controllerList);
1277 
1278  return *this;
1279 }
1280 
1281 inline void Manager::AddController(const std::shared_ptr<Controller>& controller)
1282 {
1283  std::lock_guard<std::mutex> lck(m_mutex);
1284 
1285  auto cnt = std::any_of(m_controllerList.begin(), m_controllerList.end(), [controller](const std::shared_ptr<Controller>& c) {
1286  return c == controller;
1287  });
1288 
1289  if(cnt)
1290  {
1291  return;
1292  }
1293 
1294  const auto ret = peak_afl_AutoFeatureManager_AddController(m_handle, controller->m_handle);
1295  if (ret != PEAK_AFL_STATUS_SUCCESS)
1296  {
1297  throw error::Exception(ret);
1298  }
1299 
1300  m_controllerList.emplace_back(controller);
1301 }
1302 
1303 inline void Manager::RemoveController(const std::shared_ptr<Controller>& controller)
1304 {
1305  std::lock_guard<std::mutex> lck(m_mutex);
1306 
1307  const auto ret = peak_afl_AutoFeatureManager_RemoveController(m_handle, controller->m_handle);
1308  if (ret != PEAK_AFL_STATUS_SUCCESS)
1309  {
1310  throw error::Exception(ret);
1311  }
1312 
1313  auto it = std::remove_if(m_controllerList.begin(), m_controllerList.end(), [controller](const std::shared_ptr<Controller>& c) {
1314  return c == controller;
1315  });
1316 
1317  m_controllerList.erase(it, m_controllerList.end());
1318 }
1319 
1320 inline void Manager::Process(const peak::ipl::Image& image) const
1321 {
1322  const auto ret = peak_afl_AutoFeatureManager_Process(m_handle, ImageBackendAccessor::BackendHandle(image));
1323  if (ret != PEAK_AFL_STATUS_SUCCESS)
1324  {
1325  throw error::Exception(ret);
1326  }
1327 }
1328 
1329 inline std::shared_ptr<Controller> Manager::CreateController(peak_afl_controllerType type)
1330 {
1331  std::lock_guard<std::mutex> lck(m_mutex);
1332 
1333  peak_afl_controller_handle handle{};
1334  const auto ret = peak_afl_AutoFeatureManager_CreateController(m_handle, &handle, type);
1335  if (ret != PEAK_AFL_STATUS_SUCCESS)
1336  {
1337  throw error::Exception(ret);
1338  }
1339 
1340  auto shared = std::shared_ptr<Controller>(new Controller(handle));
1341  m_controllerList.emplace_back(shared);
1342 
1343  return shared;
1344 }
1345 
1347 {
1348  std::lock_guard<std::mutex> lck(m_mutex);
1349 
1350  const auto ret = peak_afl_AutoFeatureManager_DestroyAllController(m_handle);
1351  if (ret != PEAK_AFL_STATUS_SUCCESS)
1352  {
1353  throw error::Exception(ret);
1354  }
1355 
1356  for(auto& c : m_controllerList)
1357  {
1358  c->m_handle = nullptr;
1359  }
1360 
1361  m_controllerList.clear();
1362 }
1363 
1364 inline void Manager::DestroyController(const std::shared_ptr<Controller>& controller)
1365 {
1366  std::lock_guard<std::mutex> lck(m_mutex);
1367 
1368  const auto ret = peak_afl_AutoFeatureManager_DestroyController(m_handle, controller->m_handle);
1369  if (ret != PEAK_AFL_STATUS_SUCCESS)
1370  {
1371  throw error::Exception(ret);
1372  }
1373 
1374  auto it = std::remove_if(m_controllerList.begin(), m_controllerList.end(), [controller](const std::shared_ptr<Controller>& c) {
1375  return c == controller;
1376  });
1377 
1378  m_controllerList.erase(it, m_controllerList.end());
1379 
1380  controller->m_handle = nullptr;
1381 }
1382 
1383 inline void Manager::SetGainIPL(const peak::ipl::Gain& gain)
1384 {
1385  const auto ret = peak_afl_AutoFeatureManager_SetGainIPL(m_handle, GainBackendAccessor::BackendHandle(gain));
1386  if (ret != PEAK_AFL_STATUS_SUCCESS)
1387  {
1388  throw error::Exception(ret);
1389  }
1390 }
1391 
1392 inline bool Manager::Status() const
1393 {
1394  std::uint8_t status;
1395  const auto ret = peak_afl_AutoFeatureManager_Status(m_handle, &status);
1396  if (ret != PEAK_AFL_STATUS_SUCCESS)
1397  {
1398  throw error::Exception(ret);
1399  }
1400 
1401  return status;
1402 }
1403 
1404 inline std::vector<std::shared_ptr<Controller>> Manager::ControllerList() const
1405 {
1406  std::lock_guard<std::mutex> lck(m_mutex);
1407 
1408  std::vector<std::shared_ptr<Controller>> controller{};
1409 
1410  std::copy(m_controllerList.begin(), m_controllerList.end(), std::back_inserter(controller));
1411 
1412  return controller;
1413 }
1414 
1415 inline size_t Manager::ControllerCount() const
1416 {
1417  return m_controllerList.size();
1418 }
1419 
1420 inline std::shared_ptr<Controller> Manager::GetController(peak_afl_controllerType type) const
1421 {
1422  std::lock_guard<std::mutex> lck(m_mutex);
1423 
1424  auto it = std::find_if(m_controllerList.cbegin(), m_controllerList.cend(), [=](const std::shared_ptr<Controller>& controller) {
1425  return type == controller->Type();
1426  });
1427 
1428  if(it != m_controllerList.cend())
1429  {
1430  return *it;
1431  }
1432  else
1433  {
1435  }
1436 }
1437 
1438 inline std::shared_ptr<Controller> Controller::Create(peak_afl_controllerType type)
1439 {
1440  peak_afl_controller_handle handle{};
1441  const auto ret = peak_afl_AutoController_Create(&handle, type);
1442  if (ret != PEAK_AFL_STATUS_SUCCESS)
1443  {
1444  throw error::Exception(ret);
1445  }
1446 
1447  return std::shared_ptr<Controller>(new Controller(handle));
1448 }
1449 
1451 {
1452  if (m_handle != nullptr)
1453  {
1455  m_handle = nullptr;
1456  }
1457 }
1458 
1460 {
1461  peak_afl_BOOL8 supported{};
1462  const auto ret = peak_afl_AutoController_SkipFrames_IsSupported(m_handle, &supported);
1463  if (ret != PEAK_AFL_STATUS_SUCCESS)
1464  {
1465  throw error::Exception(ret);
1466  }
1467 
1468  return supported;
1469 }
1470 
1471 inline void Controller::SetSkipFrames(std::uint32_t count)
1472 {
1473  const auto ret = peak_afl_AutoController_SkipFrames_Set(m_handle, count);
1474  if (ret != PEAK_AFL_STATUS_SUCCESS)
1475  {
1476  throw error::Exception(ret);
1477  }
1478 }
1479 
1480 inline std::uint32_t Controller::GetSkipFrames() const
1481 {
1482  std::uint32_t count{};
1483  const auto ret = peak_afl_AutoController_SkipFrames_Get(m_handle, &count);
1484  if (ret != PEAK_AFL_STATUS_SUCCESS)
1485  {
1486  throw error::Exception(ret);
1487  }
1488 
1489  return count;
1490 }
1491 
1493 {
1494  Range<std::uint32_t> range{};
1495  const auto ret = peak_afl_AutoController_SkipFrames_GetRange(m_handle, &range.min, &range.max, &range.inc);
1496  if (ret != PEAK_AFL_STATUS_SUCCESS)
1497  {
1498  throw error::Exception(ret);
1499  }
1500 
1501  return range;
1502 }
1503 
1504 inline bool Controller::IsROISupported() const
1505 {
1506  peak_afl_BOOL8 supported{};
1507  const auto ret = peak_afl_AutoController_ROI_IsSupported(m_handle, &supported);
1508  if (ret != PEAK_AFL_STATUS_SUCCESS)
1509  {
1510  throw error::Exception(ret);
1511  }
1512 
1513  return supported;
1514 }
1515 
1517 {
1518  const auto ret = peak_afl_AutoController_ROI_Set(m_handle, rect);
1519  if (ret != PEAK_AFL_STATUS_SUCCESS)
1520  {
1521  throw error::Exception(ret);
1522  }
1523 }
1524 
1526 {
1527  peak_afl_rectangle rect{};
1528  const auto ret = peak_afl_AutoController_ROI_Get(m_handle, &rect);
1529  if (ret != PEAK_AFL_STATUS_SUCCESS)
1530  {
1531  throw error::Exception(ret);
1532  }
1533  return rect;
1534 }
1535 
1537 {
1538  peak_afl_BOOL8 supported{};
1539  const auto ret = peak_afl_AutoController_ROI_Preset_IsSupported(m_handle, &supported);
1540  if (ret != PEAK_AFL_STATUS_SUCCESS)
1541  {
1542  throw error::Exception(ret);
1543  }
1544 
1545  return supported;
1546 }
1547 
1549 {
1550  const auto ret = peak_afl_AutoController_ROI_Preset_Set(m_handle, preset);
1551  if (ret != PEAK_AFL_STATUS_SUCCESS)
1552  {
1553  throw error::Exception(ret);
1554  }
1555 }
1556 
1557 inline bool Controller::IsModeSupported() const
1558 {
1559  peak_afl_BOOL8 supported{};
1560  const auto ret = peak_afl_AutoController_Mode_IsSupported(m_handle, &supported);
1561  if (ret != PEAK_AFL_STATUS_SUCCESS)
1562  {
1563  throw error::Exception(ret);
1564  }
1565 
1566  return supported;
1567 }
1568 
1570 {
1571  const auto ret = peak_afl_AutoController_Mode_Set(m_handle, mode);
1572  if (ret != PEAK_AFL_STATUS_SUCCESS)
1573  {
1574  throw error::Exception(ret);
1575  }
1576 }
1577 
1579 {
1581  const auto ret = peak_afl_AutoController_Mode_Get(m_handle, &mode);
1582  if (ret != PEAK_AFL_STATUS_SUCCESS)
1583  {
1584  throw error::Exception(ret);
1585  }
1586  return mode;
1587 }
1588 
1590 {
1591  peak_afl_controller_status status{};
1592  const auto ret = peak_afl_AutoController_Status(m_handle, &status);
1593  if (ret != PEAK_AFL_STATUS_SUCCESS)
1594  {
1595  throw error::Exception(ret);
1596  }
1597  return status;
1598 }
1599 
1600 
1601 inline std::uint8_t Controller::GetLastAutoAverage() const
1602 {
1603  std::uint8_t average{};
1604  const auto ret = peak_afl_AutoController_GetLastAutoAverage(m_handle, &average);
1605  if (ret != PEAK_AFL_STATUS_SUCCESS)
1606  {
1607  throw error::Exception(ret);
1608  }
1609  return average;
1610 }
1611 
1612 inline std::tuple<std::uint8_t, std::uint8_t, std::uint8_t> Controller::GetLastAutoAverages() const
1613 {
1614  std::uint8_t averageRed{}, averageGreen{}, averageBlue{};
1615  const auto ret = peak_afl_AutoController_GetLastAutoAverages(m_handle, &averageRed, &averageGreen, &averageBlue);
1616  if (ret != PEAK_AFL_STATUS_SUCCESS)
1617  {
1618  throw error::Exception(ret);
1619  }
1620  return { averageRed, averageGreen, averageBlue };
1621 }
1622 
1624 {
1625  peak_afl_BOOL8 supported{};
1626  const auto ret = peak_afl_AutoController_AutoTarget_IsSupported(m_handle, &supported);
1627  if (ret != PEAK_AFL_STATUS_SUCCESS)
1628  {
1629  throw error::Exception(ret);
1630  }
1631 
1632  return supported;
1633 }
1634 
1635 inline void Controller::SetAutoTarget(std::uint32_t target)
1636 {
1637  const auto ret = peak_afl_AutoController_AutoTarget_Set(m_handle, target);
1638  if (ret != PEAK_AFL_STATUS_SUCCESS)
1639  {
1640  throw error::Exception(ret);
1641  }
1642 }
1643 
1644 inline std::uint32_t Controller::GetAutoTarget() const
1645 {
1646  std::uint32_t target{};
1647  const auto ret = peak_afl_AutoController_AutoTarget_Get(m_handle, &target);
1648  if (ret != PEAK_AFL_STATUS_SUCCESS)
1649  {
1650  throw error::Exception(ret);
1651  }
1652  return target;
1653 }
1654 
1656 {
1657  Range<std::uint32_t> range{};
1658  const auto ret = peak_afl_AutoController_AutoTarget_GetRange(m_handle, &range.min, &range.max, &range.inc);
1659  if (ret != PEAK_AFL_STATUS_SUCCESS)
1660  {
1661  throw error::Exception(ret);
1662  }
1663  return range;
1664 }
1665 
1667 {
1668  peak_afl_BOOL8 supported{};
1669  const auto ret = peak_afl_AutoController_AutoTolerance_IsSupported(m_handle, &supported);
1670  if (ret != PEAK_AFL_STATUS_SUCCESS)
1671  {
1672  throw error::Exception(ret);
1673  }
1674 
1675  return supported;
1676 }
1677 
1678 inline void Controller::SetAutoTolerance(uint32_t tolerance)
1679 {
1680  const auto ret = peak_afl_AutoController_AutoTolerance_Set(m_handle, tolerance);
1681  if (ret != PEAK_AFL_STATUS_SUCCESS)
1682  {
1683  throw error::Exception(ret);
1684  }
1685 }
1686 
1687 inline uint32_t Controller::GetAutoTolerance() const
1688 {
1689  std::uint32_t tolerance;
1690  const auto ret = peak_afl_AutoController_AutoTolerance_Get(m_handle, &tolerance);
1691  if (ret != PEAK_AFL_STATUS_SUCCESS)
1692  {
1693  throw error::Exception(ret);
1694  }
1695  return tolerance;
1696 }
1697 
1699 {
1700  Range<uint32_t> range{};
1701  const auto ret = peak_afl_AutoController_AutoTolerance_GetRange(m_handle, &range.min, &range.max, &range.inc);
1702  if (ret != PEAK_AFL_STATUS_SUCCESS)
1703  {
1704  throw error::Exception(ret);
1705  }
1706  return range;
1707 }
1708 
1710 {
1711  peak_afl_BOOL8 supported{};
1712  const auto ret = peak_afl_AutoController_AutoPercentile_IsSupported(m_handle, &supported);
1713  if (ret != PEAK_AFL_STATUS_SUCCESS)
1714  {
1715  throw error::Exception(ret);
1716  }
1717 
1718  return supported;
1719 }
1720 
1721 inline void Controller::SetAutoPercentile(double percentile)
1722 {
1723  const auto ret = peak_afl_AutoController_AutoPercentile_Set(m_handle, percentile);
1724  if (ret != PEAK_AFL_STATUS_SUCCESS)
1725  {
1726  throw error::Exception(ret);
1727  }
1728 }
1729 
1730 inline double Controller::GetAutoPercentile() const
1731 {
1732  double percentile;
1733  const auto ret = peak_afl_AutoController_AutoPercentile_Get(m_handle, &percentile);
1734  if (ret != PEAK_AFL_STATUS_SUCCESS)
1735  {
1736  throw error::Exception(ret);
1737  }
1738  return percentile;
1739 }
1740 
1742 {
1743  Range<double> range{};
1744  const auto ret = peak_afl_AutoController_AutoPercentile_GetRange(m_handle, &range.min, &range.max, &range.inc);
1745  if (ret != PEAK_AFL_STATUS_SUCCESS)
1746  {
1747  throw error::Exception(ret);
1748  }
1749  return range;
1750 }
1751 
1753 {
1754  peak_afl_controllerType type{};
1755  const auto ret = peak_afl_AutoController_Type_Get(m_handle, &type);
1756  if (ret != PEAK_AFL_STATUS_SUCCESS)
1757  {
1758  throw error::Exception(ret);
1759  }
1760  return type;
1761 }
1762 
1764 {
1765  peak_afl_BOOL8 supported{};
1766  const auto ret = peak_afl_AutoController_Algorithm_IsSupported(m_handle, &supported);
1767  if (ret != PEAK_AFL_STATUS_SUCCESS)
1768  {
1769  throw error::Exception(ret);
1770  }
1771 
1772  return supported;
1773 }
1774 
1776 {
1777  const auto ret = peak_afl_AutoController_Algorithm_Set(m_handle, alg);
1778  if (ret != PEAK_AFL_STATUS_SUCCESS)
1779  {
1780  throw error::Exception(ret);
1781  }
1782 }
1783 
1785 {
1787  const auto ret = peak_afl_AutoController_Algorithm_Get(m_handle, &alg);
1788  if (ret != PEAK_AFL_STATUS_SUCCESS)
1789  {
1790  throw error::Exception(ret);
1791  }
1792 
1793  return alg;
1794 }
1795 
1796 inline std::vector<peak_afl_controller_algorithm> Controller::GetAlgorithmList() const
1797 {
1798  std::vector<peak_afl_controller_algorithm> algList{};
1799  std::uint32_t listSize{};
1800 
1801  auto ret = peak_afl_AutoController_Algorithm_GetList(m_handle, nullptr, &listSize);
1802  if (ret != PEAK_AFL_STATUS_SUCCESS)
1803  {
1804  throw error::Exception(ret);
1805  }
1806 
1807  algList.resize(listSize);
1808 
1809  ret = peak_afl_AutoController_Algorithm_GetList(m_handle, algList.data(), &listSize);
1810  if (ret != PEAK_AFL_STATUS_SUCCESS)
1811  {
1812  throw error::Exception(ret);
1813  }
1814 
1815  return algList;
1816 }
1817 
1819 {
1820  peak_afl_BOOL8 supported{};
1821  const auto ret = peak_afl_AutoController_SharpnessAlgorithm_IsSupported(m_handle, &supported);
1822  if (ret != PEAK_AFL_STATUS_SUCCESS)
1823  {
1824  throw error::Exception(ret);
1825  }
1826 
1827  return supported;
1828 }
1829 
1831 {
1832  const auto ret = peak_afl_AutoController_SharpnessAlgorithm_Set(m_handle, alg);
1833  if (ret != PEAK_AFL_STATUS_SUCCESS)
1834  {
1835  throw error::Exception(ret);
1836  }
1837 }
1838 
1840 {
1842  const auto ret = peak_afl_AutoController_SharpnessAlgorithm_Get(m_handle, &alg);
1843  if (ret != PEAK_AFL_STATUS_SUCCESS)
1844  {
1845  throw error::Exception(ret);
1846  }
1847 
1848  return alg;
1849 }
1850 
1851 inline std::vector<peak_afl_controller_sharpness_algorithm> Controller::GetSharpnessAlgorithmList() const
1852 {
1853  std::vector<peak_afl_controller_sharpness_algorithm> algList{};
1854  std::uint32_t listSize{};
1855 
1856  auto ret = peak_afl_AutoController_SharpnessAlgorithm_GetList(m_handle, nullptr, &listSize);
1857  if (ret != PEAK_AFL_STATUS_SUCCESS)
1858  {
1859  throw error::Exception(ret);
1860  }
1861 
1862  algList.resize(listSize);
1863 
1864  ret = peak_afl_AutoController_SharpnessAlgorithm_GetList(m_handle, algList.data(), &listSize);
1865  if (ret != PEAK_AFL_STATUS_SUCCESS)
1866  {
1867  throw error::Exception(ret);
1868  }
1869 
1870  return algList;
1871 }
1872 
1873 inline void Controller::RegisterFinishedCallback(const callback::FinishedCallback& callback)
1874 {
1875  m_finishedCallback = std::make_unique<FinishedCallbackType>(shared_from_this(),
1876  [handle = m_handle](void* ptr, void* ctx) {
1878  [handle = m_handle] {
1880  callback);
1881 }
1882 
1884 {
1885  m_finishedCallback.reset();
1886 }
1887 
1888 inline void Controller::RegisterComponentCallback(peak_afl_controller_brightness_component component, const callback::FinishedCallback& callback)
1889 {
1890  if (!IsBrightnessComponentModeSupported())
1891  {
1893  }
1894 
1896  {
1897  m_finishedExposureCallback = std::make_unique<ComponentCallbackType>(shared_from_this(),
1898  [handle = m_handle, component](void* ptr, void* ctx) {
1900  ptr, ctx); },
1901  [handle = m_handle, component] {
1903  nullptr, nullptr); },
1904  callback);
1905  }
1906  else if (PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_GAIN == component)
1907  {
1908  m_finishedGainCallback = std::make_unique<ComponentCallbackType>(shared_from_this(),
1909  [handle = m_handle, component](void* ptr, void* ctx) {
1911  ptr, ctx); },
1912  [handle = m_handle, component] {
1914  nullptr, nullptr); },
1915  callback);
1916  }
1917  else
1918  {
1920  }
1921 }
1922 
1924 {
1926  {
1927  m_finishedExposureCallback.reset();
1928  }
1929  else if (PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_GAIN == component)
1930  {
1931  m_finishedGainCallback.reset();
1932  }
1933  else
1934  {
1936  }
1937 }
1938 
1939 inline void Controller::RegisterDataProcessingCallback(const callback::DataProcessingCallback& callback)
1940 {
1941  m_dataProcessingCallback = std::make_unique<DataProcessingCallbackType>(shared_from_this(),
1942  [handle = m_handle](void* ptr, void* ctx) {
1944  [handle = m_handle] {
1946  callback);
1947 }
1948 
1950 {
1951  m_dataProcessingCallback.reset();
1952 }
1953 
1955 {
1956  peak_afl_BOOL8 supported{};
1957  const auto ret = peak_afl_AutoController_Weighted_ROI_IsSupported(m_handle, &supported);
1958  if (ret != PEAK_AFL_STATUS_SUCCESS)
1959  {
1960  throw error::Exception(ret);
1961  }
1962 
1963  return supported;
1964 }
1965 
1966 inline void Controller::SetWeightedROIs(const std::vector<peak_afl_weighted_rectangle>& list)
1967 {
1968  const auto ret = peak_afl_AutoController_Weighted_ROI_Set(m_handle, list.data(), static_cast<uint32_t>(list.size()));
1969  if (ret != PEAK_AFL_STATUS_SUCCESS)
1970  {
1971  throw error::Exception(ret);
1972  }
1973 }
1974 
1976 {
1977  const auto ret = peak_afl_AutoController_Weighted_ROI_Set(m_handle, &rect, 1);
1978  if (ret != PEAK_AFL_STATUS_SUCCESS)
1979  {
1980  throw error::Exception(ret);
1981  }
1982 }
1983 
1985 {
1986  peak_afl_size minSize{};
1987  const auto ret = peak_afl_AutoController_Weighted_ROI_Min_Size(m_handle, &minSize);
1988  if (ret != PEAK_AFL_STATUS_SUCCESS)
1989  {
1990  throw error::Exception(ret);
1991  }
1992  return minSize;
1993 }
1994 
1995 inline std::vector<peak_afl_weighted_rectangle> Controller::GetWeightedROIs() const
1996 {
1997  std::vector<peak_afl_weighted_rectangle> list;
1998  std::uint32_t listSize{};
1999 
2000  auto ret = peak_afl_AutoController_Weighted_ROI_Get(m_handle, nullptr, &listSize);
2001  if (ret != PEAK_AFL_STATUS_SUCCESS)
2002  {
2003  throw error::Exception(ret);
2004  }
2005 
2006  list.resize(listSize);
2007 
2008  ret = peak_afl_AutoController_Weighted_ROI_Get(m_handle, list.data(), &listSize);
2009  if (ret != PEAK_AFL_STATUS_SUCCESS)
2010  {
2011  throw error::Exception(ret);
2012  }
2013 
2014  return list;
2015 }
2016 
2017 inline bool Controller::IsLimitSupported() const
2018 {
2019  peak_afl_BOOL8 supported{};
2020  const auto ret = peak_afl_AutoController_Limit_IsSupported(m_handle, &supported);
2021  if (ret != PEAK_AFL_STATUS_SUCCESS)
2022  {
2023  throw error::Exception(ret);
2024  }
2025 
2026  return supported;
2027 }
2028 
2030 {
2031  const auto ret = peak_afl_AutoController_Limit_Set(m_handle, limit);
2032  if (ret != PEAK_AFL_STATUS_SUCCESS)
2033  {
2034  throw error::Exception(ret);
2035  }
2036 }
2037 
2039 {
2040  peak_afl_controller_limit limit{};
2041  const auto ret = peak_afl_AutoController_Limit_Get(m_handle, &limit);
2042  if (ret != PEAK_AFL_STATUS_SUCCESS)
2043  {
2044  throw error::Exception(ret);
2045  }
2046  return limit;
2047 }
2048 
2050 {
2051  peak_afl_controller_limit limit{};
2052  const auto ret = peak_afl_AutoController_Limit_Default(m_handle, &limit);
2053  if (ret != PEAK_AFL_STATUS_SUCCESS)
2054  {
2055  throw error::Exception(ret);
2056  }
2057  return limit;
2058 }
2059 
2061 {
2062  peak_afl_BOOL8 supported{};
2063  const auto ret = peak_afl_AutoController_Hysteresis_IsSupported(m_handle, &supported);
2064  if (ret != PEAK_AFL_STATUS_SUCCESS)
2065  {
2066  throw error::Exception(ret);
2067  }
2068 
2069  return supported;
2070 }
2071 
2072 inline void Controller::SetHysteresis(std::uint8_t hysteresis)
2073 {
2074  const auto ret = peak_afl_AutoController_Hysteresis_Set(m_handle, hysteresis);
2075  if (ret != PEAK_AFL_STATUS_SUCCESS)
2076  {
2077  throw error::Exception(ret);
2078  }
2079 }
2080 
2081 inline std::uint8_t Controller::GetHysteresis() const
2082 {
2083  std::uint8_t hysteresis{};
2084  const auto ret = peak_afl_AutoController_Hysteresis_Get(m_handle, &hysteresis);
2085  if (ret != PEAK_AFL_STATUS_SUCCESS)
2086  {
2087  throw error::Exception(ret);
2088  }
2089 
2090  return hysteresis;
2091 }
2092 
2093 inline std::uint8_t Controller::GetDefaultHysteresis() const
2094 {
2095  std::uint8_t hysteresis{};
2096  const auto ret = peak_afl_AutoController_Hysteresis_Default(m_handle, &hysteresis);
2097  if (ret != PEAK_AFL_STATUS_SUCCESS)
2098  {
2099  throw error::Exception(ret);
2100  }
2101 
2102  return hysteresis;
2103 }
2104 
2106 {
2107  Range<std::uint8_t> hysteresis{};
2109  m_handle, &hysteresis.min, &hysteresis.max, &hysteresis.inc);
2110  if (ret != PEAK_AFL_STATUS_SUCCESS)
2111  {
2112  throw error::Exception(ret);
2113  }
2114 
2115  return hysteresis;
2116 }
2117 
2118 PEAK_AFL_NO_DISCARD inline bool Controller::IsBrightnessComponentModeSupported() const
2119 {
2120  peak_afl_BOOL8 supported{};
2121  const auto ret = peak_afl_AutoController_BrightnessComponent_Mode_IsSupported(m_handle, &supported);
2122  if (ret != PEAK_AFL_STATUS_SUCCESS)
2123  {
2124  throw error::Exception(ret);
2125  }
2126 
2127  return supported;
2128 }
2129 
2132 {
2133  const auto ret = peak_afl_AutoController_BrightnessComponent_Mode_Set(m_handle, component, mode);
2134  if (ret != PEAK_AFL_STATUS_SUCCESS)
2135  {
2136  throw error::Exception(ret);
2137  }
2138 }
2139 
2142 {
2144  const auto ret = peak_afl_AutoController_BrightnessComponent_Mode_Get(m_handle, component, &mode);
2145  if (ret != PEAK_AFL_STATUS_SUCCESS)
2146  {
2147  throw error::Exception(ret);
2148  }
2149  return mode;
2150 }
2151 
2154 {
2155  peak_afl_controller_status status{};
2156  const auto ret = peak_afl_AutoController_BrightnessComponent_Status(m_handle, component, &status);
2157  if (ret != PEAK_AFL_STATUS_SUCCESS)
2158  {
2159  throw error::Exception(ret);
2160  }
2161  return status;
2162 }
2163 } /* namespace afl */
2164 } /* 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:1404
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:1784
~Controller()
Definition: peak_afl.hpp:1450
Range< std::uint8_t > GetHysteresisRange() const
Get autofeature hysteresis range for a controller.
Definition: peak_afl.hpp:2105
std::vector< peak_afl_controller_algorithm > GetAlgorithmList() const
Get the list of supported algorithms for a controller.
Definition: peak_afl.hpp:1796
void SetWeightedROIs(const std::vector< peak_afl_weighted_rectangle > &list)
Set the autofeature weighted region of interest for a controller.
Definition: peak_afl.hpp:1966
void SetHysteresis(std::uint8_t hysteresis)
Set the autofeature hysteresis for a controller.
Definition: peak_afl.hpp:2072
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:206
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:1415
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:1763
peak_afl_status peak_afl_AutoController_BrightnessComponent_Mode_Get(peak_afl_controller_handle controller, peak_afl_controller_brightness_component component, peak_afl_controller_automode *mode)
Get the current brightness component mode for a controller.
peak_afl_status peak_afl_AutoController_Limit_Default(peak_afl_controller_handle controller, peak_afl_controller_limit *limit)
Get the autofeature default limit.
void UnRegisterComponentCallback(peak_afl_controller_brightness_component component)
Reset the component callback for a controller.
Definition: peak_afl.hpp:1923
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:1183
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_controller_status BrightnessComponentStatus(peak_afl_controller_brightness_component component) const
Get the status for a brightness controller component.
Definition: peak_afl.hpp:2152
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:1420
peak_afl_controller_limit GetLimit() const
Get the autofeature limit for a controller.
Definition: peak_afl.hpp:2038
Library not Initialized.
Definition: peak_afl.h:96
peak_afl_status
peak_afl Status codes
Definition: peak_afl.h:87
Definition: peak_afl.hpp:56
std::uint8_t GetDefaultHysteresis() const
Get the autofeature hysteresis default.
Definition: peak_afl.hpp:2093
peak_afl Size (2D)
Definition: peak_afl.h:297
void Init()
Init the peak_afl auto feature library.
Definition: peak_afl.hpp:1173
std::uint32_t GetAutoTarget() const
Get the currently set auto target for a controller.
Definition: peak_afl.hpp:1644
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:1205
void SetAutoTolerance(std::uint32_t tolerance)
Set the auto tolerance for a controller.
Definition: peak_afl.hpp:1678
Error.
Definition: peak_afl.h:93
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:118
std::uint8_t GetHysteresis() const
Get the autofeature hysteresis for a controller.
Definition: peak_afl.hpp:2081
void RegisterComponentCallback(peak_afl_controller_brightness_component component, const callback::FinishedCallback &callback)
Set component callback for a controller.
Definition: peak_afl.hpp:1888
void SetWeightedROI(const peak_afl_weighted_rectangle &rect)
Set single autofeature weighted region of interest for a controller.
Definition: peak_afl.hpp:1975
void RegisterDataProcessingCallback(const callback::DataProcessingCallback &callback)
Set the data callback for a controller.
Definition: peak_afl.hpp:1939
void BrightnessComponentSetMode(peak_afl_controller_brightness_component component, peak_afl_controller_automode mode)
Set the autofeature mode for a brightness controller component.
Definition: peak_afl.hpp:2130
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:99
Invalid image format.
Definition: peak_afl.h:111
void UnRegisterFinishedCallback()
Reset the finished callback for a controller.
Definition: peak_afl.hpp:1883
peak_afl Rectangle (2D)
Definition: peak_afl.h:331
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:1851
void SetAutoTarget(uint32_t target)
Set the auto target for a controller.
Definition: peak_afl.hpp:1635
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.
exposure
Definition: peak_afl.h:231
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:72
peak_afl_controller_automode BrightnessComponentGetMode(peak_afl_controller_brightness_component component) const
Get the current autofeature mode for a brightness controller component.
Definition: peak_afl.hpp:2140
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:369
void SetSharpnessAlgorithm(peak_afl_controller_sharpness_algorithm algorithm)
Set the used sharpness algorithm for a controller.
Definition: peak_afl.hpp:1830
void SetAlgorithm(peak_afl_controller_algorithm algorithm)
Set the used algorithm for a controller.
Definition: peak_afl.hpp:1775
bool IsWeightedROISupported() const
Check if weighted region of interest is supported for a controller.
Definition: peak_afl.hpp:1954
std::uint32_t GetSkipFrames() const
Get number of frames skipped for a controller.
Definition: peak_afl.hpp:1480
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. ...
peak_afl_status peak_afl_AutoController_BrightnessComponent_Mode_IsSupported(peak_afl_controller_handle controller, peak_afl_BOOL8 *supported)
Check if brightness component is supported for a controller component.
std::string ToString() const
Patch.
Definition: peak_afl.hpp:78
std::uint32_t subminor
Minor.
Definition: peak_afl.hpp:71
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:1548
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:283
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:1873
peak_afl_controller_automode
controller automode
Definition: peak_afl.h:140
std::vector< peak_afl_weighted_rectangle > GetWeightedROIs() const
Get the autofeature weighted region of interest for a controller.
Definition: peak_afl.hpp:1995
Definition: peak_afl.hpp:478
peak_afl_controller_automode GetMode() const
Get the current autofeature mode for a controller.
Definition: peak_afl.hpp:1578
void SetSkipFrames(std::uint32_t count)
Set number of frames skipped for a controller.
Definition: peak_afl.hpp:1471
void SetROI(peak_afl_rectangle rect)
Set the autofeature region of interest for a controller.
Definition: peak_afl.hpp:1516
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:1438
uint8_t peak_afl_BOOL8
custom boolean type
Definition: peak_afl.h:379
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:51
Success.
Definition: peak_afl.h:90
bool IsModeSupported() const
Check if auto mode is supported for a controller.
Definition: peak_afl.hpp:1557
std::uint32_t GetAutoTolerance() const
Get the current auto tolerance for a controller.
Definition: peak_afl.hpp:1687
Definition: peak_afl.hpp:67
bool IsAutoToleranceSupported() const
check if auto tolerance is supported for a controller.
Definition: peak_afl.hpp:1666
peak_afl_rectangle GetROI() const
Get the autofeature region of interest for a controller.
Definition: peak_afl.hpp:1525
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.
gain
Definition: peak_afl.h:234
bool IsBrightnessComponentModeSupported() const
Check if auto mode is supported for a brightness controller component.
Definition: peak_afl.hpp:2118
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:436
bool IsSharpnessAlgorithmSupported() const
check setting a sharpness algorithm is supported by a controller.
Definition: peak_afl.hpp:1818
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:184
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:1612
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:89
Not supported.
Definition: peak_afl.h:114
Version_t Version()
Query the library version.
Definition: peak_afl.hpp:1192
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:1752
std::uint8_t GetLastAutoAverage() const
Get the last auto average for a controller.
Definition: peak_afl.hpp:1601
Controller callback type processing data.
Definition: peak_afl.h:264
bool IsAutoTargetSupported() const
check if auto target is supported for a controller.
Definition: peak_afl.hpp:1623
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:1329
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:1229
Definition: peak_afl.hpp:457
Range< std::uint32_t > GetAutoTargetRange() const
Get the auto target range for a controller.
Definition: peak_afl.hpp:1655
void SetAutoPercentile(double percentile)
Set the auto percentile for a controller.
Definition: peak_afl.hpp:1721
void RemoveController(const std::shared_ptr< Controller > &controller)
Remove a controller from an automanager.
Definition: peak_afl.hpp:1303
peak_afl_controller_sharpness_algorithm GetSharpnessAlgorithm() const
Get the used sharpness algorithm for a controller.
Definition: peak_afl.hpp:1839
peak_afl_status peak_afl_AutoFeatureManager_Create(peak_afl_manager_handle *handle, PEAK_NODE_MAP_HANDLE nodeMapHandle)
Create an automanager instance.
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:1504
bool IsHysteresisSupported() const
Check if hysteresis is supported for a controller.
Definition: peak_afl.hpp:2060
void UnRegisterDataProcessingCallback()
Reset the finished callback for a controller.
Definition: peak_afl.hpp:1949
Definition: peak_afl.hpp:186
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:280
peak_afl_controller_limit GetDefaultLimit() const
Get the autofeature default limit.
Definition: peak_afl.hpp:2049
bool IsLimitSupported() const
Check if limit is supported for a controller.
Definition: peak_afl.hpp:2017
peak_afl_controller_status Status() const
Get the status for a controller.
Definition: peak_afl.hpp:1589
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:102
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:1569
void DestroyController(const std::shared_ptr< Controller > &controller)
Destroy a controller.
Definition: peak_afl.hpp:1364
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:108
peak_afl_status peak_afl_AutoFeatureManager_SetGainIPL(peak_afl_manager_handle handle, PEAK_IPL_GAIN_HANDLE gainHandle)
Set the IPL Gain.
Range< std::uint32_t > GetSkipFramesRange() const
Get range for frames skipped for a controller.
Definition: peak_afl.hpp:1492
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:70
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:1536
void SetLimit(peak_afl_controller_limit limit)
Set the autofeature limit for a controller.
Definition: peak_afl.hpp:2029
peak_afl Focus Rectangle
Definition: peak_afl.h:353
peak_afl_status peak_afl_AutoController_BrightnessComponent_Callback_Set(peak_afl_controller_handle controller, peak_afl_controller_brightness_component component, peak_afl_callback_type type, void *funcPtr, void *context)
Set a callback for a controller component.
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:1984
peak_afl_status peak_afl_AutoController_BrightnessComponent_Status(peak_afl_controller_handle controller, peak_afl_controller_brightness_component component, peak_afl_controller_status *status)
Get the status for a controller component.
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:108
void AddController(const std::shared_ptr< Controller > &controller)
Add a controller to an automanager.
Definition: peak_afl.hpp:1281
void SetGainIPL(const peak::ipl::Gain &gain)
Sets the ipl gain.
Definition: peak_afl.hpp:1383
double GetAutoPercentile() const
Get the auto percentile for a controller.
Definition: peak_afl.hpp:1730
void Process(const peak::ipl::Image &image) const
Process an image.
Definition: peak_afl.hpp:1320
Range< std::uint32_t > GetAutoToleranceRange() const
Get the auto tolerance range for a controller.
Definition: peak_afl.hpp:1698
peak_afl_status peak_afl_AutoController_AutoTolerance_Get(peak_afl_controller_handle controller, uint32_t *tolerance)
Get the current auto tolerance for a controller.
Invalid Parameter.
Definition: peak_afl.h:99
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_status peak_afl_AutoController_BrightnessComponent_Mode_Set(peak_afl_controller_handle controller, peak_afl_controller_brightness_component component, peak_afl_controller_automode mode)
Set the autofeature mode for a brightness component.
peak_afl_controller_status
controller status
Definition: peak_afl.h:156
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:105
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:49
bool IsAutoPercentileSupported() const
check if auto percentile is supported for a controller.
Definition: peak_afl.hpp:1709
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:1346
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:121
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.
peak_afl_controller_brightness_component
controller brightness component
Definition: peak_afl.h:228
Controller callback type finished.
Definition: peak_afl.h:261
Range< double > GetAutoPercentileRange() const
Get the auto percentile range for a controller.
Definition: peak_afl.hpp:1741
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:1243
bool Status() const
Get the status of a manager.
Definition: peak_afl.hpp:1392
bool IsSkipFramesSupported() const
Check if skip frames is supported for a controller.
Definition: peak_afl.hpp:1459
peak_afl_status peak_afl_AutoFeatureManager_DestroyController(peak_afl_manager_handle handle, peak_afl_controller_handle controller)
Destroy a controller.