我已经使用VS 2017在64位Windows 10上使用git成功构建了最新的OpenCV和OpenCV contrib。现在的问题是尝试重新编译之前的程序(source code)使用OpenCV 2.x编辑器显示一些错误,如:
images.push_back(imread(path, 0));
>> identifier "imread" is undefined
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
>> identifier "FaceRecognizer" is undefined
>> identifier "createFisherFaceRecogizer" is undefined
VideoCapture cap(fileName);
>> identifier "VideoCapture" is undefined
到目前为止,这些是我的包含文件:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/face.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
这些是我的附加包含目录中的行:
C:\opencv\source\contrib\modules\face\include\
C:\opencv\source\core\include\
C:\opencv\source\core\modules\objdetect\include
C:\opencv\source\core\modules\imgproc\include
C:\opencv\source\core\modules\highgui\include\
C:\opencv\source\core\modules\
C:\opencv\source\core\modules\core\include\
%(AdditionalIncludeDirectories)
C:\ opencv \ source \ core 包含OpenCV的整个核心, C:\ opencv \ source \ contrib 包含整个OpenCV contrib模块。
我不确定问题是某些未包含的文件,还是错误的包含设置。