1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

opencv.js の独自ビルド

Last updated at Posted at 2022-10-28

スリムな opencv.js がほしいので

wasmで動作している opencv.js ですが、ファイルサイズが大きいのがイマイチです。自分の使う機能だけを入れたシェイプアップ版を作りたくなりました。

いや、公式がビルドした opencv.js ファイルをほしいという場合

こちらで説明されています。

(1) dockerでなるべく簡単にビルドする

見つけたのは下記の記事。

サクッとビルドは終わったのですが、できあがったopencv.jsを使用してテストしたところ、なんだかエラーが出てうまくいきませんでした。
具体的には、"Uncaught TypeError: cv.imread is not a function" が発生します。

(2) うごくビルドを作るには?

下記を見ると、emsdk 1.39.15 を使うとうまくいくよ、とあります。

(1) と (2) を組み合わせる

下記のようにしたところ、cv.imread() も問題ないバージョンが作れたようです。
皆さんの情報に感謝。

mkdir build_opencvjs
cd build_opencvjs/
git clone https://github.com/opencv/opencv.git
cd opencv/
docker run --rm --workdir /code -v "$PWD":/code "trzeci/emscripten:1.39.15-upstream" python ./platforms/js/build_js.py build
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?