C ++ opencv编译错误 - Windows7 64位使用Eclipse CDT [英] C++ opencv compilation error - Windows7 64-bit using Eclipse CDT

查看:264
本文介绍了C ++ opencv编译错误 - Windows7 64位使用Eclipse CDT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试编译此示例项目以熟悉OpenCV:

Trying to compile this sample project in order to get familiar with OpenCV:

#include <cv.h>
#include <highgui.h>

using namespace cv;

int main(int argc, char** argv)
{
    Mat image = imread(argv[1], 1);
    if (argc != 2 || !image.data) {
         printf("No image data \n");
         return -1;
    }

    namedWindow("Display Image", CV_WINDOW_AUTOSIZE);
    imshow("Display Image", image);

    waitKey(0);

    return 0;
} 

我收到以下编译错误:

Description Resource    Path    Location    Type
Field 'data' could not be resolved  imageloader.cpp ‪/Session4‬ line 8  Semantic Error
Invalid arguments '
Candidates are:
void imshow(const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &, const ? &)
void imshow(const ? &, ?)
'   imageloader.cpp ‪/Session4‬ line 14 Semantic Error

为什么无法访问Mat对象中的字段?不仅数据字段,而且所有字段。我使用c-make和MinGW +构建opencv库,在项目属性中包含相关的头文件和lib路径。

Why can't I access the fields inside the Mat object? Not only the data field, but all fields. I build the opencv library using c-make and MinGW + I included the relevant header files and lib path in the project properties.

任何帮助都将非常感激。 p>

Any help would be most appreciated.

推荐答案

Mat 测试数据是否已成功加载:

There's a specific method in Mat that tests whether the data was successfully loaded:


//返回true if矩阵数据为NULL

// returns true if matrix data is NULL

bool empty()const;

bool empty() const;

您的代码,将 if 语句更改为:

So in your code, change the if statement to:

if (argc != 2 || image.empty()) 

这篇关于C ++ opencv编译错误 - Windows7 64位使用Eclipse CDT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆