编译private.hpp OpenCV 3.0.0-rc1时出错

Error compiling private.hpp OpenCV 3.0.0-rc1

本文关键字:0-rc1 出错 private hpp OpenCV 编译      更新时间:2023-10-16

我下载了OpenCV 3.0.0-rc1并使用CMAKE-gui 3.2.2使用VS2012 Win64编译器构建它。生成了二进制文件和库,我用64位Qt设置了它。所有程序都工作正常,除了当我尝试使用功能cv::LineSegmentDetector时,它在private.hpp文件中显示编译错误。错误提示

unexpected end-of-line

我的代码如下

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/private.hpp>
#include <opencv2/core/utility.hpp>
using namespace std;
int main()
{
    cv::Mat image = cv::imread("C:\Users\IMAGE\Desktop\PROJ\SAMPLE.png");
    cv::imshow("TEST",image);
    cv::waitKey();
    cv::LineSegmentDetector lsd;
    return 0;
}

并且在错误之后,我发现private.hpp中以下部分代码的第二行作为错误突出显示。

#ifdef HAVE_EIGEN
#  if defined __GNUC__ && defined __APPLE__
#    pragma GCC diagnostic ignored "-Wshadow"
#  endif
#  include <Eigen/Core>
#  include "opencv2/core/eigen.hpp"
#endif    

# if define &&定义__APPLE__

请让我知道,如果我正在做一些实现错误或在私有的一些变化。hpp可以修复这个错误。我用的是windows 8 64位。

哦,永远不要尝试使用所谓的"private",我猜…

#include <opencv2/opencv.hpp>       // includes all others
#include <opencv2/core/utility.hpp> // getTickCount, etc.
int main()
{
    // LineSegmentDetector is an abstract class, you can't create an
    // instance on the stack, but need to use Ptr and factory:
    cv::Ptr<cv::LineSegmentDetector> lsd = cv::createLineSegmentDetector();
    return 0;
}