如何确定我安装了哪个版本的 OpenCV?
_我最感兴趣的是知道一种以编程方式(和跨平台)执行它的方法_,但我什至找不到从代码外部确定已安装版本的方法。
我在 Fedora 上使用 C++03。
原文由 penelope 发布,翻译遵循 CC BY-SA 4.0 许可协议
据我所知,主要有以下三种方式:
C++
代码确定:-将这些行放入您的代码中:
std::cout << cv::getVersionMajor() << std::endl;
std::cout << cv::getVersionMinor() << std::endl;
std::cout << cv::getVersionRevision() << std::endl;
所有这些函数都有 int
返回类型。在我的 Linux
机器上,我得到
4
2
0
但是,我更喜欢 getVersionString()
因为它只需一个函数调用就可以打印所有内容并且它具有 std::string
返回类型:
std::cout << cv::getVersionString() << std::endl; // 4.2.0
opencv_version
二进制文件,由 OpenCV
提供:-For example, on a Linux
machine, go to the OpenCV
bin
directory ie, mostly, /usr/local/bin
and run
./opencv_version
在我的 Linux
机器上,它显示 4.2.0
version.hpp
文件确定:-OpenCV
specifies the version in version.hpp
header file through three macros, CV_VERSION_MAJOR
, CV_VERSION_MINOR
, and CV_VERSION_REVISION
For example, on a Linux machine, go to the OpenCV
include
directory ie, mostly, /usr/local/include
and read version.hpp
file:
$ cd /usr/local/include/opencv4/opencv2/core
$ head version.hpp
原文由 Milan 发布,翻译遵循 CC BY-SA 4.0 许可协议
3 回答2k 阅读✓ 已解决
2 回答3.9k 阅读✓ 已解决
2 回答3.2k 阅读✓ 已解决
1 回答3.2k 阅读✓ 已解决
1 回答2.7k 阅读✓ 已解决
3 回答3.4k 阅读
1 回答1.6k 阅读✓ 已解决
您可以检查
CV_VERSION
宏。