【问题标题】:Error compiling private.hpp OpenCV 3.0.0-rc1编译 private.hpp OpenCV 3.0.0-rc1 时出错
【发布时间】:2015-06-01 04:16:02
【问题描述】:

我下载了 OpenCV 3.0.0-rc1 并使用 CMAKE-gui 3.2.2 使用 VS2012 Win64 编译器构建它。生成了二进制文件和库,我使用 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    

# if defined __GNUC__ && defined __APPLE__

如果我犯了一些实现错误或 private.hpp 中的一些更改可以修复此错误,请告诉我。我使用的是 Windows 8 64 位。

【问题讨论】:

    标签: c++ qt opencv opencv3.0


    【解决方案1】:

    哦,永远不要尝试使用一些东西,那是所谓的“私人”,我猜......

    #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;
    }
    

    【讨论】:

      猜你喜欢
      • 2016-09-24
      • 1970-01-01
      • 2013-04-13
      • 2012-03-28
      • 1970-01-01
      • 1970-01-01
      • 2016-03-10
      • 1970-01-01
      • 2015-10-18
      相关资源
      最近更新 更多