What is the difference between openCV and cv2? - opencv

I am new to the openCV library. When I was first trying the code for a feature matching tutorial
Python Tutorial Link
All other functions except for the 'drawMatches' function does not work. I figured out that my openCV version is not correct. Then I update my openCV version to the newest version(3.2.0) using command
conda install -c conda-forge opencv' and 'conda update --all
The problem now is that all other functions does not work because it does not recognize cv2. The error I get is like the following:
ImportError: dlopen(/Users/qdai/anaconda/lib/python2.7/site-packages/cv2.so,
Library not loaded: #rpath/libopenblasp-r0.2.19.dylib
Referenced from: /Users/qdai/anaconda/lib/libopencv_hdf.3.2.0.dylib
I don't know what is the relationship between cv2 and opencv. And how do I solve this problem?

From the paths you have in your example, I am assuming you're on Mac?
If so, I had this same problem.
After having homebrew installed this ended up working for me:
brew tap homebrew/science
brew install opencv
cd /Library/Python/2.7/site-packages/
sudo ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.py
sudo ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so cv2.so
Hope this helps.

Related

No rule to make target libopencv_calib3d.so.3.2.0 but opencv 3.4.1 installed, when making ROS workspace

I have opencv 3.4.1 installed from source on my ubuntu. But when running command catkin_make -DCMAKE_BUILD_TYPE=Release I get error:
No rule to make target '/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.3.2.0', needed by '~/ros_ws/devel/lib/stereo_slam/image_handle_node'. Stop.
No rule to make target '/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.3.2.0', needed by '~/ros_ws/devel/lib/libmetrics_lib.so'. Stop.
I've already tried following this: openCV program compile error "libopencv_core.so.2.4: cannot open shared object file: No such file or directory" in ubuntu 12.04
[EDIT] I get the same error compiling using clion or catkin_make directly from terminal, but clion creates special packages for release and debug versions. I don't quite understand these packages but in files CMakeCache.txt i found folowing lines:
//Dependencies for the target
metrics_lib_LIB_DEPENDS:STATIC=general;/opt/ros/melodic/lib/libtf.so;general;/opt/ros/melodic/lib/libtf2_ros.so;general;/opt/ros/melodic/lib/libactionlib.so;general;/opt/ros/melodic/lib/libmessage_filters.so;general;/opt/ros/melodic/lib/libtf2.so;general;/opt/ros/melodic/lib/libcv_bridge.so;general;/opt/ros/melodic/lib/libimage_geometry.so;general;/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_features2d.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_flann.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_imgcodecs.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_ml.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_objdetect.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_photo.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_shape.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_stitching.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_superres.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_video.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_videoio.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_videostab.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_viz.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_aruco.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_bgsegm.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_bioinspired.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_ccalib.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_datasets.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_dpm.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_face.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_freetype.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_fuzzy.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_hdf.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_line_descriptor.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_optflow.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_phase_unwrapping.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_plot.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_reg.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_rgbd.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_saliency.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_stereo.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_structured_light.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_surface_matching.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_text.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_ximgproc.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_xobjdetect.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_xphoto.so.3.2.0;general;/opt/ros/melodic/lib/libroscpp.so;general;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;general;/usr/lib/x86_64-linux-gnu/libboost_signals.so;general;/opt/ros/melodic/lib/librosconsole.so;general;/opt/ros/melodic/lib/librosconsole_log4cxx.so;general;/opt/ros/melodic/lib/librosconsole_backend_interface.so;general;/usr/lib/x86_64-linux-gnu/liblog4cxx.so;general;/usr/lib/x86_64-linux-gnu/libboost_regex.so;general;/opt/ros/melodic/lib/libxmlrpcpp.so;general;/opt/ros/melodic/lib/libroscpp_serialization.so;general;/opt/ros/melodic/lib/librostime.so;general;/opt/ros/melodic/lib/libcpp_common.so;general;/usr/lib/x86_64-linux-gnu/libboost_system.so;general;/usr/lib/x86_64-linux-gnu/libboost_thread.so;general;/usr/lib/x86_64-linux-gnu/libboost_chrono.so;general;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;general;/usr/lib/x86_64-linux-gnu/libboost_atomic.so;general;/usr/lib/x86_64-linux-gnu/libpthread.so;general;/usr/lib/x86_64-linux-gnu/libconsole_bridge.so.0.4;general;prometheus-cpp::core;general;prometheus-cpp::pull;general;ceres;general;proto;
I don't understand what these metrics_lib_LIB_DEPENDS are, and from where do they come from.
I also used erroneously sudo find / -name "opencv" -exec rm -i {} \; to remove opencv and I had the same problem.
I solved with :
sudo apt remove libopencv-dev
sudo apt remove libopencv-core3.2
However not all the opencv lib will be unistalled with this, so you need to remove all the opencv lib installed with ros (in my case I needed to remove also opencv-data). You can find them with:
sudo apt list --installed | grep opencv
after that you can install again ros melodic (or whatever you are using) :
sudo apt install ros-melodic-desktop-full
Problem was that I uninstalled previous version of opencv via next command:
sudo find / -name "*opencv*" -exec rm -i {} \;
By doing this I also erased the contents of the ROS OpenCV library. Later even after reinstalling ROS, these libraries did not reinstall because the system thinks they are installed but nothing was in them. I had to apt-get each library individually.
Don't purge OpenCV...

PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/pdo_sqlite.so' with Jenkins

I'm getting this warning when running the phpunit test suite in Jenkins pipeline.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/pdo_sqlite.so' - /usr/lib/php/20160303/pdo_sqlite.so: undefined symbol: sqlite3_column_table_name in Unknown on line 0
However this warning is not thrown when running the test suite directly in terminal.
I have PHP 7.1 in my system and this is the only PHP version I have installed. php7.1-sqlite3 is installed.
Thank you in advance.
As far as I have found out, there is a faulty file in /usr/local/lib called libsqlite3.so.0 which points to libsqlite3.so.0.8.6. I renamed the file in case it was needed for something. With the command:
cd /usr/local/lib
sudo mv libsqlite3.so.0 ./libsqlite3.so.0.back
But you can also delete it:
rm libsqlite3.so.0
The thread that lead me to the answer: link
This solved my problems, and I hope they solve yours as well :)
I had this same issue with PHP 7.1 on Ubuntu 16.04.
Running the following fixed the issue for me:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1-sqlite3
Have you built SQLite from source? If yes, enable Column metadata and recompile with
CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1" ./configure
make
sudo make install
Have fun using the cutting edge SQLite.
Reference - https://www.sqlite.org/compile.html#enable_column_metadata

OpenCV on beaglebone. pkg-config issues

So i am running ubuntu 13.04 on the sd card of my new beaglebone black. I am attempting to install opencv-2.4.2. I've got everything installed without errors but when i try to build and run a program
g++ 'pkg-config opencv --cflags' FILE.cpp -o FILE 'pkg-config opencv --libs'
I get the error:
pkg-config opencv --cflags: no such file or directory
pkg-config opencv --libs: no such file or directory
When I run pkg-config --libs opencv it gives me the correct directory (/usr/lib/ .so) with all my libraries and I have confirmed they are all actually there. pkg-config opencv --cflags gives -I/usr/include/opencv. Which also exists.
I have edited my bash.bashrc, opencv.pc, and opencv.conf files reflect these paths. They were /usr/local/lib but no libraries installed there.
I'm running out of ideas guys, any help or suggestions would be great.
Thanks.
you should be using backticks (`) instead of ' to substitute the output of pkg-config into the command line.
opencv-2.4.2 is provided in the angstrom distribution that comes with the BeagleBone Black. One problem I found was that python-opencv is at 2.3 with angstrom, so if you want to do your development work in python you have to downgrade opencv to 2.3.

How to install OpenCV in ubuntu 12.04

I already have OpenCV2.4.2 installed as part of ROS(Fuerte) in my computer(installed from Ubuntu Software Center, something due to ROS). How should I install OpenCV as a standalone?
I went through this guide and downloaded the opencv package from here. I am not quite clear as how to proceed. Can anyone give short list of steps to install? I want to use an IDE for my projects, so which IDE is proper for C++ and how to install the proper IDE and configure it correctly?
Also how to check if certain tools are installed?
This link which you also mentioned describes the necessary steps to compile OpenCV on your machine.
The version of OpenCV you install this way will be newer than the one installed with the ROS package, they usually have some delay. (Maybe not with Fuerte.)
Using multiple versions of the same library on a machine might cause problems with linking and it will create a bit of headache for you so I would avoid it.
Try running pkg-config opencv --libs to see if the ROS version pulled by Fuerte is available and you can use this with your projects later on.
For a starter IDE I would recommend Qt Creator.
The easy way to set OpenCV up with your project in Qt Creator is the following:
Create a project
Open the .pro file of the project
Run pkg-config opencv --cflags
Add this to the .pro file: INCLUDEPATH += __result__of__above
pkg-config opencv --libs
Add this to the .pro file: LIBS += __result__of__above
In the end what you add should look something like this:
INCLUDEPATH += -I/opt/ros/fuerte/include
LIBS += -L/opt/ros/fuerte/lib -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_ts -lopencv_video -lopencv_videostab
To install OpenCV using the terminal on Ubuntu:
$ su -
# apt-get update
# apt-get install build-essential
# apt-get install libavformat-dev
# apt-get install x264 v4l-utils ffmpeg
# apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev
OpenCV should be installed in /usr/local/ Installation Directory
You may also want to compile and view examples
$ cp -r /usr/share/doc/opencv-doc/examples .
$ cd examples
$ cd c
$ sh build_all.sh
You can read the complete article about How to install OpenCV on Ubuntu from Nam Huy Linux Blog at http://namhuy.net/1205/how-to-install-opencv-on-ubuntu.html
This github user has compiled all the installation steps using a shell script. You can install any OpenCV version you want by running the appropriate shell script inside.
$ git clone https://github.com/jayrambhia/Install-OpenCV.git
$ cd Ubuntu
$ chmod +x *
$ ./opencv_latest.sh
There is an installer for Ubuntu 16.04, and it may work well on Ubuntu 12.04, you could have a try. I have used it to install on Ubuntu 16.04 and it succeed!
An interactive installing script for install openCV on Ubuntu 16.04 LTS

How to install opencv in ubuntu 11.10?

I have been searching all over the net and doing what is being said.How should I install open cv in ubuntu 11.10 platform? I want to do some image processing using open cv. Thanks. Btw, Im a novice in programming.
download latest OpenCV-2.4.2.tar.bz2 and extract it.
in terminal cd to the Opencv-2.4.2
run mkdir release
cd release
run cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
run sudo make install
That's it to install opencv. It will take almost 30 mins to install.
But after successful installation you might get another issue with your Ubuntu 11.10 (in my experience). You may get linking error with opencv libraries. To get rid of that problem run export LD_LIBRARY_PATH=/usr/local/lib on every login session. Or add /usr/local/lib -this line at end of /etc/ld.so.conf for a permanent solution.
You can download my detailed opencv implementation of histogram equalization from my website for a good start-up!
my website :

Resources