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

Function load_image

examples/main_image.cpp:209–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209static void load_image(app_state& app, const char* path) {
210 snprintf(app.status, sizeof(app.status), "Loading image: %s", path);
211 app.image = sam3_load_image(path);
212 if (app.image.data.empty()) {
213 snprintf(app.status, sizeof(app.status), "Failed to load image.");
214 return;
215 }
216 app.tex_image = upload_texture(app.image.data.data(),
217 app.image.width, app.image.height, 3, app.tex_image);
218 app.image_encoded = false;
219 app.result = {};
220 app.pos_points.clear();
221 app.neg_points.clear();
222 app.pos_exemplars.clear();
223 app.neg_exemplars.clear();
224 app.pvs_box = {0, 0, 0, 0};
225 app.has_pvs_box = false;
226
227 snprintf(app.status, sizeof(app.status), "Encoding image (%dx%d)...",
228 app.image.width, app.image.height);
229 app.busy = true;
230 if (sam3_encode_image(*app.state, *app.model, app.image)) {
231 app.image_encoded = true;
232 snprintf(app.status, sizeof(app.status), "Image encoded. Ready for segmentation.");
233 } else {
234 snprintf(app.status, sizeof(app.status), "Image encoding failed!");
235 }
236 app.busy = false;
237 build_overlay(app);
238}
239
240static void run_pcs(app_state& app) {
241 if (!app.image_encoded) return;

Callers 1

mainFunction · 0.85

Calls 4

sam3_load_imageFunction · 0.85
sam3_encode_imageFunction · 0.85
build_overlayFunction · 0.85
upload_textureFunction · 0.70

Tested by

no test coverage detected