Coder Social home page Coder Social logo

uniapp-opencv's Introduction

uniapp-opencv

介绍

基于opencv-ts对uni-app做了适配,目前支持H5、微信小程序、App,其中微信小程序适配参考了WeChat-MiniProgram-AR-WASM

使用方法

import cv from '@/uni_modules/zj-opencv';
cv.then(async () => {
    const src = await cv.imread('first');
    const dst = new cv.Mat();
    cv.cvtColor(src, dst, cv.COLOR_RGBA2GRAY, 0);
    await cv.imshow('second', dst);
    src.delete();
    dst.delete();
});

具体可参考Demo

注意事项

  • 由于uniapp中部分方法需要异步调用,原imreadimshow方法改为了异步方法,返回的是Promise对象,调用时需要在前面加await或在then里面执行后续操作。
  • imreadimshow方法暂时只支持传入canvasid,注意不是canvas-id
  • Mat对象用完一定要调用delete方法,否则会造成OOM。
  • 微信小程序中如果使用的不是2d的canvas,调试工具不支持canvasPutImageData,需要在真机中预览。
  • Typescript中使用时,如果引入的路径为绝对路径如@/uni_modules/zj-opencv,需要修改tsconfig.json文件。
{
  "compilerOptions": {
    ...
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  },
  ...
}
  • 字节小程序在调试工具上运行会报错,需要在真机上预览
  • 字节小程序不支持压缩过的wasm文件,由于上传的大小限制所以只编译了图像处理的模块

其他

opencv.js修改明细

uniapp-opencv's People

Contributors

zhangjian4 avatar

Stargazers

Satellite_R63 avatar  avatar 重庆森林 avatar  avatar  avatar  avatar Xue Lu Lu avatar

Watchers

 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.