| 207 | } |
| 208 | |
| 209 | static 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 | |
| 240 | static void run_pcs(app_state& app) { |
| 241 | if (!app.image_encoded) return; |
no test coverage detected