| 12264 | *****************************************************************************/ |
| 12265 | |
| 12266 | sam3_image sam3_load_image(const std::string& path) { |
| 12267 | sam3_image img; |
| 12268 | int w, h, c; |
| 12269 | uint8_t* data = stbi_load(path.c_str(), &w, &h, &c, 3); |
| 12270 | if (!data) { |
| 12271 | fprintf(stderr, "%s: failed to load '%s'\n", __func__, path.c_str()); |
| 12272 | return img; |
| 12273 | } |
| 12274 | img.width = w; |
| 12275 | img.height = h; |
| 12276 | img.channels = 3; |
| 12277 | img.data.assign(data, data + w * h * 3); |
| 12278 | stbi_image_free(data); |
| 12279 | return img; |
| 12280 | } |
| 12281 | |
| 12282 | bool sam3_save_mask(const sam3_mask& mask, const std::string& path) { |
| 12283 | if (mask.data.empty()) return false; |