Is it possible to use OpenCV module in PyScript?

3.5k views Asked by At

I want to use opencv module but I can't import OpenCV. So how can I solve this problem? By the way, Pyodide supports OpenCV.

Example Code

2

There are 2 answers

1
John Hanley On

OpenCV is not supported yet.

At this time, OpenCV requires pypi-json. Loading that package via Pyscript micropip throws a CORS error. Once that is fixed, I am not sure which other problems will surface.

This means some OpenCV dependencies must be corrected first.

[UPDATE]

This link infers that the Pyodide dev branch now supports openCV. I have not verified that information.

7
lukygee On

Have you loaded it as a module in your HTML?

  <py-env>
  - bokeh
  - numpy
    ....
  - OpenCV
  </py-env>