结构如下:
类 Feature 特征点
成员为x,y,label
成员函数为读文件和写文件
类 Template 模板
成员为 宽,高,金字塔层数,vector<Feature>
成员函数也是读文件和写文件
类 QuantizedPyramid 量化金字塔
有三个纯虚函数
量化,抽取模板,下采样
内部有个结构体 Candidate 候选点 成员为Feature 和 score
类 Modality 形态
成员函数 不同类型的量化金字塔的接口(深度或者颜色梯度),通过类型或者文件来创造
形态,
纯虚函数 名字,读文件,写文件,生成量化金字塔的实现
类 ColorGradient 彩色梯度 继承 Modality
多了三个成员,弱阈值,特征点数量,强阈值
类 DepthNormal 深度归一化 继承 Modality
多了四个成员,距离阈值,差别阈值,特征点数量,抽取阈值
一个函数 colormap() 彩色映射,将量化好的图像深度拷贝给传入的参数。
类 Match
成员有 x,y,相似性,类的ID,模板的ID。
重载<运算符,如果相似性不同,比较相似性的大小,如果相似性相同,比较模板ID的大小
类 Detector
成员 vector<Modality> 代表不同形状,vector<int> 它的值代表每层金字塔的采样步长,它的大小代表金字塔层数
成员函数match(vector<Mat>sources,float threshold,vector<match>& matchers,const std::vector<String>& class_ids = std::vector<String>(),
OutputArrayOfArrays quantized_images = noArray(),
const std::vector<Mat>& masks = std::vector<Mat>()); const
int addTemplate(const std::vector<Mat>& sources, const String& class_id,
const Mat& object_mask, CV_OUT Rect* bounding_box = NULL);
增加模板,返回id或者-1(增加失败)
int addSyntheticTemplate(const std::vector<Template>& templates, const String& class_id);
其他只是简单访问参数就不记录
成员
vector<Modality> modalities; 形态集合
int pyramid_levels;金字塔层数
std::vector<int> T_at_level; 金字塔每层步长
typedef std::vector<Template> TemplatePyramid;
typedef std::map<String, std::vector<TemplatePyramid> > TemplatesMap;
TemplatesMap class_templates; 类模板 是一个图,字符串作为键值,里面是二重集合的模板。
TemplatePyramid 就是一个模板图生产的金字塔图像。
TemplatesMap 则是多个不同类型的,并且用字符串作为键值的类。
//暂时不了解,不做介绍。
typedef std::vector<Mat> LinearMemories;
// Indexed as [pyramid level][modality][quantized label]
typedef std::vector< std::vector<LinearMemories> > LinearMemoryPyramid;
void matchClass(const LinearMemoryPyramid& lm_pyramid,
const std::vector<Size>& sizes,
float threshold, std::vector<Match>& matches,
const String& class_id,
const std::vector<TemplatePyramid>& template_pyramids) const;