How to detect objects in a video opencv with Python?
You can use the following algorithm:
-Perform Background subtraction, as you're doing currently
-enclose foreground in contours (using findContours(,,,) then drawContours(,,,) function)
-enclose obtained contours in bounding boxes (using boundingRect(,,,) function)
-if area of bounding box is approximately equal to that of enclosed contour, then the shape is a square or rectangle, not a triangle. 
(A large part of the box enclosing a triangle will lie outside the triangle)
-if boundingBox height is approximately equal to its width, then it is a square. (access height and width by Rect.height and Rect.width)
I have a video consisting of different objects such as square, rectangle , triangle. I somehow need to detect and show only square objects. So in each frame, if there is a square, it is fine but if there is a triangle or rectangle then it should display it. I am using background subtraction and I am able to detect all the three objects and create a bounding box around them. But I am not able to figure out how to display only square object.