[英]What does minDist(100) and the curly braces in this piece of code mean?
我剛剛遇到了一段使我感到困惑的代碼。 這是一個頭文件,定義了一個名為ColorDetector的類。 私有部分如下:
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]);
}
這是該類的公開聲明,讓我感到困惑:
public:
// empty constructor
ColorDetector() : minDist(100) {
// default parameter initialization here
target[0]= target[1]= target[2]= 0;
}
我不太清楚此構造函數中的語法。 mindset(100)在這里是什么意思,為什么將目標數組寫在花括號內? 我用關鍵字“默認構造函數”和“默認參數”搜索了google,但沒有找到相關文章。 有人可以在這里告訴我這段代碼的確切含義嗎?
這個的班
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.