1

I am trying to build opencv from it's github repo manually and use it in the virtual python environment. I am unable to import opencv.

Previously I got the error as mentioned Here. The solution is to downgrade numpy I tried that but now I am getting this error. Can someone point out what might be the issue.




Traceback (most recent call last): File "/home/sb/opencv_zoo/benchmark/benchmark.py", line 6, in <module> import cv2 as cv

 File "/home/belwals/env_cv/lib/python3.11/site-packages/cv2/_init__.py", line 181, in <module> bootstrap()
File "/home/sb/env_cv/lib/python3.11/site-packages/cv2/_init_.py", line 175, in bootstrap
  if_load_extra_py_code_for_module("cv2", submodule, DEBUG):

File "/home/sb/env_cv/lib/python3.11/site-packages/cv2/_init__.py", line 28, in.      _load_extra_py_code_for_module
py_module = importlib.import_module(module_name)

File "/usr/lib/python3.11/importlib/_init__.py", line 126, in import_module.  return_bootstrap._gcd_import (name[level:], package, level)

File "/home/sb/env_cv/lib/python3.11/site-packages/cv2/typing/_init__.py", line 135
cv::Vec2d=_typing.Sequence[float]
A
SyntaxError: invalid syntax
7
  • I have to ask: why? there are binary packages of opencv-python available for all the major systems. Commented Nov 12 at 11:25
  • why is your traceback faulty? did you take a photo of a computer screen and have some AI turn it into text? Commented Nov 12 at 11:28
  • @ChristophRackwitz want to do some experiments with opencv repo by making some changes in few kernels. Yes it is some AI turning into text but it is correct please bear with it🙂. Commented Nov 12 at 11:58
  • 1
    I believe you have two version of OpenCV. one you install it using pip and another one is from your build. You can do something like this: rm -rf env_cv python3.11 -m venv env_cv source env_cv/bin/activate pip uninstall opencv-python opencv-contrib-python opencv-python-headless -y then if you built from source using cmake "delete your environment variable, create new one, uninstall opencv using pip (cross-check) and again build it from scratch" Commented Nov 12 at 16:09
  • also with import cv2 do you get an error? By sharing also how you built it could be helpful Commented Nov 12 at 16:25

1 Answer 1

2

Its a bug in bindings generator. You can replace this cv::Vec2d to Vec2d in this file calib3d.hpp

Reference from Open-CV issues

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

Comments

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.