MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ region_rect()

PixelRect MayaFlux::Yantra::VisionInternal::region_rect ( const std::optional< Kinesis::Vision::BoundingBox > &  region,
uint32_t  w,
uint32_t  h 
)
inline

Pixel rectangle of a normalised region over a w x h image, clamped to the image.

No region is the whole image. A region that clamps to nothing gives an empty rectangle, which masks everything.

Definition at line 89 of file DispatchLayouts.hpp.

91{
92 if (!region)
93 return { .x0 = 0U, .y0 = 0U, .x1 = w, .y1 = h };
94
95 const auto fw = static_cast<float>(w);
96 const auto fh = static_cast<float>(h);
97 const auto clamp_to = [](float v, uint32_t hi) {
98 return static_cast<uint32_t>(std::clamp(v, 0.0F, static_cast<float>(hi)));
99 };
100 return {
101 .x0 = clamp_to(std::floor(region->x * fw), w),
102 .y0 = clamp_to(std::floor(region->y * fh), h),
103 .x1 = clamp_to(std::ceil((region->x + region->w) * fw), w),
104 .y1 = clamp_to(std::ceil((region->y + region->h) * fh), h),
105 };
106}
uint32_t h
Definition InkPress.cpp:29

References h, and MayaFlux::Yantra::VisionInternal::PixelRect::x0.

Referenced by MayaFlux::Yantra::VisionGpuExecutor::op_extract_peaks(), MayaFlux::Yantra::VisionGpuExecutor::op_harris_response(), and MayaFlux::Yantra::VisionGpuExecutor::op_track_keypoints().

+ Here is the caller graph for this function: