How to determine OpenCV version

♀尐吖头ヾ 提交于 2019-11-29 02:28:31

问题


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't even find a way to determine the installed version from outside the code.

I'm working with C++03, on Fedora.


回答1:


You can check the CV_VERSION macro.




回答2:


You can check the following macro variables:

CV_MAJOR_VERSION
CV_MINOR_VERSION



回答3:


If you also want to get build information, you can use this code:

    printf("OpenCV: %s", cv::getBuildInformation().c_str());



回答4:


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



回答5:


pkg-config --modversion opencv




回答6:


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.




回答7:


If you install from svn repository, you can see the exact revision version like that:

# in the opencv.svn directory
svn info



回答8:


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)



来源:https://stackoverflow.com/questions/11030640/how-to-determine-opencv-version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!