hog_5_4.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:logo-detect 作者: sunbinbin1991 项目源码 文件源码
def hog(img):
  h, w = img.shape

  gx = cv2.Sobel(img, cv2.CV_32F, 1, 0)
  gy = cv2.Sobel(img, cv2.CV_32F, 0, 1)

  mag, ang = cv2.cartToPolar(gx, gy)
  bins = np.int32(bin_n*ang/(2*np.pi))    # quantizing binvalues in (0...16)


  bin_cells = ()
  mag_cells = ()
  for i in range(wc):
    for j in range(hc):
      bin_cells += (bins[j*h/hc:(j+1)*h/hc, i*w/wc:(i+1)*w/wc],)
      mag_cells += (mag[j*h/hc:(j+1)*h/hc, i*w/wc:(i+1)*w/wc],)


  hists = [np.bincount(b.ravel(), m.ravel(), bin_n) for b, m in zip(bin_cells, mag_cells)]
  hist = np.hstack(hists)     # hist is a 16*wc*hc vector

  return hist
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号