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

时间:2015-06-01 04:16:03

标签: c++ qt opencv opencv3.0

我下载了OpenCV 3.0.0-rc1并使用VS2012 Win64编译器使用CMAKE-gui 3.2.2构建它。生成了二进制文件和库,我使用Qt 64位进行设置。所有程序都正常工作,除非我尝试使用功能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    

#如果已定义__GNUC__&amp;&amp;定义__APPLE __

如果我正在执行某些实现错误或者private.hpp中的某些更改可以修复此错误,请告诉我。我正在使用Windows 8 64位。

1 个答案:

答案 0 :(得分:1)

哦,永远不要尝试使用某种东西,这就是所谓的#34;私人&#34;,我猜......

#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;
}
相关问题