from time import sleep
from picamera.array import PiRGBArray
from picamera import PiCamera
import picamera
from fractions import Fraction


with picamera.PiCamera() as camera:
    p=6
    h=8
    k=6
    rawCapture = PiRGBArray(camera)
    #camera.resolution=(3280,2464)
    camera.resolution=(640,480)
    #camera.vflip=True
    camera.CAPTURE_TIMEOUT=120
    camera.framerate=Fraction(1, p)
    camera.shutter_speed = 1000000*k
    camera.exposure_mode = 'off'
    camera.iso = 100*h
    print 'config set'
    sleep(10)
    print 'config done. capturing....'
    camera.capture(rawCapture, format="bgr")
    camera.capture('test8.png')
    
    print 'writing to file...'
    
    #camera.capture('image.data','rgb')
