emscripten adaptions

pull/3471/head
kallaballa 2 years ago
parent 9081dc6078
commit 650f3bc553
  1. 4
      Makefile
  2. 4
      src/common/viz2d.cpp
  3. 9
      src/optflow/optflow-demo.cpp

@ -17,8 +17,8 @@ endif
ifdef EMSDK
CXX := em++
EMCXXFLAGS += -flto -sINITIAL_MEMORY=512MB -sTOTAL_MEMORY=512MB -s USE_PTHREADS=1 -pthread -msimd128
EMLDFLAGS += -sUSE_GLFW=3 -sMAX_WEBGL_VERSION=2 -sUSE_ZLIB=1 -sWASM=1 -sWASM_BIGINT -sINITIAL_MEMORY=512MB -sTOTAL_MEMORY=512MB -sALLOW_MEMORY_GROWTH=1 -sUSE_PTHREADS=1 -pthread -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency -sLLD_REPORT_UNDEFINED --bind
EMCXXFLAGS += -flto -s USE_PTHREADS=1 -pthread -msimd128
EMLDFLAGS += -sUSE_GLFW=3 -sMAX_WEBGL_VERSION=2 -sUSE_ZLIB=1 -sWASM=1 -sWASM_BIGINT -sINITIAL_MEMORY=512MB -sTOTAL_MEMORY=512MB -sUSE_PTHREADS=1 -pthread -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency -sLLD_REPORT_UNDEFINED --bind
CXXFLAGS += $(EMCXXFLAGS) -c
LDFLAGS += $(EMLDFLAGS)
endif

@ -757,7 +757,11 @@ bool Viz2D::display() {
makeCurrent();
glfwPollEvents();
screen().draw_contents();
#ifndef __EMSCRIPTEN__
clglContext_->blitFrameBufferToScreen(getViewport(), getWindowSize(), isStretching());
#else
clglContext_->blitFrameBufferToScreen(getViewport(), getInitialSize(), isStretching());
#endif
screen().draw_widgets();
glfwSwapBuffers(glfwWindow_);
result = !glfwWindowShouldClose(glfwWindow_);

@ -75,10 +75,10 @@ std::string pushImage(std::string filename){
cv::Mat v = videoFrame.getMat(cv::ACCESS_RW);
cvtColor(v, tmp, cv::COLOR_RGB2BGRA);
fs.read((char*)(tmp.data), tmp.elemSize() * tmp.total());
cvtColor(tmp, v, cv::COLOR_RGBA2BGR);
cvtColor(tmp, v, cv::COLOR_BGRA2BGR);
v.release();
tmp.release();
cerr << "match" << endl;
// cerr << "match" << endl;
} else {
cerr << "mismatch" << endl;
}
@ -412,9 +412,10 @@ void setup_gui(cv::Ptr<kb::viz2d::Viz2D> v2d, cv::Ptr<kb::viz2d::Viz2D> v2dMenu)
v2d->makeWindow(220, 175, "Settings");
#ifndef __EMSCRIPTEN__
v2d->makeGroup("Hardware Acceleration");
v2d->makeFormVariable("Enable", use_acceleration, "Enable or disable libva and OpenCL acceleration");
#endif
v2d->makeGroup("Scene Change Detection");
v2d->makeFormVariable("Threshold", scene_change_thresh, 0.1f, 1.0f, true, "", "Peak threshold. Lowering it makes detection more sensitive");
v2d->makeFormVariable("Threshold Diff", scene_change_thresh_diff, 0.1f, 1.0f, true, "", "Difference of peak thresholds. Lowering it makes detection more sensitive");
@ -423,11 +424,11 @@ void setup_gui(cv::Ptr<kb::viz2d::Viz2D> v2d, cv::Ptr<kb::viz2d::Viz2D> v2dMenu)
v2dMenu->makeGroup("Display");
v2dMenu->makeFormVariable("Show FPS", show_fps, "Enable or disable the On-screen FPS display");
#ifndef __EMSCRIPTEN__
v2dMenu->makeFormVariable("Stetch", stretch, "Stretch the frame buffer to the window size")->set_callback([=](const bool &s) {
v2d->setStretching(s);
});
#ifndef __EMSCRIPTEN__
v2dMenu->makeButton("Fullscreen", [=]() {
v2d->setFullscreen(!v2d->isFullscreen());
});

Loading…
Cancel
Save