2

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
  • Please provide enough code so others can better understand or reproduce the problem. Commented May 11, 2022 at 11:05
  • Do not use links to provide question details. Create self-contained questions. Links change, break, etc rendering your question useless in the future. Commented May 11, 2022 at 17:45

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Mr. John, thanks a lot for your answer.
1

Have you loaded it as a module in your HTML?

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

7 Comments

I added as <py-env> - cv2 <py-env>.
Are you also importing as usual in your file? Try opencv-python. Do you get an error when you try to use the module?
the import is called cv2 but the PyPI package is called opencv-python
As I understand, I editted the question part. You can find example code in "Example Code".
@Yılmaz ALACA I'm confused then. Did it work yet? If that is the solution that works, make it clear in the edited answer. Plus, don't put in code as an image. You'll want to put it in as a text code block. I like the second and third way listed here. Those options will serve you well posting code at StackOverflow here and in the future.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.