import time
import picamera

#camera = picamera.PiCamera()
#try:
#    camera.start_preview()
#    time.sleep(10)
#    camera.stop_preview()
#	camera.capture('aqwzsx.jpg')
#finally:
#    camera.close()
	
	
import time
import picamera

with picamera.PiCamera() as camera:
    camera.resolution = (1024, 768)
    camera.start_preview()
    # Camera warm-up time
    time.sleep(2)
    camera.capture('foo.jpg')