GithubHelp home page GithubHelp logo

gustavohra / opencvjs-separate-wasm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vitalyros/opencvjs-separate-wasm

0.0 0.0 0.0 2.31 MB

Build of opencv.js with separate js and wasm files

opencvjs-separate-wasm's Introduction

Opencv JS separate wasm build

Build of opencv.js with separate js and wasm files

Version of this npm package corresponds with opencv version

How to use?

  • install with npm npm install @vitalyros/opencvjs-separate-wasm
  • make node_modules/@vitalyros/opencvjs-separate-wasm/opecvjs.wasm file accessible for fetch requests. This depends on where you want to store this wasm file. If you don't need to store it separately from js file, then why are you using this? Use the common package.
  • In your javascript
    • import default from javascript part of the package import {default as initOpencvJs} from "@vitalyros/opencvjs-separate-wasm"; FYI this is a factory function see MODULARIZE=1 in emscripten docs
    • fetch wasm let wasm = await fetch("http://mysite/opencvjs.wasm");
    • turn wasm into a buffer let buffer = await wasm.arrayBuffer();
    • initialize opencv.js cv = await initOpencvJs({wasmBinary: buffer});
    • use cv as described in opencv.js docs

e.g. for wasm stored as separate file in web extension

import {default as initOpencvJs} from "@vitalyros/opencvjs-separate-wasm";

var cv;

(async() => {
    let url = browser.extension.getURL("./dist/ext/opencv/opencv.wasm");
    let wasm = await fetch(url);
    let buffer = await wasm.arrayBuffer();
    cv = await initOpencvJs({
        wasmBinary: buffer
    });
    // cv.imread(image)
})();

opencvjs-separate-wasm's People

Contributors

vitalyros avatar

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.