How to determine OpenCV version

前端 未结 8 977
南笙
南笙 2020-12-29 03:48

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

相关标签:
8条回答
  • 2020-12-29 04:21

    pkg-config --modversion opencv

    0 讨论(0)
  • 2020-12-29 04:23

    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.

    0 讨论(0)
  • 2020-12-29 04:31

    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)

    0 讨论(0)
  • 2020-12-29 04:33

    You can check the following macro variables:

    CV_MAJOR_VERSION
    CV_MINOR_VERSION
    
    0 讨论(0)
  • 2020-12-29 04:36

    You can check the CV_VERSION macro.

    0 讨论(0)
  • 2020-12-29 04:43

    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
    
    0 讨论(0)
提交回复
热议问题