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

◆ crops()

std::shared_ptr< Core::VKImage > MayaFlux::Yantra::VisionExtractor::crops ( const std::shared_ptr< Core::VKImage > &  source,
const Kinesis::Vision::VisionAnalysis &  analysis,
uint32_t  tile_w,
uint32_t  tile_h 
)

Every find_elements box resampled to tile_w x tile_h, side by side in one atlas (tile_w * count, tile_h), in box order.

Definition at line 362 of file VisionExtractor.cpp.

366{
367 if (!analysis.find_elements || analysis.find_elements->boxes.empty() || tile_w == 0 || tile_h == 0)
368 return nullptr;
369
370 const auto& boxes = analysis.find_elements->boxes;
371 const auto count = static_cast<uint32_t>(boxes.size());
372
373 std::vector<float> rects;
374 rects.reserve(boxes.size() * 4);
375 for (const auto& b : boxes)
376 rects.insert(rects.end(), { b.x, b.y, b.w, b.h });
377
378 auto& ctx = image_context();
379 use_shader(ctx, "vision_region_atlas.comp.spv", k_wg_image, sizeof(AtlasPC));
380 ctx.stage_image(source);
381 ctx.set_binding_data(3, std::span<const float>(rects));
382 ctx.set_push_constants(AtlasPC { .tile_w = tile_w, .tile_h = tile_h, .count = count });
383 return dispatch_image(ctx, tile_w * count, tile_h);
384}
size_t b
size_t count
uint32_t tile_h
uint32_t tile_w
TextureExecutionContext & image_context()
The two contexts every method shares, one shader swapped in per call.

References b, count, MayaFlux::Kinesis::Vision::VisionAnalysis::find_elements, image_context(), tile_h, and tile_w.

Referenced by run_operation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: