質問

I ask this because I have a couple installed and have some doubts if I am loading the right dynamic libraries.

This question is slightly different from these as they answer what is installed and not what your application is linking:

Find OpenCV Version Installed on Ubuntu

How to check for openCV

役に立ちましたか?

解決

In addition to great @berak's answer (related to version.hpp):

There are different naming schemes in OpenCV 2.4 and OpenCV 3.0 branches.
For OpenCV 2.4.x we have something like this (note that for 2.4.x CV_VERSION_MAJOR is 4):

#define CV_VERSION_EPOCH    2
#define CV_VERSION_MAJOR    4
#define CV_VERSION_MINOR    8
#define CV_VERSION_REVISION 0

And for OpenCV 3.0.x we have the following (note that CV_VERSION_MAJOR sense was changed!):

#define CV_VERSION_MAJOR    3
#define CV_VERSION_MINOR    0
#define CV_VERSION_REVISION 0
#define CV_VERSION_STATUS   "-dev"

That is if you need support for both 2.4.x abd 3.0.x, code will be slightly non-obvious if you want to check CV_VERSION_MAJOR.
I prefer checking CV_VERSION_EPOCH instead:

#if (defined(CV_VERSION_EPOCH) && CV_VERSION_EPOCH == 2)
# OpenCV 2.4.x stuff
#else
# OpenCV 3.0 stuff
#endif

他のヒント

there is a version.hpp header in core, which defines constants like CV_VERSION_MAJOR, etc.

apart from this, cout << cv::getBuildInformation() << endl; is quite useful, because it will show you the cmake output generated when building opencv (so you can see the dependancies, whether it's using ffmpeg or gstreamer, the like ..)

edit: please use CV_MAJOR_VERSION, not CV_VERSION_MAJOR, since the use of the latter is conflicting between 2.4 and master

that's the definition of OpenCV 2.4.8 from version.hpp:

#define CV_VERSION_EPOCH    2
#define CV_VERSION_MAJOR    4
#define CV_VERSION_MINOR    8
#define CV_VERSION_REVISION 0
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top