'cv::Mat::type':非标准语法;使用 '&' 创建指向成员的指针
'cv::Mat::type': non-standard syntax; use '&' to create a pointer to member
我知道论坛中有很多相同的问题,但我找不到解决方案,而且我没有强大的 c++ 基础知识。
我有一个课程如下。当在main((中调用检测器函数时,错误发生在行Mat output = Mat::zeros(input.rows, input.cols, input.type(;。
class CardDetector
{
string const ORIGINAL = "original";
string const OUTPUT = "output";
public:
CardDetector()
{
cout << "testing";
}
void detect()
{
namedWindow(ORIGINAL, WINDOW_AUTOSIZE);
namedWindow(OUTPUT, WINDOW_AUTOSIZE);
Mat input = imread("top.jpg", 1);
Mat output = edgeDetection(input);
resize(input, input, Size(400, 500));
imshow(ORIGINAL, input);
imshow(OUTPUT, output);
waitKey(0);
}
private:
Mat edgeDetection(Mat input) {
Mat output = Mat::zeros(input.rows, input.cols, input.type);
return output;
}
};
int main()
{
CardDetector detector;
detector.detect();
return 0;
}
发生在我们所有人身上。在这一行中:
Mat output = Mat::zeros(input.rows, input.cols, input.type);
input.type 是一个函数,所以你需要:
Mat output = Mat::zeros(input.rows, input.cols, input.type());
这将返回您需要的 int。
顺便说一下,我涉足过OpenCV,但不是很熟悉。我所知道的是你的代码编译得很好,可以进行调整。
相关文章:
- C++-我可以创建另一个类的成员并在构造函数中使用它吗
- int数据类型的指针指向的是什么,如果是一个类的私有数据成员,我们创建了该类的两个对象?
- 使用成员在类中创建 lambda 表达式
- 使用带有 ref 参数的成员函数创建线程时出现编译错误
- C++ 双向链表:使用矩阵类成员创建和填充列表
- 如何创建存储指向成员函数的指针的类 (C++)
- 使用 back_inserter 从结构的单个成员创建向量
- 为类的成员创建别名
- 使用各种数据类型成员创建对象的简便方法
- C 用数组作为成员创建对象
- Visual Studio 2015"非标准语法;使用"&"为成员创建指针"
- 用STD ::函数作为集体成员创建回调
- 如何为班级成员创建开关
- 如何为指针成员创建构造函数
- 如何为成员创建shared_ptr
- c++如何为同一成员创建公共和受保护的访问器
- 如何为指针成员创建对象
- 如何为包装需要2个参数的c函数的unique_ptr类成员创建自定义deleter
- 如何为成员的成员创建boost multi_index密钥
- 使用std::mem_fn为数据成员创建可调用包装