Downgrade OpenCV library on Fedora 18

Fedora 18 and OpenCV version 2.4.3 is not the brightest combination. After upgrading from FC17, python script has stopped working with displayed “SURF missing” error. I decided to downgrade OpenCV to 2.3.1 until this library problem will be resolved. Downgrade process is a little tricky, but finally my python code started to work on FC18 the same as it worked on FC17.

Before we go any further, here is FC18 error message displayed from python script containing cv2.SURF() line:

Traceback (most recent call last):
  File "./test.py", line 14, in 
    import lib
  File "/home/dbunic/test.py", line 786, in 
    surf = cv2.SURF(2000)
AttributeError: 'module' object has no attribute 'SURF'

On the page OpenCV 2.4.3 package on Fedora 18 is missing “nonfree” folder you can find info about moving some functions to “nonfree” module and that module is removed from the latest OpenCV package – doh! So, until all this will be resolved, here are steps how to downgrade OpenCV:

1) Download OpenCV packages for FC17
My Fedora is 64bit and if your system is 32bit then download i386 packages. For downgrading process, two RPM packages are needed (library and python module):

opencv-2.3.1-8.fc17.x86_64.rpm
opencv-python-2.3.1-8.fc17.x86_64.rpm

2) Remove OpenCV 2.4.3 from Fedora 18
Without “–nodeps” parameter, package manager will complain about dependencies and removing will not be allowed. Procedure described in this cookbook will replace OpenCV, so dependent libraries will not be broken at the end.

# rpm -e --nodeps opencv opencv-python

3) Resolve dependencies
At this moment (when FC18 OpenCV is removed) it’s possible to try install FC17 packages. It is very likely that the following error will be displayed:

# rpm -ivh opencv-2.3.1-8.fc17.x86_64.rpm opencv-python-2.3.1-8.fc17.x86_64.rpm
warning: opencv-2.3.1-8.fc17.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 1aca3465: NOKEY
error: Failed dependencies:
	libOpenNI.so()(64bit) is needed by opencv-2.3.1-8.fc17.x86_64
	libtbb.so.2()(64bit) is needed by opencv-2.3.1-8.fc17.x86_64
	libtiff.so.3()(64bit) is needed by opencv-2.3.1-8.fc17.x86_64
	libtbb.so.2()(64bit) is needed by opencv-python-2.3.1-8.fc17.x86_64

Some of listed dependencies can be resolved with the following “yum install” command:

# yum install tbb
# yum install openni

… but libtiff.so.3 dependency will stay and the only solution is to copy existing library from FC17 to FC18 and to manually create symbolic link (keep in mind that this procedure is for 64bit Linux):

# cp /tmp/libtiff.so.3.9.6 /usr/lib64
# cd /usr/lib64
# ln -s libtiff.so.3.9.6 libtiff.so.3

4) Force 2.3.1 OpenCV installation
Manual copy of libtiff.so.3.9.6 will not fix RPM dependency and installation will still complain about missing libtiff.so.3 library. The only way is to force package installation with “–nodeps” parameter:

rpm -ivh --nodeps opencv-2.3.1-8.fc17.x86_64.rpm opencv-python-2.3.1-8.fc17.x86_64.rpm

After completing all these steps, python script should work on FC18 system without any “strange” error like missing SURF module. Hope this post is useful and will help you to continue developing OpenCV projects on Fedora Core 18.

Leave a Comment