Speeding up HOG compute in Java [closed]
I have the phyton code like this
def hog_single(img):
samples=[]
gx = cv2.Sobel(img, cv2.CV_32F, 1, 0)
gy = cv2.Sobel(img, cv2.CV_32F, 0, 1)
mag, ang = cv2.cartToPolar(gx, gy)
bin_n = 16
bin = np.int32(bin_n*ang/(2*np.pi))
bin_cells = bin[:100,:100], bin[100:,:100], bin[:100,100:], bin[100:,100:]
mag_cells = mag[:100,:100], mag[100:,:100], mag[:100,100:], mag[100:,100:]
hists = [np.bincount(b.ravel(), m.ravel(), bin_n) for b, m in zip(bin_cells, mag_cells)]
hist = np.hstack(hists)
# transform to Hellinger kernel
eps = 1e-7
hist /= hist.sum() + eps
hist = np.sqrt(hist)
hist /= norm(hist) + eps
samples.append(hist)
return np.float32(samples)
That code from https://github.com/arijitx/HandGesturePy using HOG for hand gesture. my question is how to write that code for speeding up my HOG.compute() in Java ? Because i dont know how to reinvent this part into java please help me.
you are not using HOGDescriptor.compute() , which is parallelized, and SSE/AVX optimized.
don't reinvent the wheel, and profit from opencv's effort at optimization.
What a SSE/AVX optimized means ?
vector operations, like multiplying 4 numbers at a time
How can i implement that in my HOG ?
you can't in java. that's why you should not reinvent it.
Thanks in advance !