Skip to content

A Windows build of sam3.cpp #5

@mimi3421

Description

@mimi3421

Thanks to the author and Claude to create this nice example for sam3 and ggml application.

I forked the project and made some adaptations so that the sam_image and sam_video modules can be compiled on Windows.

A sample release is here: https://github.com/mimi3421/sam3.cpp/releases/tag/main

The key changes were:

  1. Add -DCMAKE_BUILD_TYPE=Release and -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake in cmake build config in the workflow file.
  2. Add SDL2 and imGUI installation porcess in the workflow file.
  3. For main_image.cpp and main_video.cpp, add #define SDL_MAIN_HANDLED and change the loading order of the head files to avoid the duplicated declaration error. Change the opengl head file form GL/gl.h to SDL2/SDL_opengl.h to increase compatibility.
  4. For sam3.cpp, remove 2>/dev/null in all foreign FFMPEG calls and change the popen method from 'r' to 'rb' to avoid the auto newline translation in Windows cmd.
  5. For examples/third-party/CMakeLists.txt, change the target_compile_definitions from IMGUI_IMPL_OPENGL_LOADER_CUSTOM to IMGUI_IMPL_OPENGL_LOADER_NONE to let the SDL2 choose the opengl loader.

I'm not sure whether these changes would introduce new problems in other building platforms, maybe it would be better to let Claude to decide.

In addition, some bugs and suggestions are listed here:

  1. The exported file from sam3_image.exe always names mask00.png so that the old one is replaced.
  2. The GUI should work in a seperated thread so the program would not be halted when doing computation
  3. Maybe adding a Vulkan backend, which is also supported by ggml, is more favorable for other GPU host.
  4. Foreign calling of FFMPEG frame by frame is intolerability slow on Windows. Maybe it's better to use the shared library or utilizing some frame cache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions