It is possible to work with both versions of the library parallel, but it would not be recomendable because you have to pay some extra attention to possible issues related with it.
You can do it in many ways. One of them would be to download the code of the exact version you want, compile it and deploy/install it for instance in /usr/local. Then you will be able to link your code to this version of opencv (using cmake and the CMakeList.txt file), while you are linked at the same time to other indigo libraries that may depend to the original 2.4.8 version of opencv.
Originally posted by Pablo Iñigo Blasco with karma: 2982 on 2016-06-07
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by skr_robo on 2016-06-09:
Thank you for the reply. Can you pls tell me how to edit CMakeLists.txt so that ROS uses OpenCV 2.4.9
Comment by Pablo Iñigo Blasco on 2016-06-10:
The ROS libraries and executable come already linked to a specific (and not changeable opencv library).
However, for your custom code you can select the version of opencv in cmake. One thing you have todo is:
FIND_PACKAGE(OpenCV 2.4.8 EXACT REQUIRED)
Comment by Pablo Iñigo Blasco on 2016-06-10:
Additionally you have to enable cmake reach the development libraries you are going to use. It can be done in many ways, for instance you can set the OPENCV_DIR cmake variable (through the CMakeFileLists.txt or using the cmake -DOPENCV_DIR or configuring the build with ccmake)
Comment by Pablo Iñigo Blasco on 2016-06-10:
All this is possible but you should study how Cmake works here and how the operative system works in terms of library loading and how C++ libraries are linked... otherwise you may find problems or situations that you may not understand
Comment by Pablo Iñigo Blasco on 2016-06-10:
To make ROS work directly with one specific version you will have to compile ROS from sources or find a precompiled version (hydro, indigo, jade, etc.) that is linked with the version of opencv you want.
Comment by skr_robo on 2016-06-10:
Thank You for the guidance. I will start developing an understanding of cmake.