How to count captured object from webcam in python?

I have trained my model (by using Darkflow YOLOV2 and OpenCV) for single class, i want to count the object detected in webcam, means it should count unique object, if same object detecting in webcam frame then it should count as one until it leave the frame. Anyone can tell me please, how can i do so.

Thanks in advance.