Unable to run tune_blockmatcher and image_to_pointcloud programs - opencv

I am able to capture images on webcams and calibrate them well using
StereoVision library from erget.
But, while trying for execution of tune_blockmatcher and images_to_pointcloud, i found below errors as StereoBM and StereoSGBM classes are unable to import.
>import cv2
>from stereovision.blockmatchers import StereoBM, StereoSGBM
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\stereovision\blockmatchers.py", line 111,
in <module>
class StereoBM(BlockMatcher):
File "C:\Python27\lib\site-packages\stereovision\blockmatchers.py", line 117,
in StereoBM
"stereo_bm_preset": cv2.STEREO_BM_NARROW_PRESET}
AttributeError: 'module' object has no attribute 'STEREO_BM_NARROW_PRESET'
>`
C:\s\StereoVision-master\stereovision>python tune_blockmatcher.py
Traceback (most recent call last):
File "tune_blockmatcher.py", line 34, in <module>
from stereovision.blockmatchers import StereoBM, StereoSGBM
File "build\bdist.win-amd64\egg\stereovision\blockmatchers.py", line 111, in <
module>
class StereoBM(BlockMatcher):
File "build\bdist.win-amd64\egg\stereovision\blockmatchers.py", line 117, in S
tereoBM
"stereo_bm_preset": cv2.STEREO_BM_NARROW_PRESET}
AttributeError: 'module' object has no attribute 'STEREO_BM_NARROW_PRESET'
OS i am running is Windows7, running OPENCV 3.4.0 and Python2.7, installed stereovision library with 'pip install StereoVision'
Any solution for this issue ?

You are facing this issue because the StereoVision framework provided by Daniel Lee does not work with OpenCV 3.
First of all, uninstall OpenCV 3 from your machine.
Then install OpenCV 2 and retry: your problem will be gone.
Hope this helps

Related

After importing opencv-python , the corresponding functions don't work

I'm new to learning on opencv-python.
So I started by creating a new python project named OpenCV and then imported opencv-python package and then started typing in my code in a new Python file. But once I try running the file I keep getting error.
Code And Error img
It seems as if imread() and imshow() - none are accepted.
I tried importing imread() separately by using cmd and my terminal but nothing seems to works.
It further shows legacy error.
import cv2
img = cv2.imread('lena.jpg', 1)
print(img)
cv2.imshow('image', img)
cv2.waitKey(10000)
cv2.destroyAllWindows()
My error:
Traceback (most recent call last):
File "/Users/mac/myprojects/opencv/read_and_display_image.py", line 1, in
import cv2
File "/Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/init.py", line 181, in
bootstrap()
File "/Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/init.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dlopen(/Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: _VTRegisterSupplementalVideoDecoderIfAvailable
Referenced from: /Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/.dylibs/libavcodec.59.37.100.dylib
Expected in: /System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox
in /Users/mac/myprojects/opencv/openenv/lib/python3.9/site-packages/cv2/.dylibs/libavcodec.59.37.100.dylib

getting error - can someone please suggest

(cdt_env) saurabh#DESKTOP-IQ51Q9S:~/git/Engineering/developer-tools$ cdt --help
Traceback (most recent call last):
File "/home/saurabh/cdt_env/bin/cdt", line 2, in
from cdt.cli import cli
File "/home/saurabh/cdt_env/lib/python3.8/site-packages/cdt/init.py", line 1, in
from common import (
ModuleNotFoundError: No module named 'common'
(cdt_env) saurabh#DESKTOP-IQ51Q9S:~/git/Engineering/developer-tools$

Python test fails printing dependency on local package

I thought that bazel runs tests in sandbox, but recently I got an error pointing to a local module /usr/lib/python3/dist-packages/OpenSSL/SSL.py. It it correct? How to make bazel run in a sandbox?
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //master:master_impl_test
-----------------------------------------------------------------------------
Traceback (most recent call last):
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/__main__/master/master_impl_test.py", line 14, in <module>
from master import master_impl
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/__main__/master/master_impl.py", line 20, in <module>
from azure.cosmos import cosmos_client
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__azure_cosmos/azure/cosmos/cosmos_client.py", line 25, in <module>
import requests
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__requests/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__urllib3/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 675, in <module>
_lib.Cryptography_HAS_TLSEXT_HOSTNAME, "SNI not available"
AttributeError: module 'lib' has no attribute 'Cryptography_HAS_TLSEXT_HOSTNAME'
Today my project's CI get this error. I fixed this problem in my project, just upgrading pyOpenSSL library to latest version.
Old requirements-file.txt:
requests
pyOpenSSL==19.0.0
urllib3==1.25.3
New requirements-file.txt:
cffi==1.14.4
cryptography==3.3
pycparser==2.20
pyOpenSSL==20.0.0
six==1.15.0
urllib3==1.25.3

Console problem in Spyder showing: an error ocurred while starting the kernel [duplicate]

Spyder console is showing an error msg:
An error ocurred while starting the kernel
Traceback (most recent call last): File "C:\Users\ABCD\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Users\ABCD\Anaconda3\lib\runpy.py",
line 85, in _run_code exec(code, run_globals) File "C:\Users\ABCD\Anaconda3\lib\site‑packages\spyder_kernels\console\__main__.py",
line 11, in start.main() File "C:\Users\ABCD\Anaconda3\lib\site‑packages\spyder_kernels\console\start.py",
line 287, in main import_spydercustomize() File "C:\Users\ABCD\Anaconda3\lib\site‑packages\spyder_kernels\console\start.py",
line 39, in import_spydercustomize import spydercustomize File "C:\Users\ABCD\Anaconda3\lib\site‑packages\spyder_kernels\customize\spydercustomize.py",
line 27, in from IPython.core.getipython import get_ipython File "C:\Users\ABCD\Anaconda3\lib\site‑packages\IPython\__init__.py",
line 55, in from .terminal.embed import embed File "C:\Users\ABCD\Anaconda3\lib\site‑packages\IPython\terminal\embed.py",
line 17, in from IPython.terminal.ipapp import load_default_config File "C:\Users\ABCD\Anaconda3\lib\site‑packages\IPython\terminal\ipapp.py",
line 28, in from IPython.core.magics import ( File "C:\Users\ABCD\Anaconda3\lib\site‑packages\IPython\core\magics\__init__.py",
line 18, in from .code import CodeMagics, MacroToEdit File "C:\Users\ABCD\Anaconda3\lib\site‑packages\IPython\core\magics\code.py",
line 23, in from urllib.request import urlopen File "C:\Users\ABCD\Anaconda3\lib\urllib\request.py",
line 86, in import email File "C:\Users\ABCD\email.py",
line 8, in n=input() EOFError: EOF when reading a line
What I understood on reading other threads about similar kind of problems , that this is due to having two python versions installed
So, I tried manually removing all python files (as I was unable to uninstall python) and then uninstalled and reinstalled anaconda (spyder) but the problem persists
Any kind of help wd be appreciated
Short answer: To fix this problem, you need to remove or rename this file:
C:\Users\ABCD\email.py
Long answer: That file has the same name of a core Python module. Since it's placed in your home directory, it has higher priority than that module, which makes Python to use it first and ends up causing the error.

Unable to launch spyder

I get this error when I launch Spyder through cmd
Also, I can't run it by clicking the shortcut
Traceback (most recent call last):
File "C:\Akash Shanmugaraj\anaconda3\Scripts\spyder-script.py", line 6, in <module>
from spyder.app.start import main
File "C:\Akash Shanmugaraj\anaconda3\lib\site-packages\spyder\app\start.py", line 22, in <module>
import zmq
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: cannot import name 'constants' from partially initialized module 'zmq.backend.cython' (most likely due to a circular import) (C:\Users\Akash Shanmugaraj\AppData\Roaming\Python\Python38\site-packages\zmq\backend\cython\__init__.py)
I had the same problem. "activate base" didn't help, but just found a solution. Certainly not quite correct, but it works.
Go to folder:
C:\Users\<your_login>\AppData\Roaming\Python
and rename it ("Python") on "Python_x" or something else.
Spyder and Navigator starts up and so far everything works, but don't delete that folder.
In cmd try activating the base environment(or any other relevant environment) by running
activate base
and then try running spyder.

Resources