[英]What does minDist(100) and the curly braces in this piece of code mean?
I've just met a piece of code that made me confused. 我刚刚遇到了一段使我感到困惑的代码。 It's a header file that defines a class named ColorDetector.
这是一个头文件,定义了一个名为ColorDetector的类。 The private part is as follows:
私有部分如下:
class ColorDetector {
private:
// minimum acceptable distance
int minDist;
// target color
cv::Vec3b target;
// image containing resulting binary map
cv::Mat result;
// inline private member function
// Computes the distance from target color.
int getDistance(const cv::Vec3b& color) const {
// return static_cast<int>(cv::norm<int,3>(cv::Vec3i(color[0]-target[0],color[1]-target[1],color[2]-target[2])));
return abs(color[0]-target[0])+
abs(color[1]-target[1])+
abs(color[2]-target[2]);
}
Here's the public declaration of this class that made me confused: 这是该类的公开声明,让我感到困惑:
public:
// empty constructor
ColorDetector() : minDist(100) {
// default parameter initialization here
target[0]= target[1]= target[2]= 0;
}
I am not quite clear about the grammar in this constructor here. 我不太清楚此构造函数中的语法。 What does mindset(100) mean here and why the target array is written within curly braces?
mindset(100)在这里是什么意思,为什么将目标数组写在花括号内? I searched google with keyword "default constructor" and "default parameter" but found no relating articles.
我用关键字“默认构造函数”和“默认参数”搜索了google,但没有找到相关文章。 Can someone tell me the exact meaning of this piece of code here?
有人可以在这里告诉我这段代码的确切含义吗?
The class of this 这个的班
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.