The gesture's code with opencv doesn't count the finger

I made that replacing above but doesn’t work.
Why? The number of finger was wrong.