rollback experiments

pull/3471/head
kallaballa 2 years ago
parent 5aad32a7f7
commit ecefe5ff18
  1. 13
      src/common/subsystems.hpp
  2. 17
      src/optflow/optflow-demo.cpp

@ -262,11 +262,11 @@ static void error_callback(int error, const char *description) {
class Window { class Window {
cv::Size size_; cv::Size size_;
bool offscreen_; bool offscreen_;
string title_;
int major_; int major_;
int minor_; int minor_;
int samples_; int samples_;
bool debug_; bool debug_;
string title_;
GLFWwindow *glfwWindow_ = nullptr; GLFWwindow *glfwWindow_ = nullptr;
CLGLContext* clglContext_ = nullptr; CLGLContext* clglContext_ = nullptr;
CLVAContext* clvaContext_ = nullptr; CLVAContext* clvaContext_ = nullptr;
@ -276,8 +276,6 @@ class Window {
nanogui::Screen* screen_ = nullptr; nanogui::Screen* screen_ = nullptr;
nanogui::FormHelper* form_ = nullptr; nanogui::FormHelper* form_ = nullptr;
cv::TickMeter tickMeter_; cv::TickMeter tickMeter_;
std::mutex pollMutex_;
bool startPolling_ = false;
bool closed_ = false; bool closed_ = false;
public: public:
@ -579,9 +577,9 @@ public:
} }
bool display() { bool display() {
std::scoped_lock<std::mutex> lock(pollMutex_);
bool result = true; bool result = true;
if (!offscreen_) { if (!offscreen_) {
glfwPollEvents();
screen_->draw_contents(); screen_->draw_contents();
clglContext_->blitFrameBufferToScreen(); clglContext_->blitFrameBufferToScreen();
screen_->draw_widgets(); screen_->draw_widgets();
@ -589,16 +587,9 @@ public:
result = !glfwWindowShouldClose(glfwWindow_); result = !glfwWindowShouldClose(glfwWindow_);
} }
startPolling_ = true;
return result; return result;
} }
void pollEvents() {
std::scoped_lock<std::mutex> lock(pollMutex_);
if(startPolling_)
glfwPollEvents();
}
bool isClosed() { bool isClosed() {
return closed_; return closed_;

@ -184,10 +184,9 @@ void composite_layers(const cv::UMat background, const cv::UMat foreground, cons
} }
void setup_gui(cv::Ptr<kb::Window> window) { void setup_gui(cv::Ptr<kb::Window> window) {
window->makeWindow(6, 45, "Settings"); window->makeWindow(5, 45, "Settings");
auto useOpenCL = window->makeFormVariable("Use OpenCL", use_opencl, "Enable or disable OpenCL acceleration");
window->makeFormVariable("Use OpenCL", use_opencl, "Enable or disable OpenCL acceleration");
window->makeGroup("Foreground"); window->makeGroup("Foreground");
window->makeFormVariable("Scale", fg_scale, 0.1f, 4.0f, true, "", "Generate the foreground at this scale"); window->makeFormVariable("Scale", fg_scale, 0.1f, 4.0f, true, "", "Generate the foreground at this scale");
window->makeFormVariable("Loss", fg_loss, 0.1f, 99.9f, true, "%", "On every frame the foreground loses on brightness"); window->makeFormVariable("Loss", fg_loss, 0.1f, 99.9f, true, "%", "On every frame the foreground loses on brightness");
@ -233,9 +232,8 @@ int main(int argc, char **argv) {
exit(1); exit(1);
} }
cv::Ptr<kb::Window> window = new kb::Window(cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Sparse Optical Flow Demo"); cv::Ptr<kb::Window> window = new kb::Window(cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Sparse Optical Flow Demo");
std::thread worker([&]() {
window->initialize(); window->initialize();
kb::print_system_info(); kb::print_system_info();
setup_gui(window); setup_gui(window);
@ -302,15 +300,6 @@ int main(int argc, char **argv) {
if(!window->display()) if(!window->display())
break; break;
} }
window->close();
});
while(!window->isClosed()) {
window->pollEvents();
std::this_thread::sleep_for(10ms);
}
worker.join();
return 0; return 0;
} }

Loading…
Cancel
Save