fixed bugs pointed by  wpfnihao

Please refer here for the actual bugs https://github.com/gpsinghsandhu/Kernel-Based-Object-Tracking/commit/99e63138534007eac9dfe9bdc990629f539da8c7

Thanks wpfnihao once again