How to determine OpenCV version

前端 未结 8 988
南笙
南笙 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: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.

提交回复
热议问题