Ask Your Question
0

How to set up a "side-OpenCV" / set path to another opencv

asked 2016-07-19 10:02:41 -0600

danceToBebop gravatar image

Hey everyone,

I'm working on a station without sudo rights. Installed is a OpenCV V. 2.3.x. Now for my needs this isn't sufficient. However I was able to download and compile the latest Version

make aswell as make install

worked out fine, but of the last step. Moving the installed libs to /usr/local/include/opencv2 because of the missing rights.

So since it's now just a matter of setting the path to the library, how can I do this, that system-wide the recently installed version is only used and the other ignored ?

Thanks for your help

Kind Regards

edit retag flag offensive close merge delete

Comments

I have the answer but I have to wait 1 more day due this community, so this case is closed thanks for your time

danceToBebop gravatar imagedanceToBebop ( 2016-07-20 12:42:20 -0600 )edit

make it a comment, then, i'll convert it.

berak gravatar imageberak ( 2016-07-20 13:03:50 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2016-07-21 10:05:29 -0600

danceToBebop gravatar image

updated 2016-07-21 10:23:52 -0600

I was able to figure out a solution that works. An option is working with sys.path, there is apparently another one with $PYTHONPATH but that didn't run on my system - I short guess would be, that here a library is just appended to the path and if one already has a working library of this kind in its path, the first one - in this case the deprecated opencv is chosen.

However working with sys.path lets you put the library at any desired position. To make it short:

import sys
sys.path.insert(0,'<path-to-better-lib>')
import cv2

the number stands for the position in the path-string: 0 means put on very first place so the later cv2.so will just be ignored.

example for <'path-to-better-lib'> : ~/newOpencv/lib/python2.7/dist-packages, that's where the cv2.so resides, which represents opencv

N.B.: of course this will work with other libraries too, just replace import cv2 respectively. That's how to deal with multiple versions of any (not just cv) libs installed on one workstation in python

edit flag offensive delete link more
0

answered 2016-07-19 10:31:52 -0600

berak gravatar image
  • cmake -DCMAKE_INSTALL_PREFIX=/where/you/want/it
  • also, maybe building static libs is a good idea then (cmake -DBUILD_SHARED_LIBS=OFF), since you won't be allowed to install the so's to system path either.
edit flag offensive delete link more

Comments

will this e.g. prevent python to use the deprecated and force it to use my version ?

danceToBebop gravatar imagedanceToBebop ( 2016-07-19 10:33:31 -0600 )edit

yes. -DBUILD_SHARED_LIBS=OFF will make a statically linked cv2.so, that no more depends on opencv so's.

(still, uninstalling the old version might be another idea)

berak gravatar imageberak ( 2016-07-19 10:39:26 -0600 )edit

The library was build again, but still system-wide the depricated version is used. That comes back to my question, how can I change that path, to look for the recent one ?

danceToBebop gravatar imagedanceToBebop ( 2016-07-19 11:04:34 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-19 10:01:59 -0600

Seen: 2,131 times

Last updated: Jul 21 '16