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

Function main

examples/main_video.cpp:359–1036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357// ── Main ─────────────────────────────────────────────────────────────────────
358
359int main(int argc, char** argv) {
360 vapp_state app;
361 app.params.n_threads = 4;
362 app.params.use_gpu = true;
363
364 // Parse args
365 for (int i = 1; i < argc; ++i) {
366 if (strcmp(argv[i], "--model") == 0 && i+1 < argc) {
367 app.params.model_path = argv[++i];
368 } else if (strcmp(argv[i], "--video") == 0 && i+1 < argc) {
369 app.video_path = argv[++i];
370 } else if (strcmp(argv[i], "--threads") == 0 && i+1 < argc) {
371 app.params.n_threads = atoi(argv[++i]);
372 } else if (strcmp(argv[i], "--no-gpu") == 0) {
373 app.params.use_gpu = false;
374 } else if (strcmp(argv[i], "--encode-img-size") == 0 && i+1 < argc) {
375 app.params.encode_img_size = atoi(argv[++i]);
376 } else if (strcmp(argv[i], "--help") == 0) {
377 fprintf(stderr,
378 "Usage: %s --model <path.ggml> --video <path>\n"
379 " [--threads N] [--no-gpu] [--encode-img-size N]\n", argv[0]);
380 return 0;
381 }
382 }
383
384 if (app.params.model_path.empty()) {
385 fprintf(stderr, "Error: --model is required.\n");
386 return 1;
387 }
388
389 // ── Init SDL2 + OpenGL ───────────────────────────────────────────────────
390
391 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
392 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
393 return 1;
394 }
395
396#ifdef __APPLE__
397 SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
398 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
399 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
400 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
401 const char* glsl_version = "#version 150";
402#else
403 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
404 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
405 const char* glsl_version = "#version 130";
406#endif
407
408 std::string init_title = basename_of(app.params.model_path);
409 if (!app.video_path.empty()) {
410 init_title = basename_of(app.video_path) + " \xe2\x80\x94 " + init_title;
411 }
412
413 SDL_Window* window = SDL_CreateWindow(
414 init_title.c_str(),
415 SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
416 1280, 800,

Callers

nothing calls this directly

Calls 15

sam3_load_modelFunction · 0.85
sam3_create_stateFunction · 0.85
sam3_is_visual_onlyFunction · 0.85
sam3_get_model_typeFunction · 0.85
sam3_get_video_infoFunction · 0.85
create_trackerFunction · 0.85
decode_and_trackFunction · 0.85
sam3_decode_video_frameFunction · 0.85
clear_init_promptsFunction · 0.85
build_frame_overlayFunction · 0.85
find_instance_atFunction · 0.85
sam3_refine_instanceFunction · 0.85

Tested by

no test coverage detected