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
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.