To uninstall OpenCV (Open Source Computer Vision) from Raspberry Pi (Raspbian Jessie), follow the steps mentioned below in this article.
Tools and Technologies used in this article :
Connect to Raspberry Pi
Remotely connect to the Raspberry Pi using any SSH client (e.g. putty) or directly open the terminal in the Raspberry Pi.
Find out if OpenCV is installed or not
Run following command to check whether OpenCV is installed or not.
pi@mypi2 ~ $ pkg-config --modversion opencv
3.1.0
Remove Official opencvlib
a. First check if official opencvlib is installed or not
pi@ mypi2 ~ $ dpkg -l libopencv*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=================================================================-=====================================-=====================================-========================================================================================================================================
ii libopencv-calib3d2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision Camera Calibration library
ii libopencv-contrib2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision contrib library
ii libopencv-core2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision core library
ii libopencv-features2d2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision Feature Detection and Descriptor Extraction library
ii libopencv-flann2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision Clustering and Search in Multi-Dimensional spaces library
ii libopencv-highgui2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision High-level GUI and Media I/O library
ii libopencv-imgproc2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision Image Processing library
ii libopencv-legacy2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision legacy library
ii libopencv-ml2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision Machine Learning library
ii libopencv-objdetect2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision Object Detection library
ii libopencv-video2.4:armhf 2.4.9.1+dfsg-1+deb8u1 armhf computer vision Video analysis library
b. If found in the previous step, then purge libopencv packages
pi@ mypi2 ~ $ sudo apt-get purge libopencv*
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libopenconnect3' for regex 'libopencv*'
Note, selecting 'libopencascade-ocaf-lite-6.5.0' for regex 'libopencv*'
Note, selecting 'libopencl-2.0-1' for regex 'libopencv*'
Note, selecting 'libopenct1-dev' for regex 'libopencv*'
Note, selecting 'libopencv-objdetect-dev' for regex 'libopencv*'
Note, selecting 'libopencascade-foundation-dev' for regex 'libopencv*'
Note, selecting 'libopencv-contrib2.4' for regex 'libopencv*'
Note, selecting 'libopencv-flann-dev' for regex 'libopencv*'
:
:
:
Package 'ocl-icd-libopencl1' is not installed, so not removed
The following packages will be REMOVED:
gstreamer1.0-plugins-bad* libopencv-calib3d2.4* libopencv-contrib2.4* libopencv-core2.4* libopencv-features2d2.4* libopencv-flann2.4* libopencv-highgui2.4* libopencv-imgproc2.4* libopencv-legacy2.4* libopencv-ml2.4* libopencv-objdetect2.4* libopencv-video2.4*
0 upgraded, 0 newly installed, 12 to remove and 0 not upgraded.
After this operation, 14.7 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 119208 files and directories currently installed.)
Removing gstreamer1.0-plugins-bad:armhf (1.4.4-2.1rpi4rpi1g) ...
Removing libopencv-legacy2.4:armhf (2.4.9.1+dfsg-1+deb8u1) ...
:
:
:
Purging configuration files for libopencv-core2.4:armhf (2.4.9.1+dfsg-1+deb8u1) ...
Processing triggers for libc-bin (2.19-18+deb8u2) ...
Remove OpenCV Debian Package (Custom Built from OpenCV Source code)
a. Remove package
pi@mypi2 ~ $ sudo dpkg -r opencv
(Reading database ... 117810 files and directories currently installed.)
Removing opencv (3.1.0-1) ...
dpkg: warning: while removing opencv, directory '/usr/local/lib' not empty so not removed
dpkg: warning: while removing opencv, directory '/usr/local/share' not empty so not removed
b. Verify uninstallation
pi@mypi2 ~ $ sudo dpkg -r opencv
dpkg: warning: ignoring request to remove opencv which isn't installed
If installed using sudo make install (Built from OpenCV Source code)
Go to the OpenCV build directory in the terminal and run the following command
pi@ mypi2 ~/opencv-3.1.0/build $ sudo make uninstall
-- Uninstalling "/usr/local/include/opencv2/cvconfig.h"
-- Uninstalling "/usr/local/include/opencv2/opencv_modules.hpp"
-- Uninstalling "/usr/local/lib/pkgconfig/opencv.pc"
-- Uninstalling "/usr/local/share/OpenCV/OpenCVConfig.cmake"
-- Uninstalling "/usr/local/share/OpenCV/OpenCVConfig-version.cmake"
-- Uninstalling "/usr/local/share/OpenCV/OpenCVModules.cmake"
-- Uninstalling "/usr/local/share/OpenCV/OpenCVModules-release.cmake"
-- Uninstalling "/usr/local/share/OpenCV/3rdparty/lib/liblibtiff.a"
-- Uninstalling "/usr/local/share/OpenCV/3rdparty/lib/liblibjpeg.a"
-- Uninstalling "/usr/local/share/OpenCV/3rdparty/lib/liblibwebp.a"
-- Uninstalling "/usr/local/share/OpenCV/3rdparty/lib/liblibjasper.a"
-- Uninstalling "/usr/local/share/OpenCV/3rdparty/lib/libIlmImf.a":
:
:
:
:
-- Uninstalling "/usr/local/share/OpenCV/lbpcascades/lbpcascade_profileface.xml"
-- Uninstalling "/usr/local/share/OpenCV/lbpcascades/lbpcascade_frontalcatface.xml"
-- Uninstalling "/usr/local/bin/opencv_traincascade"
-- Uninstalling "/usr/local/bin/opencv_createsamples"
-- Uninstalling "/usr/local/bin/opencv_annotation"
Built target uninstall