I am implementing motion based object tracking program which is using background substraction, Kalman Filter and Hungarian algorithm. Everything is working fine except the occlusions. When two object are close enough to each other the background substraction recognizes it as one of these two objects. After they split the program recognizes these two objects correctly. I am looking for solution/algorithm which will detect occlusion like shown in point c) in the example below. 
I will appreciate any references or code examples reffering to occlusion detecion problem when using background substraction.
Object detection using a machine learning algorithm should reliably distinguish between these objects, even with significant occlusion. You haven't shared anything about your environment so I don't know what kind of constraints you have, but using an ML approach, here is how I would tackle your problem.
The above example uses this Kalman Filter and Hungarian algorithm, which can track multiple objects in real-time.
Again, not sure about your environment, but you could find pre-built object detection algorithms on the Tensorflow site.