Upgrade OpenCV to 4.8.1. in C++

On my Linux Ubuntu system, recently I attempted to upgrade opencv from 4.2.0 to 4.8.1 using pip install --upgrade opencv-python== 4.8.1. I verified the newest version in Python and so this works well.

However, when starting opencv with c++ it is still using the older version 4.2.0.

In CmakeLists.txt I changed the line find_package( OpenCV 4.8.1 REQUIRED).`

This is giving the error :“with requested version “4.8.1”.`
The following configuration files were considered but not accepted:
/usr/lib/x86_64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake, version: 4.2.0
/lib/x86_64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake,
version: 4.2.0”

Indeed, /usr/lib/x86_64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake still
shows 4.2.0 and is protected against writing.

I think this is an issue with a path directory, since opencv is installed in the folder /.local/lib/python3.8/site-packages/cv2/, which seemed a bit strange to me.

So my question is, how do I upgrade C++ to the newest opencv version 4.8.1? Thank you very much in advance!

well of course. that’s the python package. it contains opencv, but you can’t use that outside of python. if you want to write C++, the python package is utterly irrelevant to you.

you need to download binaries from the opencv site or github, or install some package maintained by your operating system’s volunteers, or get opencv source and build it yourself.

1 Like