leovandriel / cvplot

Graph plots, drawing, layout and windows in OpenCV
MIT License
124 stars 28 forks source link

Decouple from GLFW #40

Closed PatJRobinson closed 1 year ago

PatJRobinson commented 1 year ago

I really like this library and would like to use it in my project. However, its dependency on GLFW conflicts with the windowing system already being used with another dependency.

I do not see any reason for this coupling - is there a way to simply render figure to an OpenCV image so that I can do what I want with it, without requiring GLFW create window function to be called?

Thanks in advance.

PatJRobinson commented 1 year ago

Closed - managed to solve myself. Basically, the windowing used in this library was conflicting with the windowing used by another, causing the program to crash. I made the following changes in window.cc and everything works fine for my purposes:

Window::Window(std::string title)
    : offset_(0, 0),
      title_(std::move(title)),
      cursor_(-10, -10),
      name_("cvplot_" + std::to_string(clock())) {
  // cv::namedWindow(name_, cv::WINDOW_AUTOSIZE);     // causes conflicts
  // cv::setMouseCallback(name_, mouse_callback, this);     // causes conflicts
}
leovandriel commented 1 year ago

Hi @PatJRobinson, thanks for sharing how you addressed the issue. I had not considered your usecase, but it makes sense to use cvplot without rendering to the screen.