17#include <peak_icv_c/selectors/peak_icv_region_selector.h>
119 template <
typename T>
123 std::vector<Region> m_regions;
126inline RegionSelector::RegionSelector(
const std::vector<Region>& regions)
127 : m_regions{ regions }
137 return SelectBy<peak::common::IntervalU>(
138 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByArea_GetCount, PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByArea, interval);
143 return SelectBy<peak::common::IntervalF>(PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityX_GetCount,
144 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityX, interval);
149 return SelectBy<peak::common::IntervalF>(PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityY_GetCount,
150 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityY, interval);
155 return SelectBy<peak::common::RectangleF>(PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityRect_GetCount,
156 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityRect, rect);
164 if (m_regions.empty())
169 std::vector<peak_icv_region_handle> handles;
170 handles.reserve(m_regions.size());
172 std::transform(m_regions.begin(), m_regions.end(), std::back_inserter(handles), [](
const auto& region) {
173 return peak::common::detail::BackendAccessor<peak::icv::Region>::BackendHandle(region);
178 return selectByGetCount(
179 handles.data(), handles.size(), peak::common::detail::BackendAccessor<T>::CreateCType(interval), &count);
187 std::vector<peak_icv_region_handle> selectedHandles(count);
189 return selectBy(handles.data(), handles.size(), peak::common::detail::BackendAccessor<T>::CreateCType(interval),
190 selectedHandles.data(), selectedHandles.size());
192 return RegionSelector(peak::common::detail::BackendAccessor<peak::icv::Region>::CreateInstances(selectedHandles));
Represents a continuous numeric interval with inclusive lower and upper bounds.
A generic rectangle defined by a point and a size.
Selects regions based on feature criteria.
RegionSelector SelectByArea(const peak::common::IntervalU &interval)
Selects regions by area.
RegionSelector SelectByCenterOfGravityRect(const peak::common::RectangleF &rect)
Selects regions by center of gravity within a rectangle.
std::vector< Region > GetRegions()
RegionSelector SelectByCenterOfGravityY(const peak::common::IntervalF &interval)
Selects regions by center of gravity Y.
RegionSelector SelectByCenterOfGravityX(const peak::common::IntervalF &interval)
Selects regions by center of gravity X.
RegionSelector(const std::vector< Region > ®ions)
Constructs a selector for the specified set of regions.
typename c_type_of_< Type >::type c_type_of_t
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
std::function< peak_icv_status(peak_icv_region_handle *, size_t, T, peak_icv_region_handle *, size_t)> select_by_function_t
std::function< peak_icv_status(peak_icv_region_handle *, size_t, T, size_t *)> select_by_get_count_function_t