MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / find_instance_at

Function find_instance_at

examples/main_video.cpp:277–288  ·  view source on GitHub ↗

Check if a click position lands on any tracked instance mask. Returns the instance_id or -1.

Source from the content-addressed store, hash-verified

275// Check if a click position lands on any tracked instance mask.
276// Returns the instance_id or -1.
277static int find_instance_at(const vapp_state& app, float ix, float iy) {
278 int px = (int)ix, py = (int)iy;
279 for (const auto& det : app.result.detections) {
280 if (det.mask.data.empty()) continue;
281 if (px >= 0 && px < det.mask.width &&
282 py >= 0 && py < det.mask.height &&
283 det.mask.data[py * det.mask.width + px] > 127) {
284 return det.instance_id;
285 }
286 }
287 return -1;
288}
289
290static void add_instance_from_prompts(vapp_state& app) {
291 if (!app.tracker_created || !app.frame_encoded) return;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected