Coder Social home page Coder Social logo

opencv-web's Introduction

Compiled OpenCV following OpenCV tutorial and opencv-wasm targeting web environment.

Install

npm install opencv-web

To specify a custom path for the opencv_js.wasm file, replace PATHTOWASMFILE in the code snippet below and add it to your HTML file.

    <script>
      var Module = {
        locateFile: function(s) {
          return PATHTOWASMFILE+ s;
        }
      };
    </script> 

Compile process

./utils/build.sh

WASM=1: This flag ensures that the output is in WebAssembly format. Emscripten supports both asm.js and WebAssembly, and this flag specifies the use of WebAssembly.

NO_EXIT_RUNTIME=1: By setting this flag, the runtime does not shut down after the main function finishes executing. This is useful for applications that need to continue running after the main function completes, such as those that use async functions or handle events.

EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun']: This flag specifies additional runtime methods to be exported. The addOnPostRun method allows you to add functions that will be called after the main function has executed. This is useful for initializing code or handling tasks that need to occur post-execution.

ASSERTIONS=1: Enabling assertions includes runtime checks to help catch common errors and issues during development. This is useful for debugging, but these checks can be disabled in a production build to improve performance.

ALLOW_MEMORY_GROWTH=1: This flag allows the memory used by the WebAssembly module to grow dynamically. By default, WebAssembly memory is fixed in size, but enabling memory growth can help handle cases where the application needs more memory than initially allocated.

SINGLE_FILE=0: This flag controls whether to output a single file or separate files for the JavaScript and WebAssembly code. Setting it to 0 means that the output will be split into multiple files (a separate .wasm file and a .js file).

ENVIRONMENT=web: This flag specifies the target environment for the compiled code. Setting it to web indicates that the code is intended to run in a web browser environment.

EXPORT_ES6=1: This flag specifies that the output JavaScript module should use ES6 module syntax (import and export). This makes the generated code compatible with modern JavaScript module systems.

USE_ES6_IMPORT_META=0: This flag controls the use of the ES6 import.meta construct. Setting it to 0 disables the use of import.meta, which might be necessary for compatibility with certain JavaScript environments that do not support this feature.

MODULARIZE=1: This flag makes the output JavaScript code modular, meaning the WebAssembly module is wrapped in a function. This allows for better integration with JavaScript module systems and can help with namespace management.

opencv-web's People

Contributors

iishiishii avatar

Stargazers

Roman Fedorov avatar

Watchers

 avatar

opencv-web's Issues

Missing types, can't even build them with electron-rebuild

Good evening, I 've stumbled upon this package, as it it ideal for electron, but there is an issue with missing types.

Can you generate them and release an updated packages with all the types?

Electron rebuild doesn't work by default, so we can't even use it effectively(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.