How to select the specific frame with object
I'm seeing two issues here:


Frames with no activity: You can check the gradient between successive frames and only do object detection when the gradient information passes a certain threshold.
Counting the same object: The vehicle location information can be useful for this task. If the gradient change occurs in the location of a detected object in the previous frame then it is the same vehicle. If necessary, you can also use object color and object size parameters to account for varying speeds.