def set_settings(self, optimal): camera = PiCamera() Time.sleep(1) camera.resolution = self.max_size camera.awb_mode = 'off' camera.ISO = optimal['iso'] camera.shutter_speed = optimal['ss'] camera.brightness = 50 camera.contrast = 0 camera.led = False Time.sleep(60) self.camera = camera
def init(): camera = PiCamera() camera.resolution = (320, 240) camera.framerate = 30 camera.sensor_mode = 3 camera.rotation = 90 #camera.exposure_compensation = 0 camera.shutter_speed = camera.exposure_speed camera.exposure_mode = 'off' #camera.awb_mode = 'off' #camera.awb_gains = g #camera.contrast = 10 camera.brightness = 50 camera.saturation = 50 #brighter colours camera.ISO = 100 rawCapture = PiRGBArray(camera, size=(320, 240)) return (camera, rawCapture)
def picam_image_grabbler(inputpipe, image_pipes, resolution, frame_rate, debug=False, format="bgr"): #Pi camera setup camera = PiCamera() camera.resolution = resolution camera.framerate = frame_rate camera.ISO = 1600 camera.sensor_mode = 7 rawCapture = PiRGBArray(camera, size=resolution) #If there is only one pipe, make it into an array to not break future code if (not isinstance(image_pipes, (list, tuple))): image_pipes = [image_pipes] out_pipe_count = len(image_pipes) output_counter = 0 #Capture the frames continuously from the camera for frame in camera.capture_continuous(rawCapture, format=format, use_video_port=True): #print("Grabbled Frame!") #send image down appropriate pipes start_time = time.time() image_pipes[output_counter].send(frame.array) output_counter += 1 if (debug): #cv2.imshow("Image", frame.array) #key = cv2.waitKey(1) #print("Grabbled at: " + str(int(calc_fps(start_time, time.time())))) pass #Clear the pipe counter if necessary if (output_counter >= out_pipe_count): output_counter = 0 #Clear this mmal buffer so it won't overflow rawCapture.truncate(0) start = time.time()
def getVideo(): #Initialize Camera Stream camera = PiCamera() camera.resolution = (320, 240) #These values are subject to change, use the Testing Suite to determine what range of values you want camera.brightness = 50 camera.ISO = 100 camera.shutter_speed = 1000 rawCapture = PiRGBArray(camera, size=(320, 240)) ###Edit the line below and change the IP address to your robot's ip (i.e. "10.30.61.17"), port is an arbitrary number client = UDP_Client.Client("Robot IP", 9000) #(IP,PORT) #frame_time is a pretty precise way of getting the timestamp of your image if you need it frame_time = time.time() for frame in camera.capture_continuous(rawCapture, format='bgr', use_video_port=True): image = frame.array ###DO YOUR PROCESSING HERE USING OpenCV and the image variable ###Refer to the Image Processing module and call its function process_image here process_image(image) ###Input your data and tags into the list below to send data to the rio ###This data is converted to a json string FYI, makes the sending faster client.sendData({"X": 0, "Y": 0, "Z": 0, "Time": frame_time}) #this trunctates the stream of images to grab the current image rawCapture.truncate(0) frame_time = time.time() if cv2.waitKey(1) & 0xFF == ord('q'): cv2.destroyAllWindows() break
width = 320 height = 240 rectx1 = 50 recty1 = 0 rectx2 = 250 recty2 = height minLineLength = 1 maxLineGap = 10 # initialize the camera and grab a reference to the raw camera capture camera = PiCamera() camera.resolution = (width, height) camera.framerate = 60 camera.ISO = 800 time.sleep(2) stream = PiRGBArray(camera, size=(width, height)) for f in camera.capture_continuous(stream, format="bgr", use_video_port=True): src = stream.array linecount = 0 # Convert BGR to HSV hsv = cv2.cvtColor(src,cv2.COLOR_BGR2HSV) edges = cv2.Canny(hsv,50,150,apertureSize = 3) lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap) if lines is not None:
interval = int(sys.argv[3]) # wait time in seconds e.g. 1800 steps = int(sys.argv[4]) # number of images e.g 200 else: print ("Required parameters: folder name, filename, interval (secs), number of steps.") sys.exit() print('folder = ' + folder + '\nfilename = ' + filename + '\ninterval = ' + str(interval) + ' sec'+ '\nsteps = '+ str(steps)) # make the folder if it doesn't exist if os.path.exists(folder) == False: os.mkdir(folder) # Minimal camera settings camera.resolution=(960,720) camera.ISO=400 camera.framerate = 1 # frames/sec, determines the max shutter speed camera.shutter_speed = 500000 # exposure time in microsecs camera.exposure_mode = 'off' # camera.awb_gains = [1,1] camera.awb_mode = 'off' # Advanced camera users: # ------------------------------------------------------------- # These are other possible parameters to change, depending on experiment: #camera.analog_gain = 1 #camera.digital_gain=1 #camera.brightness = 50 #camera.sharpness = 0 #camera.contrast = 0 # useful to take reduce the background #camera.saturation = 0
path = sys.path[0] cv2.imwrite( str(path) + "/" + strftime("%Y_%m_%d__%I_%M_%S", gmtime()) + "_DistPic.jpg", found) print "Picture saved" cv2.destroyAllWindows() else: cv2.destroyAllWindows() camera = PiCamera() camera.resolution = (640, 480) camera.framerate = 30 camera.meter_mode = 'matrix' camera.shutter_speed = 6000 camera.ISO = 800 aruco_dic = aruco.Dictionary_get(aruco.DICT_6X6_250) master = Tk() master.title("Get Area") instr = Label( master, text= "Press t to take a picture \n Press s on the pictures window to save picture \n Press any other letter on pictures window to close window" ) instr.pack() master.bind("<KeyRelease-t>", take_pic)
#camera.video_stabilization = False #camera.exposure_mode ='auto' #camera.awb_mode = 'off' #camera.awb_mode = 'auto' #camera.awb_mode = 'sunlight' #camera.awb_mode = 'cloudy' #camera.awb_mode = 'shade' #camera.awb_mode = 'tungsten' #camera.awb_mode = 'fluorescent' #camera.awb_mode = 'incandescent' #camera.awb_mode = 'flash' #camera.awb_mode = 'horizon' camera.ISO = 200 camera.saturation = 50 rawCapture = PiRGBArray(camera, size=(ImgWidth, ImgHeight)) #Fixed exposure #warm up time 3 seconds time.sleep(3) camera.shutter_speed = camera.exposure_speed expSpeed = camera.shutter_speed camera.exposure_mode = 'off' g = camera.awb_gains
num_pics = int(sys.argv[1]) # set up camera print '%0.2f: Initializing Camera' % (time.time() - time_start) camera = PiCamera() if (int(sys.argv[2]) == 0): width = 640 # Mode 7, 640x480, aspect ratio 4:3, 40 to 90 fps, full FoV height = 480 else: width = 1648 # Mode 4, 1648x1232, aspect ratio 4:3, 1/10 to 40 fps, full FoV height = 1232 filename = sys.argv[3] camera.resolution = (width, height) camera.framerate = 30 camera.shutter_speed = 0 # Automatic selection camera.ISO = 0 # Automatic selection camera.meter_mode = 'matrix' rawCapt = PiRGBArray(camera, size=(width, height)) time.sleep(2) print '%0.2f: Initializing Camera Finished' % (time.time() - time_start) # set up aruco print '%0.2f: Initializing ArUco' % (time.time() - time_start) aruco_dic = aruco.Dictionary_get(aruco.DICT_5X5_50) print '%0.2f: Initializing ArUco Finished' % (time.time() - time_start) # set up sift print '%0.2f: Initializing SIFT' % (time.time() - time_start) grayImg = cv2.imread('/home/pi/speedtest/qrcode_200x200.png', 0) # TODO PUT THIS IN sift = cv2.xfeatures2d.SIFT_create()
# Time-Lapes Pi Camera # created on 29.08.2017 Tony Davis from picamera import PiCamera from time import sleep import datetime import time timer_a = time.time() # duration timer camera = PiCamera() camera.resolution = (1280, 720) camera.sharpness = 0 camera.contrast = 0 camera.brightness = 50 camera.saturation = 0 camera.ISO = 0 camera.video_stabilization = False camera.exposure_compensation = 0 camera.exposure_mode = 'auto' camera.awb_mode = 'auto' camera.image_effect = 'none' camera.meter_mode = 'average' #camera.colour_effect = 'None' camera.rotation = 90 camera.contrast = 0 date = datetime.datetime.now().strftime("%d_%m_%Y_%H_%M_%S") #------------- change these values to set freuency and duration--------------------# feq = 2 # interval between taking a picture (in seconds)
##recordNameFull = recordName+"_"+dateT+".jpg" recordNameFull = recordName client_sock.send("Tomando fotografia") print("Tomando fotografia") try: if camera == '': camera = PiCamera() camera.resolution = (1024, 1024) #1080 972 camera.start_preview(alpha=255) #camera.framerate = 5 camera.sharpness = 10 #-100 100 camera.contrast = 40 #-100 100 camera.brightness = 50 #0 100 camera.saturation = 40 #-100 100 camera.ISO = 250 #0 1600 camera.video_stabilization = False camera.exposure_compensation = 15 #-25 25 camera.exposure_mode = 'backlight' camera.meter_mode = 'average' camera.awb_mode = 'off' camera.awb_gains = 1.7 camera.image_effect = 'none' camera.color_effects = None camera.rotation = 0 camera.hflip = False camera.vflip = False camera.crop = (0.0, 0.0, 1.0, 1.0) sleep(2) camera.stop_preview()
camera.saturation = 0 img_base_name = './out/image_{}{}_g{}_{}.jpg' camera.exposure_mode = 'auto' gain = 'auto' sleep(2) for i in range(2): print('capturando imagem {} com ganho {}'.format(i, gain)) sleep(0.2) camera.capture(img_base_name.format(now.month, now.day, gain, i)) camera.exposure_mode = 'off' gain = 10 camera.ISO = gain sleep(2) for i in range(3): print('capturando imagem {} com ganho {}'.format(i, gain)) sleep(0.2) camera.capture(img_base_name.format(now.month, now.day, gain, i)) gain = 60 camera.exposure_mode = 'off' camera.ISO = gain sleep(2) for i in range(3): print('capturando imagem {} com ganho {}'.format(i, gain)) sleep(0.2) camera.capture(img_base_name.format(now.month, now.day, gain, i))
else: print( "Required parameters: folder name, filename, interval (secs), number of steps." ) sys.exit() print('folder = ' + folder + '\nfilename = ' + filename + '\ninterval = ' + str(interval) + ' sec' + '\nsteps = ' + str(steps)) # make the folder if it doesn't exist if os.path.exists(folder) == False: os.mkdir(folder) # Minimal camera settings camera.resolution = (960, 720) camera.ISO = 700 camera.framerate = 1 # frames/sec, determines the max shutter speed camera.shutter_speed = 200000 # exposure time in microsecs camera.exposure_mode = 'auto' #'fixedfps' camera.awb_gains = [1, 1] camera.awb_mode = 'off' # Advanced camera users: # ------------------------------------------------------------- # These are other possible parameters to change, depending on experiment: #camera.analog_gain = 1 #camera.digital_gain=1 #camera.brightness = 50 #camera.sharpness = 0 #camera.contrast = 0 # useful to take reduce the background #camera.saturation = 0
cam.rotation = 0 # Rotation back to default cam.capture( '/home/pi/Desktop/bench.jpg' ) # Take an image and store it in the prescribed directory and file name cam.resolution # Get the current resolution settings cam.resolution = (1280, 720) # Set a new resolution cam.capture( '/home/pi/Desktop/bench2.jpg') # Take an image at the last set resolution cam.capture( '/home/pi/Desktop/bench2.jpg', resize=(800, 480)) # Take an image at the last set resolution, then resize it # Other things you can do with your camera... cam.sharpness = 0 cam.contrast = 0 cam.brightness = 50 cam.saturation = 0 cam.ISO = 0 cam.video_stabilization = False cam.exposure_compensation = 0 cam.exposure_mode = 'auto' cam.meter_mode = 'average' cam.awb_mode = 'auto' cam.image_effect = 'none' cam.color_effects = None cam.rotation = 0 cam.hflip = False cam.vflip = False cam.crop = (0.0, 0.0, 1.0, 1.0)
from picamera import PiCamera from time import sleep import time camera = PiCamera() camera.rotation = 180# image was upside down camera.brightness = 60# default brightness is 50; this makes the # picture slightly brighter through longer # exposure #camera.ISO = 800 camera.ISO = 1600 camera.start_preview()# I think this basically turns the camera on import os #rootdir = '/home/pi/baby_monitor' rootdir = '/home/pi/git/cherrypy_learn/img/' if not os.path.exists(rootdir): os.mkdir(rootdir) foldername = time.strftime('%m_%d_%y') folderpath = os.path.join(rootdir, foldername) print('folderpath: ' + folderpath) if not os.path.exists(folderpath): os.mkdir(folderpath) t1 = time.time() runtime = 180.0*60# 30 minutes, expressed in seconds endtime = t1 + runtime curtime = time.time() while curtime < endtime:
cam.start_preview() # Show a preview cam.start_preview(alpha=150) # Show a preview with alpha for transparency at 150 (valid values 0..255) cam.stop_preview() # Stop a preview cam.rotation = 180 # Rotate preview and still image by 180 degrees cam.start_preview() # Show the preview with the rotation set in the previous line cam.stop_preview() cam.rotation = 0 # Rotation back to default cam.capture('/home/pi/Desktop/bench.jpg') # Take an image and store it in the prescribed directory and file name cam.resolution # Get the current resolution settings cam.resolution=(1280,720) # Set a new resolution cam.capture('/home/pi/Desktop/bench2.jpg') # Take an image at the last set resolution cam.capture('/home/pi/Desktop/bench2.jpg', resize=(800,480)) # Take an image at the last set resolution, then resize it # Other things you can do with your camera... cam.sharpness = 0 cam.contrast = 0 cam.brightness = 50 cam.saturation = 0 cam.ISO = 0 cam.video_stabilization = False cam.exposure_compensation = 0 cam.exposure_mode = 'auto' cam.meter_mode = 'average' cam.awb_mode = 'auto' cam.image_effect = 'none' cam.color_effects = None cam.rotation = 0 cam.hflip = False cam.vflip = False cam.crop = (0.0, 0.0, 1.0, 1.0)
from picamera.array import PiRGBArray from picamera import PiCamera import time import cv2 ImgWidth = 640 ImgHeight = 480 camera = PiCamera(resolution=(ImgWidth, ImgHeight), framerate=30) #camera.sharpness = 100 #camera.saturation = 100 camera.ISO = 100 camera.video_stabilization = False camera.exposure_mode ='auto' #camera.awb_mode = 'off' camera.awb_mode = 'auto' #camera.awb_mode = 'sunlight' #camera.awb_mode = 'cloudy' #camera.awb_mode = 'shade' #camera.awb_mode = 'tungsten' #camera.awb_mode = 'fluorescent' #camera.awb_mode = 'incandescent' #camera.awb_mode = 'flash' #camera.awb_mode = 'horizon' camera.image_effect = 'saturation' #camera.image_effect = 'deinterlace1'
ALIGN_H1_CROP_Y_2 = 350 ALIGN_H2_CROP_X_1 = 870 ALIGN_H2_CROP_X_2 = 915 ALIGN_H2_CROP_Y_1 = 490 ALIGN_H2_CROP_Y_2 = 540 HOLE_MIN_AREA = 50 HOLE_MAX_AREA = 400 camera = PiCamera() camera.resolution = (w, h) camera.exposure_mode = CAMERA_EXPOSURE_MODE camera.contrast = CAMERA_CONTRAST camera.brightness = CAMERA_BRIGHTNESS camera.saturation = CAMERA_SATURATION camera.ISO = CAMERA_ISO camera.video_stabilization = CAMERA_STABILIZATION camera.exposure_mode = CAMERA_EXPOSURE_MODE camera.sharpness = CAMERA_SHARPNESS camera.meter_mode = CAMERA_METER_MODE camera.awb_mode = CAMERA_MODE camera.awb_gains = CAMERA_AWB_GAINS camera.image_effect = 'none' camera.color_effects = None camera.rotation = CAMERA_ROTATION camera.hflip = CAMERA_HFLIP camera.vflip = CAMERA_VFLIP camera.crop = (0.0, 0.0, 1.0, 1.0) camera.exposure_compensation = EXPOSURE_COMPENSATION_WHITE camera.framerate = 24 rawCapture = PiRGBArray(camera, size=(w, h))
cv2.createTrackbar(hl, wnd, 0, 255, nothing) cv2.createTrackbar(hh, wnd, 255, 255, nothing) cv2.createTrackbar(sl, wnd, 0, 255, nothing) cv2.createTrackbar(sh, wnd, 255, 255, nothing) cv2.createTrackbar(vl, wnd, 0, 255, nothing) cv2.createTrackbar(vh, wnd, 255, 255, nothing) cv2.createTrackbar("ISO", wnd, 100, 1600, nothing) cv2.createTrackbar("Brightness", wnd, 50, 100, nothing) camera = PiCamera() camera.resolution = (320, 240) rawCapture = PiRGBArray(camera, size=(320, 240)) time.sleep(.5) ##camera.exposure_mode= 'sports' camera.brightness = 5 camera.ISO = 100 #camera.sharpness = 100 #camera.contrast = 100 #camera.awb_mode = 'off' camera.shutter_speed = 1000 print camera.shutter_speed print camera.exposure_speed print camera.framerate for frame in camera.capture_continuous(rawCapture, format='rgb', use_video_port=True): upperHue = cv2.getTrackbarPos(hh, wnd) lowerHue = cv2.getTrackbarPos(hl, wnd) upperSat = cv2.getTrackbarPos(sh, wnd)