233-589 colorgradient map 2D
1374 high level detector api
源码地址 https://github.com/meiqua/shape_based_matching/blob/python_binding/line2Dup.cpp
Feature:x,y,orientation 一个像素点和它的方向
Candidate:quantitized pyramid里面的一个struct,有一个feature和它的的score,有一个函数是把score高的feature排到前面
ColorGradient 是由modality 继承过来,作用是computes quantized gradient orientations from a color image
Modality有两个子类 2d的ColorGradient 和3d的depth normal
Modality的主要作用是通过公有函数process计算输入图片的 量化后的 图像金字塔 返回的是一个指向 量化后的 图像金字塔的指针
这里Ptr是一个智能指针(smart pointer),随便指啥都可以
Template:储存了一个feature向量(一张template上的多个像素点),template的h,w,以及所在的pyramid level
Template pyramid:通过typedef新定义的一组template组成的vector,本身template是由一组feature得到的vector。
Templatemap:把string映射到template pyramid的map,可能是针对2d和3d的modality有两种template pyramid
一. 训练
1.1 旋转缩放 选定的template 图
rot_num = max(int((rot_deg_range[1]-rot_deg_range[0]) / rot_deg_range[2]), 1)
scale_num = max(int((scale_range[1]-scale_range[0]) / scale_range[2]), 1)
for rot_deg in np.linspace(rot_deg_range[0], rot_deg_range[1], rot_num):
for scale in np.linspace(scale_range[0], scale_range[1], scale_num):
templ_img, M = linemod.rotateTemplate(img, rot_deg, scale)
1.2 把旋转缩放之后的template 图加入Detector中
is_add_success = linemod.addTemplate(templ_img, "0", info)
template_id, rect = self.detector.addTemplate([img], class_id, mask)
1.2.1 在旋转缩放之后的template图像上得到一个 quantized pyramid
Ptr<ColorGradientPyramid> qp = modality->process(source, object_mask);
这里是通过2d的colorgradient map中的计算功能得到
这个是 直接构造一个 ColorGradientPyramid 对象,返回其指针
ColorGradientPyramid 构造函数中 update(); ,内部是
quantizedOrientations(src, magnitude, angle, weak_threshold);
先做 高斯模糊, 然后 在水平和垂直方向 调用 Sobel,
调用 phase 计算梯度方向,调用 hysteresisGradient, 主要输出就是