How to determine which version of OpenCV I have installed?
I am most interested in knowing a way of doing it programatically (and cross-platform), but I can
pkg-config --modversion opencv
I would like to enhance one of the answers using version.hpp defines.
Please notice the potential problem with that solution:
v. 2.4.13.6 defines:
#define CV_VERSION_EPOCH 2
#define CV_VERSION_MAJOR 4
#define CV_VERSION_MINOR 13
#define CV_VERSION_REVISION 6
#if CV_VERSION_REVISION
# define CV_VERSION CVAUX_STR(CV_VERSION_EPOCH) "." CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION)
#else
# define CV_VERSION CVAUX_STR(CV_VERSION_EPOCH) "." CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR)
#endif
and v. 3.4.2 defines:
#define CV_VERSION_MAJOR 3
#define CV_VERSION_MINOR 4
#define CV_VERSION_REVISION 2
#define CV_VERSION CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION) CV_VERSION_STATUS
As a result, CV_VERSION_MAJOR are not comparable. Much safer solution is to parse CV_VERSION and use the first value before a dot.
if you are working under Windows and you need to configure Codeblocks or any other IDE (thus,you can not issue any command yet nor compile a program ) you can simply go to the folder of installation of OpenCV and look after the final leters of the libraries in the sub-folder "/lib" .All libraries there are named in a pattern that reflects the major,minor and the revision of the build of OpenCV.For instance if you stumble upon a file named opencv_ts300.lib or opencv_world300.lib then the major is 3,minor is 0 and revision is 0.
(Note: it's likely that this method fails I mean when these informations do not comply with the real version but this will be maybe with the revision but unlikely with the major)
You can check the following macro variables:
CV_MAJOR_VERSION
CV_MINOR_VERSION
You can check the CV_VERSION
macro.
The version string is located in:
https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core/version.hpp
Top of version.hpp, below the BSD license:
#define CV_VERSION_MAJOR 3
#define CV_VERSION_MINOR 2
#define CV_VERSION_REVISION 0