opencv import error (libopencv_dnn.so.4.5 undefined symbol) - opencv

I'd like to utilize my Movidius Neural Compute Stick 1 (NCS1) to learn deep learning.
However, when I run a sample code, the following import error occurs:
python3 emotion.py -i sample.jpg -o result.jpg
Traceback (most recent call last):
File "emotion.py", line 1, in <module>
import cv2
File "/opt/intel/openvino/python/python3/cv2/__init__.py", line 129, in <module>
bootstrap()
File "/opt/intel/openvino/python/python3/cv2/__init__.py", line 112, in bootstrap
import cv2
ImportError: /opt/intel/openvino/opencv/lib/libopencv_dnn.so.4.5:
undefined symbol: _ZN15InferenceEngine5TBlobIhSt9enable_ifILb1EvEED1Ev
I'm using a Raspberry Pi 3B.
The OS is Raspberry Pi OS 32-bit (Legacy) Buster because Bullseye doesn't support NCS1.
OpenVINO Version is l_openvino_toolkit_runtime_raspbian_p_2020.3.194.tgz,
which is the last version that supports NCS1.
Here's how to reproduce.
I installed Raspberry Pi OS 32-bit (Legacy) Buster onto the microSD.
After some simple initial settings, I typed these commands to install the OpenVINO toolkit:
sudo mkdir -p /opt/intel/openvino
mkdir ~/download
cd ~/download
wget https://storage.openvinotoolkit.org/repositories/openvino/packages/2020.3/l_openvino_toolkit_runtime_raspbian_p_2020.3.194.tgz
sudo tar -xf l_openvino_toolkit_runtime_raspbian_p_2020.3.194.tgz --strip 1 -C /opt/intel/openvino
echo "source /opt/intel/openvino/bin/setupvars.sh" >> ~/.bashrc
source /opt/intel/openvino/bin/setupvars.sh
sudo usermod -a -G users "$(whoami)"
sh /opt/intel/openvino/install_dependencies/install_NCS_udev_rules.sh
In order to set up the OpenCV environment, I typed:
sudo apt update
sudo apt install -y python3-pip
sudo apt install -y libopencv-dev
sudo apt install -y python3-numpy
pip3 install pillow
That's it.
Then, I downloaded necessary images and codes, and ran emotion.py.
The whole contents of emotion.py doesn't matter here because only the first line gives me the error.
more -10 emotion.py
import cv2
import numpy as np
from PIL import ImageFont, ImageDraw, Image
import argparse
import sys
from openvino.inference_engine import IECore
frame_png = cv2.imread("frame_main.png", cv2.IMREAD_UNCHANGED)
face_png = cv2.imread("frame_face.png", cv2.IMREAD_UNCHANGED)
gender_png = cv2.imread("frame_gender.png", cv2.IMREAD_UNCHANGED)
Addtional Info:
pi#raspberrypi:~ $ python -VV
Python 2.7.16
pi#raspberrypi:~ $ python3 -VV
Python 3.7.3 (default, Oct 31 2022, 14:04:00)
[GCC 8.3.0]
Also, I tried to use berry-conda to do a similar thing with this answer.
But, it failed because the package libprotobuf is missing:
(After berry-conda installation)
pi#raspberrypi:/tmp $ which python
/home/pi/berryconda3/bin/python
pi#raspberrypi:/tmp $ which conda
/home/pi/berryconda3/bin/conda
pi#raspberrypi:/tmp $ python --version
Python 3.6.1
pi#raspberrypi:/tmp $ conda install -c defaults libprotobuf protobuf
Fetching package metadata .....
PackageNotFoundError: Package missing in current linux-armv7l channels:
- libprotobuf
This berry-conda installation completely changed my previous environment above.
I don't know if I should keep using berry-conda
or re-install Raspberry Pi OS 32-bit (Legacy) Buster again to do it from scratch.
Any suggestions would be greatly appreciated.

The error message is indicating that there is an issue with an undefined symbol in the libopencv_dnn.so.4.5 library, which suggests that there may be a compatibility issue between OpenVINO and the version of OpenCV installed on your system.
You could try reinstalling OpenVINO and making sure that it is properly configured with your system's version of OpenCV. You could also try updating or reinstalling OpenCV.

Related

how to solve the glm problem when installing pymol?

I am trying to install pymol in CentOS 7 system. I installed the dependency glm-devel-0.9.6.3-1.el7.noarch by yum:
sudo yum install glm-devel.
During compiling I got an error related to glm as following:
layer1/SceneView.cpp:34:61: error: no matching function for call to ‘equal(const vec3&, const vec3&, float)’
Could anyone tell why this error appears?
I will appreciate any help!
Best regards.
install pymol in CentOS 7
Build example with updated glm-devel
# yum install mmtf-cpp-devel.x86_64 glew-devel.x86_64 libpng-devel freetype-devel msgpack-devel libxml2-devel python36-qt5-devel.x86_64 freeglut-devel mesa-libGL-devel.x86_64 python3-devel
# yum install ./glm-devel-0.9.9.6-6.el7.noarch.rpm
## works with the default python3 (3.6.8) and g++ -4.8.5
Link, glm-devel-0.9.9.6-6.el7 https://drive.google.com/file/d/1BXygEWqpvlbZg867dsXuW47T67Z0V0Q8/view?usp=sharing
https://github.com/schrodinger/pymol-open-source →
https://github.com/schrodinger/pymol-open-source/blob/master/INSTALL
git clone https://github.com/schrodinger/pymol-open-source.git
cd pymol-open-source/
python3 setup.py build
# python3 setup.py install
pymol ## the pymol GUI opens OK
There is also a binary version available, with python 3.7 included : https://pymol.org/2/ →
https://pymol.org/installers/PyMOL-2.5.2_293-Linux-x86_64-py37.tar.bz2 → tar xvf PyMOL-2.5.2_293-Linux-x86_64-py37.tar.bz2
cd pymol/ && ./pymol

conda python 3.7 opencv import error libgnutls.so.30: undefined symbol: mpn_add_1, version HOGWEED_4

I am facing problem while getting opencv to work with python 3.7 in Conda on Ubuntu 20.04.
I get the following error when I try to import cv2 in python:
$ python
Python 3.7.8 | packaged by conda-forge | (default, Jul 23 2020, 03:54:19)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/swagat/anaconda3/envs/tf2py37/lib/python3.7/site-packages/../../././libgnutls.so.30: undefined symbol: mpn_add_1, version HOGWEED_4
my Conda configuration looks something like this:
active environment : tf2py37
active env location : /home/swagat/anaconda3/envs/tf2py37
shell level : 2
user config file : /home/swagat/.condarc
populated config files :
conda version : 4.8.5
conda-build version : 3.18.9
python version : 3.7.4.final.0
virtual packages : __cuda=10.1
__glibc=2.31
I installed opencv from the conda-forge channel using the following command:
$ conda install -c conda-forge opencv
I can see that opencv is installed on my system:
$ conda list opencv
# packages in environment at /home/swagat/anaconda3/envs/tf2py37:
#
# Name Version Build Channel
libopencv 4.5.0 py37_2 conda-forge
opencv 4.5.0 py37_2 conda-forge
py-opencv 4.5.0 py37hc6149b9_2 conda-forge
I also checked if gnutls is installed:
$ conda list gnutls
# packages in environment at /home/swagat/anaconda3/envs/tf2py37:
#
# Name Version Build Channel
gnutls 3.6.13 h79a8f9a_0 conda-forge
What else I can try to solve this problem? I am kind of stuck here. Any help will be appreciated. Thanks.
It seems that conda version of the opencv is broken.
My solution is:
remove your conda opencv and install the native one:
conda remove opencv
python -m pip install opencv-python # Execute this with your conda env activated

Ubuntu: downgrade SDL2 version

I'm trying to run a python graphical application made with KIVY framework, then I have this on my terminal:
root#MZs83nQ1:/home/kruqer/Documents/mybackup/Appoff# python appoff.py
[INFO ] [Logger ] Record log in /root/.kivy/logs/kivy_17-11-09_5.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v2.7.14 (default, Sep 23 2017, 22:06:14)
[GCC 7.2.0]
Traceback (most recent call last):
File "appoff.py", line 2, in <module>
from kivy.app import App
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 319, in <module>
from kivy.base import runTouchApp, stopTouchApp
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 30, in <module>
from kivy.event import EventDispatcher
File "/usr/lib/python2.7/dist-packages/kivy/event.py", line 8, in <module>
import kivy._event
ImportError: /usr/lib/python2.7/dist-packages/kivy/_event.x86_64-linux-gnu.so: undefined symbol: PyFPE_jbuf
I made researches on google and I found this topic and I need to downgrade my sdl2 version to a version between 2.0.5 and 2.0.6, but I can't see which version am I running actually and don't know how to downgrade it.
My OS is Ubuntu 17.10.
Display SDL Version
Execute the following and it will show you the SDL version that you are using:
dpkg -l | grep sdl
Uninstall
sudo apt-get remove package1 [package2 ...]
Install
Python 2.x/3.x
sudo apt-get install -y \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev
Example - OS: Ubuntu 16.04 LTS (64bits), Python 2.x

Graphviz not working using conda or pip [duplicate]

This question already has answers here:
anaconda - graphviz - can't import after installation
(14 answers)
Closed 3 years ago.
I cannot get graphviz to install and import properly, either using conda install or pip install. I am using jupyter on anaconda.
conda install -c anaconda graphviz
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-0e78fd6401bd> in <module>()
----> 1 import graphviz
2 dot_data = tree.export_graphviz(clf, out_file=None)
3 graph = graphviz.Source(dot_data)
4 graph.render("iris")
ModuleNotFoundError: No module named 'graphviz'
When I install using pip I can successfully import but when I run the below code, I get a very long error message that ends with the following when running graph.render:
from sklearn.datasets import load_iris
from sklearn import tree
import graphviz
iris = load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
dot_data = tree.export_graphviz(clf, out_file=None)
graph = graphviz.Source(dot_data)
graph.render("iris")
Below is the end of the end of a long error message:
ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'iris'], make sure the Graphviz executables are on your systems' PATH
I have the directory where the graphviz folders are in PATH.
Anyone have an idea what I am doing wrong?
http://www.graphviz.org/Download_windows.php
Install windows package from: http://www.graphviz.org/Download_windows.php
Install python graphviz package
Add C:\Program Files (x86)\Graphviz2.38\bin to User path
Add C:\Program Files (x86)\Graphviz2.38\bin\dot.exe to System Path
RESTART COMPUTER
Worked for me!
If you're running Linux, you may have to run this command in addition to the Conda command (I had to do this):
sudo apt-get install graphviz
I was getting the exact same error in Pycharm and this solved it.

Installing opencv for python3

Has anyone tried to install opencv for python3?. As stated here http://opencv.willowgarage.com/wiki/InstallGuide its support status is unknown. So I want to try it:
I have downloaded the sources for OpenCV-2.3.1. But cmake reports.
-- Python interpreter: /Library/Frameworks/Python.framework/Versions/3.2/bin/python3 -B (ver
3.2)
-- Python numpy: NO (Python wrappers will not be generated)
I do have numpy (version 1.6.0) installed in python3 but cmake does not find it. I am using Mac OSX 10.6 Any ideas?
Update
I just saw one more thing of the cmake output that might be helpful
-- Found PythonInterp: /Library/Frameworks/Python.framework/Versions/3.2/bin/python3 (found
version "3.2")
-- Found PythonLibs: /usr/lib/libpython2.6.dylib File "", line 1
from distutils.sysconfig import *; print get_python_lib()
^
SyntaxError: invalid syntax File "", line 1
import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print
numpy.distutils.misc_util.get_numpy_include_dirs()[0]
^
SyntaxError: invalid syntax File "", line 1
import sphinx; print sphinx.__version__
^ SyntaxError: invalid syntax
Notice that it found 3.2 but then libpython2.6 ??
Any ideas?
At the moment OpenCV supports Python 2.x only. OpenCV (including OpenCV 2.4) does not compiles with Python 3.x.
Python3 support is already in wishlist for future versions of OpenCV. But currently there are no activities in this direction and you are welcome to create and contribute a patch resolving the compatibility issues.
Use the pip application.
On ubuntu:
sudo apt install python3-pip
and so, on command line:
pip3 install --upgrade pip
pip3 install opencv-python
I got the thing to at least build and install. It can load the cv2 module just fine. Haven't tested too much though.
Details:
https://stackoverflow.com/a/21212023/3075814

Resources