Preview fswebcam image as it takes picture
Question: I am currently using a USB webcam with a Raspberry Pi 3. At the moment as part
of a lot of other code in Python it takes a picture using the camera and saves
it to a specific directory. I was wondering whether there was any way of
getting a preview of the image to show up on screen, similarly to how the
picamera works:

`camera.start_preview() time.sleep(5)
camera.capture('/home/pi/Downloads/image.jpg') camera.stop_preview()`

Is there an equivalent to this using fswebcam? The part of the code that takes
the image is:

`from subprocess import call call(["fswebcam", "--no-banner", "image.jpg"])`

Ideally I would like it to preview the image on-screen for a set number of
seconds before capturing it and saving it to the directory. Is this possible?


Answer: I made this kind of function for a commercial app. (no source code here,
sorry) Mixing fswebcam for capturing and other python code for previewing
seems to be a bad idea, as the camera will hardly be available for them both.
(you may try to use "mplayer tv://" as the preview and launch fswebcam from
another terminal to verify this point)

For the python approcah : as the most difficult part will be to display the
preview, you should build your app around this feature. Saving a frame as an
image will be easy from there. I had some success working with Pygame, that
can use v4l2 cameras, managing displays and user events.

In practice, look at <https://gist.github.com/snim2/255151>, the main pygame
function you'll need are there.

Note : don't expect the refresh rate of the preview to be perfect. It will
only be decent. Not sure if it's the camera, v4l2, pygame or python that cause
this ...

