正确包括在opencv 2.3中使用新的C ++ API [英] Correct includes to use the new C++ API in opencv 2.3
问题描述
我熟悉旧的opencv 1,并且长时间使用它的C函数。但是,我在切换到opencv 2.3的C ++ API时遇到了问题
I'm familiar with the old opencv 1, and used its C functions for a long time. However, I have problems with switching to the C++ API of opencv 2.3
我下载了最新的稳定版本(2.3.1),但其中的示例使用了旧的C函数,或者包括opencv2 / highgui / highgui.hpp
。
I downloaded the latest stable version (2.3.1), but the examples in it use either the old C functions, or include "opencv2/highgui/highgui.hpp"
.
问题是,我的 include / opencv2
目录中唯一的文件是 opencv.hpp
。如果我包含它,有很多路径是不正确的。
opencv.hpp
内有以下内容:
The problem is, the only file in my include/opencv2
directory is opencv.hpp
. If I include that, there are a lot of paths which are incorrect.
Inside of opencv.hpp
there are such things as:
#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/imgproc/imgproc_c.h"
等。
但是,在我的opencv目录中,包含文件位于以下文件夹中:
However, in my opencv directory, the include files are in folders like:
modules/core/include/opencv2/core
modules/flann/include/opencv2/flann
modules/imgproc/include/opencv2/imgproc
等。
那么,如果我必须手动指定包含路径, opencv.hpp
的重点是什么?每一个标题?在opencv网站(http://opencv.willowgarage.com)上,教程要么已经过时了,要么根本没有解决这个问题,直接跳到算法上。
So, what is the point of that opencv.hpp
, if I have to specify the include path manually for every single header? On the opencv site (http://opencv.willowgarage.com) the tutorials are either hopelessly outdated, or they don't address this question at all and jump straight to the algorithms.
编辑:我正在使用Qt,如果这很重要的话。我从 http://code.opencv.org/svn/opencv/branches下载了源代码/2.3/ 并成功构建。
I'm using Qt, if that matters. I downloaded the source from http://code.opencv.org/svn/opencv/branches/2.3/ and built it successfully.
编辑2:是的,这很重要。其中一个Qt标头丢失了,因此opencv的构建过程跳过了几个库。
Yes, it mattered. One of the Qt headers was missing, and so the building process of opencv skipped a few libraries.
推荐答案
我想我找到了问题。我有(4.6.3)的Qt源在 corelib / global
中没有 qconfig.h
,所以当我内置 opencv
,并非所有库都已创建,并且未复制标头。
I think I found the problem. The Qt source I have (4.6.3) does not have qconfig.h
in corelib/global
, so when I built opencv
, not all libraries were created, and the headers were not copied.
就是这样,遇到同样问题的其他人也会知道并且不会浪费时间寻找解决方案: qtconfig.h
不包含在Qt源代码分发中。你必须自己创建该文件,其目录中有许多模板,要么重命名其中一个( qconfig-large
, qconfig-minimal
等),或者只是创建一个空的 qconfig.h
。
Just so others with the same problem will know it and not waste hours finding for a solution: qtconfig.h
is not included in the Qt source distribution. You have to create that file yourself, there are a number of templates in its directory, either rename one of them (qconfig-large
, qconfig-minimal
, etc.), or just create an empty qconfig.h
.
编辑:我不建议任何人这样。我下载创建了一个mingw make,重新下载了所有内容,现在它可以正常工作了。我必须注意我构建opencv的mingw版本与Qt使用的版本相同。
I don't recommend this way to anyone. I downloaded created a mingw make, redownloaded everything, and it works now. I had to take care that the mingw version I built opencv is the same as the one used with Qt.
这篇关于正确包括在opencv 2.3中使用新的C ++ API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!