The videoCapture does exactly what you want.
http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=video#VideoCapture
Steps to follow:
- Create the videoCapture interface, giving the index of your webcam to it.
- Grab a frame, which is automatically stored in a Mat element.
- Use the imsave functionality to store the Mat into an image.
http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imwrite#cv2.imwrite