0

I'm creating a simple python script that uses gphoto2 to take a photo from my usb connected camera and feh to display the photo.

When I run program, gphoto2 will capture the photo and feh will open it but I would like to return to the command line to take another photo without having to manually close the image window.

Is there someway I can run the program from the command line continually without have to close the image window?

class PhotoBooth(object):

    def capture_photo(self):
            filename = join(out, '%s.jpg' % str(uuid4()))
            subprocess.call('gphoto2 --capture-image-and-download --filename="%s"' % filename, shell=True)
            return filename

    def print_photo(self, filename):
            subprocess.Popen('feh --g 640x480 ' + filename, shell=True)


photobooth = PhotoBooth()

try:
    while True:
            raw_input("Press enter to capture photo")
            filename = photobooth.capture_photo()
            photobooth.print_photo(filename)

    except KeyboardInterrupt:
            print "\nExiting..."
qidaas
  • 156
  • 1
  • 4

2 Answers2

0

If you spawn the feh process in the background, you should be able to do it all in a simple loop. See this question on StackOverflow for the incantation to do it:

How to start a background process in Python?

Community
  • 1
  • 1
Michael
  • 1,306
  • 1
  • 12
  • 30
  • I included my code in my original question above. I still can't use the command terminal once the feh window open. I would like to continue to capture photos had have the feh window in the foreground display in the pictures. Am I missing something? – qidaas Sep 17 '13 at 03:56
  • "background process" is not exclusive with "window in the foreground" – Javier Sep 25 '13 at 20:50
0

The link Michael provided gives you an answer. If that method doesn't work, you could try using & at the end of the feh command. On the command line in linux & at the end of a command will run a command in the background.

Joe McCay
  • 13
  • 4