0
bin_n = 16 # Number of bins
def hog(img):
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 = bins[:10,:10], bins[10:,:10], bins[:10,10:], bins[10:,10:]
mag_cells = mag[:10,:10], mag[10:,:10], mag[:10,10:], mag[10:,10:]
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 64 bit vector
return hist
path1='d:\\Emmanu\\project-data\\training-set\\1\\'
listing1 = os.listdir(path1)
for file in listing1:
img = cv2.imread(path1 + file)
h=hog(img)
print h
我得到的名單像
什麼是列表中的每個數字表示一長串的圖像Extracing HOG特徵?