pythonopencvvirtualenv

Not able to build opencv manually in python env


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

Solution

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

    Reference from Open-CV issues