def __call__(self, cam: PiCamera, *args, **kwargs): if self._fmt is not None: cam.annotate_background = Color('black') cam.annotate_text = datetime.now().strftime(self._fmt) else: cam.annotate_background = None cam.annotate_text = None
def run(self): # Write captures to memory stream = BytesIO() # Init camera camera = PiCamera() camera.sensor_mode = 2 camera.resolution = (2592, 1944) camera.framerate = 12 camera.hflip = True camera.annotate_text_size = 100 # Add overlay o = camera.add_overlay(self.overlay.padded.tobytes(), layer=3, alpha=255, size=self.overlay.image.size) RED = Color('#ff0000') GREEN = Color('#00ff00') BLUE = Color('#0000ff') camera.annotate_text = 'SCANNING' camera.annotate_background = BLUE camera.start_preview() try: while True: camera.annotate_text = 'SCANNING' camera.annotate_background = BLUE sleep(3) stream.seek(0) camera.capture(stream, format='jpeg', resize=(self.overlay.image.size[0], self.overlay.image.size[1])) stream.seek(0) image = Image.open(stream) image = image.crop(self.overlay.roi_a + self.overlay.roi_b) image = image.transpose(Image.FLIP_LEFT_RIGHT) qr = qrdecode(image) print(qr) if len(qr) != 0: if self.qr_validator(qr[0][0].decode()): camera.annotate_text = 'AUTHORIZED' camera.annotate_background = GREEN else: camera.annotate_text = 'NOT AUTHORIZED' camera.annotate_background = RED sleep(3) finally: camera.remove_overlay(o) camera.close()
def _initialize_camera(config_camera): logging.info("Initialize Camera") # Parse configuration options resolution_height = config_camera["resolution_height"] resolution_width = config_camera["resolution_width"] annotate_text_size = config_camera["annotate_text_size"] annotate_text = config_camera["annotate_text"] annotate_foreground = config_camera["annotate_foreground"] annotate_background = config_camera["annotate_background"] camera = PiCamera() logging.debug("Image Resolution: Height=[%s]; Width=[%s]" % (resolution_height, resolution_width)) camera.resolution = (resolution_height, resolution_width) # turn camera to black and white camera.color_effects = (128, 128) camera.contrast = config_camera["contrast"] camera.brightness = config_camera["brightness"] camera.exposure_mode = 'auto' if config_camera["annotate"]: logging.debug("Set annotate text size to [%s]" % (annotate_text_size)) camera.annotate_text_size = annotate_text_size camera.annotate_foreground = Color(annotate_foreground) camera.annotate_background = Color(annotate_background) text = ' ' + annotate_text + ' ' logging.debug("Annotate text is [%s]" % (text)) camera.annotate_text = text logging.info("Start Camera Preview") #camera.start_preview() return camera
def videoRecording(totalTime): camera = PiCamera() currentTime = datetime.now() currentTime = currentTime.strftime("%Y:%m:%d:%I:%M:%S") print("Start time:" + currentTime) camera.annotate_background = Color("green") camera.annotate_foreground = Color("yellow") camera.annotate_text = "start time: " + currentTime camera.annotate_text_size = 50 currentTime = datetime.now() currentTime = currentTime.strftime("%Y:%m:%d:%I:%M:%S") startTime = currentTime print("Video start:" + startTime) camera.start_preview() camera.start_recording("./allVideoRecording/%s.h264" % startTime) sleep(totalTime) camera.stop_recording() camera.stop_preview() currentTime = datetime.now() currentTime = currentTime.strftime("%Y:%m:%d:%I:%M:%S") print("Video end:" + currentTime) camera.close() return startTime
def take_pic(): camera = PiCamera() # camera.rotatio=180 # Default is the monitor's resolution # still image(max 2592*1944), video (max 1920*1080) # min resolution 64*64 camera.resolution = (1920, 1080) # when set max resolution, framerate should be 15 # camera.framerate = 15 # camera.brightness=70 # camera.contrast=20 # valid size are 6-160, default 32 camera.annotate_text_size = 30 camera.annotate_background = Color('black') annotation = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) camera.annotate_text = annotation camera.start_preview() # camera.IMAGE-EFFECTS # camera.image_effect = 'gpen' # camera.AWB_MODES camera.awb_mode = 'auto' # camera.EXPOSURE_MODES camera.exposure_mode = 'auto' # sleep for at least 2 seconds, sensor auto set its light levels time.sleep(3) camera.capture('./image.jpg') camera.stop_preview()
def main(): rotation = 0 sleeptime = 3 run_program = True try: opts, args = getopt.getopt(sys.argv[1:], "r:s:", ["rotation=", "sleeptime="]) except getopt.GetoptError as err: print(str(err)) sys.exit(2) for opt, arg in opts: if opt in ("-r", "--rotation"): rotation = arg elif opt in ("-s", "--sleeptime"): sleeptime = arg print("Rotation : " + str(rotation)) print("Sleeptime : " + str(sleeptime)) while run_program: try: camera = PiCamera() camera.rotation = int(rotation) # https://picamera.readthedocs.io/en/release-1.13/fov.html#sensor-modes #camera.resolution = (3280, 2464) camera.resolution = (1600, 1200) #camera.resolution = (1920, 1080) # 3280x2464 which is 4:3 camera.annotate_text_size = 64 camera.annotate_background = Color('black') camera.annotate_foreground = Color('white') for i in range(7200): sleep(int(sleeptime)) filenamestamp = datetime.datetime.fromtimestamp( time.time()).strftime('%Y_%m_%d_%H_%M_%S') annotationstamp = datetime.datetime.fromtimestamp( time.time()).strftime('%Y-%m-%d %H:%M:%S') camera.annotate_text = annotationstamp + ' ' + str(i) # Capture options: # - quality has range from 1 to 100, default is 85. 1 is low quality and 100 is high quality camera.capture('/home/pi/github/ip-cam/upl/%s_py.jpeg' % filenamestamp, resize=(1600, 1200), quality=20) #camera.capture('/home/pi/github/ip-cam/upl/%s_py.jpeg' % filenamestamp, quality=20) #camera.capture('/home/pi/github/ip-cam/upl/%s_py.jpeg' % filenamestamp, quality=10) else: camera.close() except KeyboardInterrupt: print("Exception: ", sys.exc_info()) run_program = False except: print("Exception: ", sys.exc_info()) finally: camera.close() if run_program: print("Restart program.") print("End program.")
def show(): camera = PiCamera() gps = "5sec" camera.hflip = True #camera.brightness = 50 os.system("sudo ./hub-ctrl -h 1 -P 2 -p 1") camera.start_preview() camera.annotate_background = Color('red') camera.annotate_foreground = Color('white') camera.annotate_text = gps sleep(5) camera.stop_preview() os.system("sudo ./hub-ctrl -h 1 -P 2 -p 0") camera.close()
def capturePicture(filename='/tmp/iantest.jpg'): camera = PiCamera() # Heat the camera up camera.rotation = 180 camera.start_preview() camera.annotate_background = Color('blue') camera.annotate_foreground = Color('yellow') camera.annotate_text_size = 20 now = time.strftime("%c") camera.annotate_text = " Serena [TRB]: %s "% now time.sleep(.5) camera.capture(filename) time.sleep(.5) camera.stop_preview() return
def snap_image(text, effect): global image_path camera = PiCamera() camera.start_preview() sleep(5) if len(text) < 0: camera.annotate_background = Color('blue') camera.annotate_foreground = Color('red') camera.annotate_text_size = 50 camera.annotate_text = text if len(effect) < 0: camera.image_effect = effect sleep(2) camera.capture(image_path) sleep(10) camera.stop_preview()
def snapshot(self): camera = PiCamera() camera.vflip = self.VFLIP camera.hflip = self.HFLIP camera.resolution = (self.HRES / 2, self.VRES / 2) log.debug("Take a snapshot") camera.annotate_text_size = 120 camera.annotate_background = picamera.Color('black') camera.annotate_text = datetime.datetime.now().strftime( '%Y-%m-%d %H:%M:%S') camera.capture(self.path + "snapshot.png") camera.close() shutil.rmtree(self.path + "snapshot_files", ignore_errors=True) self.log.debug("Make the snapshot zoomable") deepzoom.ImageCreator().create(self.path + "snapshot.png", self.path + "snapshot.dzi")
def take_photo(): ####################################### #Initialization ####################################### demoCamera = PiCamera() demoCamera.start_preview() demoCamera.annotate_background = Color('white') demoCamera.annotate_foreground = Color('red') demoCamera.annotate_text = " SWS3009B - 2019" sleep(5) name_time = time.ctime() picture_name = '/home/pi/Desktop/camera/cat' + str(name_time) + '.jpg' demoCamera.capture(picture_name) demoCamera.stop_preview()
def detect_and_record_motion(): """ Detects and records motion via interfacing with PIR sensor and camera. Saves the recording locally then triggers a function to upload/clean up """ # Grab folder id from config file conf = configparser.ConfigParser() conf.read('config.ini') vid_pth = conf['tmp_dir']['path'] drive_folder_id = conf['google_drive']['folder_id'] # Create utilities instance drive_utils = DriveUtilities(drive_service, logger) # Motion sensor module connected to pin 4 (5v) pir = MotionSensor(4) camera = PiCamera() camera.resolution = (1280, 720) camera.vflip = True try: while True: # PIR sensor triggered, camera starts recording for a minimum of 10 seconds pir.wait_for_active() logger.info('>>>PIR sensor: Motion detected') triggered_datetime = datetime.datetime.today().strftime( '%Y-%m-%d_%H-%M-%S') file_path = vid_pth + triggered_datetime + '.h264' camera.start_recording(file_path) camera.annotate_background = Color('red') camera.annotate_text_size = 20 camera.annotate_text = triggered_datetime time.sleep(10) # PIR sensor becomes inactive, camera stops recording and file is uploaded pir.wait_for_inactive() camera.stop_recording() logger.info('>>>PIR sensor: Motion ended') clean_and_upload(file_path, drive_utils, drive_folder_id) except KeyboardInterrupt: camera.close() sys.exit()
def picamstarttlapse(): global trigger_flag global process_flag global tlapse_thread global EVENTTIME playsound("tlapse") time.sleep(2) camera = PiCamera() camera.resolution = (RESOLUTIONX, RESOLUTIONY) camera.rotation = ROTATION camera.brightness = BRIGHTNESS camera.contrast = CONTRAST camera.awb_mode = AWBMODE if (TIMESTAMP == 'true'): camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S') camera.annotate_background = picamera.Color('black') videoprefix = "RPiT-" #filetime = int(time.time() / TIMELAPSEINTERVAL) while (testBit(trigger_flag, 2) != 0): filetime = int(time.time() / TIMELAPSEINTERVAL) #cleanoldfiles() if (TIMESTAMP == 'true'): camera.annotate_text = dt.datetime.now().strftime( '%Y-%m-%d %H:%M:%S') logging.info( f"I Take Timelapse Image : {IMAGEPATH + '/' + datetime.now().strftime(videoprefix + '%Y%m%d-%H%M%S') + '.jpg'}" ) playsound("image") camera.capture(IMAGEPATH + "/" + datetime.now().strftime(videoprefix + '%Y%m%d-%H%M%S') + '.jpg') while (testBit(trigger_flag, 2) != 0) and (int( time.time() / TIMELAPSEINTERVAL) <= filetime): time.sleep(1) EVENTTIME = int(time.time()) camera.close() process_flag = clearBit(process_flag, 2) time.sleep(1)
def apiCapture(): camera = PiCamera() camera.resolution = (2592, 1944) #camera.resolution = (1296, 972) camera.iso = 1600 ## Camera warm-up time camera.start_preview() sleep(2) now = datetime.now() hour = int(now.strftime("%H")) if (hour >= 7 and hour <= 14): camera.iso = 100 if (hour >= 15 and hour <= 16): camera.iso = 200 if (hour >= 17 and hour <= 18): camera.iso = 400 folder = _folder + now.strftime("%Y%m") if not os.path.exists(folder): os.mkdir(folder) timestamp = now.strftime("%Y%m%d_%H%M%S") imageFile = timestamp + '.jpg' filePath = folder + "/" + imageFile string = now.strftime(" %Y-%m-%d %H:%M:%S") + " @Raspberry Pi Zero W " camera.annotate_foreground = Color('black') camera.annotate_background = Color('white') camera.annotate_text = string camera.capture(filePath) camera.close() return send_file(filePath, mimetype="image/jpeg")
def capturePicture(siteName): global motionCapturedDirectory camera = PiCamera() #camera.rotation = 90 # Heat the camera up camera.start_preview() #camera.brightness = 50 camera.annotate_background = Color('black') camera.annotate_foreground = Color('white') camera.annotate_text_size = 17 nowNice = time.strftime("%c") nowRaw = time.strftime("%Y%m%d-%H%M%S") nowEpoch = int(time.time()) checkPath(motionCapturedDirectory+"/"+siteName) filename = '%s/%s/%s.jpg'% (motionCapturedDirectory, siteName, nowRaw) camera.annotate_text = 'Site:[%s] %s'% (siteName, nowNice) time.sleep(1) camera.capture(filename) time.sleep(.5) camera.stop_preview() # send filename back to caller return filename
def timeLapse(increment, totalAmount): camera = PiCamera() currentTime = datetime.now() currentTime = currentTime.strftime("%Y:%m:%d:%I:%M:%S") print("Start Time:" + currentTime) camera.annotate_background = Color("green") camera.annotate_foreground = Color("yellow") camera.annotate_text = currentTime camera.annotate_text_size = 50 amountOfPictures = 0 while (amountOfPictures < totalAmount): currentTime = datetime.now() currentTime = currentTime.strftime("%Y:%m:%d:%I:%M:%S") print("Picture taken:" + currentTime) camera.capture("./allTimeLapse/%s.jpg" % currentTime) sleep(increment) amountOfPictures += 1 #print(amountOfPictures) camera.close()
def take_a_picture(app): mode = app.config['PHOTO_MODE'] delay = app.config['PHOTO_DELAY'] width = app.config['PHOTO_WIDTH'] height = app.config['PHOTO_HEIGHT'] text_size = app.config['PHOTO_TEXT_SIZE'] background = app.config['PHOTO_BACKGROUND'] quality = app.config['PHOTO_QUALITY'] instant, label = now() filename = os.path.join(os.path.dirname(__file__), 'static/' + instant + '.jpg') try: camera = PiCamera() camera.resolution = (width, height) camera.awb_mode = mode camera.start_preview() sleep(float(delay)) weather = get_weather(app.config) camera.annotate_text = label + "\n" + weather camera.annotate_text_size = text_size camera.annotate_background = Color(background) camera.capture(filename, format='jpeg', quality=quality) except Exception as e: print(weather) app.logger.error(e) return False finally: if 'camera' in locals(): camera.close() return True else: return False
def main(): date = time.strftime("%Y_%m_%d_%H_%M_%S") date_photo = time.strftime("%d-%m-%Y %H:%M") name_file = '/home/bertrand/images/someone_%s.png' % date camera = PiCamera() camera.rotation = 180 camera.resolution = (2592, 1458) camera.annotate_text_size = 50 camera.annotate_text = date_photo camera.annotate_background = Color('white') camera.annotate_foreground = Color('black') camera.brightness = 60 camera.contrast = 55 time.sleep(5) camera.capture(name_file) camera.close() shutil.move(name_file, '/home/bertrand/workspace/rasp/static/image_last/last.png') foo = Image.open('/home/bertrand/workspace/rasp/static/image_last/last.png').convert('RGB') foo = foo.resize((1024, 576), Image.ANTIALIAS) foo.save("/home/bertrand/workspace/rasp/static/image_last/last.jpg", optimize=True, quality=95) return
# Power management registers pada accelerometer power_mgmt_1 = 0x6b power_mgmt_2 = 0x6c #Inisialisasi Pi Camera camera=PiCamera() camera.resolution = (1280,720) now=datetime.datetime.now() jam=now.hour if ((jam>6)and(jam<18)): camera.start_preview() camera.exposure_mode = 'antishake' camera.annotate_text_size = 25 camera.annotate_foreground = Color('black') camera.annotate_background = Color('white') else: #NIGHT MODE camera.brightness = 60 camera.contrast = 30 camera.sharpness = 65 camera.exposure_mode = 'night' camera.start_preview() #camera.exposure_mode = 'nightpreview' # Waktu saat ini temptime_init=time.time() localtime=time.asctime(time.localtime(time.time())) #counter=1 #counter_priority=1
def picamstartrecord(): global trigger_flag global process_flag global record_thread global EVENTTIME playsound("record") time.sleep(2) timelapsedelta = 0 #logging.info("1") camera = PiCamera() camera.resolution = (RESOLUTIONX, RESOLUTIONY) camera.rotation = ROTATION camera.brightness = BRIGHTNESS camera.contrast = CONTRAST camera.awb_mode = AWBMODE camera.framerate = FRAMEPS if (TIMESTAMP == 'true'): camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S') camera.annotate_background = picamera.Color('black') videoprefix = "RPiR-" #logging.info("2") # add a delay to ensure recording starts > 5 and < 55 to avoid clashing with the snapshot image. # while (int(time.time()) % 60 <= 5 or int(time.time()) % 60 >= 55): # time.sleep(5) while (testBit(trigger_flag, 0) != 0): filetime = int(time.time() / (VIDEOINTERVAL * 60)) #cleanoldfiles() #logging.info("3") outputfilename = datetime.now().strftime(videoprefix + '%Y%m%d-%H%M%S') playsound("video") logging.info( f"V+ Start Recording Video : {VIDEOPATH}/{outputfilename}.h264") camera.start_recording(VIDEOPATH + "/" + outputfilename + '.h264', format='h264', quality=QUALITY) time.sleep(2) while (testBit(trigger_flag, 0) != 0) and (int( time.time() / (VIDEOINTERVAL * 60)) <= filetime): #logging.info("4") if (TIMESTAMP == 'true'): camera.annotate_text = dt.datetime.now().strftime( '%Y-%m-%d %H:%M:%S') if (TAKESNAPSHOT == 'true'): # Take a snapshot jpg every {SNAPSHOTINTERVAL} seconds if (int( (time.time() + 5) / SNAPSHOTINTERVAL) > timelapsedelta): logging.info( f"I Take Snapshot Image : {IMAGEPATH + '/' + datetime.now().strftime(videoprefix + '%Y%m%d-%H%M%S') + '.jpg'}" ) playsound("image") camera.capture(IMAGEPATH + "/" + datetime.now().strftime(videoprefix + '%Y%m%d-%H%M%S') + '.jpg') timelapsedelta = (int( (time.time() + 5) / SNAPSHOTINTERVAL)) EVENTTIME = int(time.time()) time.sleep(1) camera.stop_recording() logging.info( f"V- Stop Recording Video : {VIDEOPATH}/{outputfilename}.h264") if (MEDIAFORMAT == "mp4" or MEDIAFORMAT == "both"): convert_thread = threading.Thread(target=converttomp4, args=(outputfilename, ), name='convert_thread', daemon=True) convert_thread.start() logging.debug(f"# CONVERTTHREAD {convert_thread}") #logging.info("5") camera.close() process_flag = clearBit(process_flag, 0) #logging.info("6") time.sleep(1)
if camera_expmode == "auto": camera.exposure_mode = 'nightpreview' camera_expmode = "night" else: camera.exposure_mode = 'auto' camera_expmode = "auto" updateStatus() if data == "Record": if free <= 128: camera.annotate_text = 'Recording not possible - Storage device is full.' else: if camera_recording == 0: if loop_recording == 0: camera.annotate_background = picamera.Color('black') camera.annotate_text = "RPi-Dashcam - " + dt.datetime.now( ).strftime('%d-%m-%Y %H:%M:%S') camera.start_recording( recordpath + 'RPIDC_' + dt.datetime.now().strftime('%d%m%Y') + '_' + dt.datetime.now().strftime('%H%M%S') + '.h264') camera_recording = 1 updateStatus() else: camera.annotate_background = picamera.Color('black') camera.annotate_text = "RPi-Dashcam - " + dt.datetime.now( ).strftime('%d-%m-%Y %H:%M:%S') camera.start_recording( recordpath + 'RPIDC_' + dt.datetime.now().strftime('%d%m%Y') + '.h264')
iss.compute() obs = ephem.Observer() obs.lat = iss.sublat obs.long = iss.sublong obs.elevation = 0 sun.compute(obs) sun_angle = math.degrees(sun.alt) day_night = "Day" if sun_angle > twilight else "Night" date = time.strftime("%H-%M-%S") cam.annotate_text_size = 120 cam.annotate_foreground = Color("White") cam.annotate_background = Color("Black") cam.annotate_text = "Lat: %s - Long: %s - %s" % (iss.sublat, iss.sublong, day_night) if start >= 54: cam.capture(date + ".jpg") print(date + ".jpg") print(start) if real_temp < 26.7 or real_temp > 18.3 or real_humidity < 70 or real_humidity > 40: sense.set_pixels(happy_face) if real_temp > 26.7 or real_temp < 18.3 or real_humidity > 70 or real_humidity < 40: sense.set_pixels(sad_face)
from picamera import PiCamera, Color from time import sleep import datetime camera = PiCamera() camera.brightness = 50 camera.resolution = (720, 480) #camera.image_effect = 'watercolor' camera.image_effect = 'colorbalance' camera.exposure_mode = 'auto' camera.awb_mode = 'auto' camera.rotation = 180 camera.annotate_background = Color('green') camera.annotate_foreground = Color('white') camera.annotate_text_size = 32 text = "Grace's GardenPi " + datetime.datetime.now().strftime("%x,%X") pictureName = "/home/pi/Desktop/gardenpi_files/pictures/Picture_" + datetime.datetime.now( ).strftime("%m-%d-%y_%X") + ".jpg" f = open("/home/pi/Desktop/gardenpi_files/picturelist.csv", "a") f.write("Picture_" + datetime.datetime.now().strftime("%m-%d-%y_%X") + ".jpg\n") f.close() camera.annotate_text = text camera.capture(pictureName) #camera.start_recording('/home/pi/Desktop/gardenpi_files/pictures/video.h264') #sleep(5) #camera.stop_recording()
# initialize the camera and grab a reference to the raw camera capture camera = PiCamera() camera.resolution = (720, 480) camera.framerate = 30 idxs = [0, 0, 0] print("Thu bam nut") while True: # Neu button dang nhan if Button.isPressed(): print("Nut dang duoc bam") rawCapture = PiRGBArray(camera, size=(720, 480)) camera.start_preview() camera.annotate_background = Color("blue") camera.start_recording(video_output_file) i = 0 for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): print(i) if (i % 15 == 0): test_image = rawCapture.array test_image2 = test_image test_image = cv2.cvtColor(test_image, cv2.COLOR_BGR2GRAY) print("Xu ly anh") #test_image = cv2.imread('left.jpg', 0); #print(test_image.shape) #print(test_image.size)
from picamera import PiCamera, Color from datetime import datetime from time import sleep try: camera = PiCamera() #создаем экземпляр camera.annotate_background = Color("teal") camera.annotate_foreground = Color("lightpink") #for exposure in range(3): camera.annotate_text = datetime.now().strftime('%Y-%m-%d %H:%M:%S') camera.annotate_text_size = 55 #camera.exposure_mode="backlight" #camera.awb_mode='sunlight' #camera.rotation=180 #camera.annotate_text="Exp: %s" % exposure #camera.capture( '/root/Pictures/Example1/PhotoInNight.jpg') camera.capture('/root/Pictures/Example1/PhotoInDay.jpg') #camera.capture( '/root/Pictures/Example1/pic0%s.jpg' %exposure) #sleep(2) finally: camera.close() print("End of program")
camera.preview_fullscreen = True # True False camera.iso = 0 # 0(auto) 1600 camera.exposure_mode = "auto" # off auto night nightpreview backlight spotlight sports snow beach verylong fixedfps antishake fireworks camera.awb_mode = "auto" # off auto sunlight cloudy shade tungsten fluorescent incandescent flash horizon #camera.awb_gains = 4.0, 4.0 # 0.0 8.0 camera.meter_mode = "matrix" # average spot backlit matrix camera.saturation = 30 # -100 +100 camera.video_stabilization = False # True False camera.image_effect = "none" #none, negative, solarize, sketch, denoise,emboss, oilpaint, hatch, gpen, pastell, watercolor, film, blur, saturation, colorswap, washedout, posterise, colorpoint, cartoon, deinterlace1, deinterlace2 #camera.color_effects = 128, 128 #schwarz-weiss, Werte gehen von 0-255 camera.drc_strength = "low" # off low medium high camera.image_denoise = True # True False camera.video_denoise = True # True False #camera.analog_gain = 1.0 # Fraction #camera.digital_gain = 0.8 # Fraction camera.annotate_background = Color("white") camera.annotate_foreground = Color("black") camera.annotate_text = "" # max 255 characters if not os.path.exists("pictures"): print("erstelle Picture-Directory") os.system("mkdir pictures") time.sleep(3) if not exists("tarpi.param.db"): print("erzeuge Datenbank") param = shelve.open("tarpi.param") param["camera.contrast"] = "36" # -100 +100 param["camera.brightness"] = "50" # 0 100 param["camera.annotate_text_size"] = "16" # 6 160 param["camera.exposure_compensation"] = "0" # -25 +25
# Improvement idea: make a popup that asks for resolution, # or gives options for res to choose from. camera.resolution = (1024, 768) # Improvement ides: # 1) Make selecatable or adjustable image rotation. # 2) Put the rotation selection on a rotary encoder, # or make button presses cycle through rotations camera.rotation = 180 # Show preview, with slight transparency (range 0-255) camera.start_preview(alpha=175) # I thought color of text is foreground, but nope. # For a background color, do _background camera.annotate_background = Color('red') # Size of text, ange of 6 to 160 camera.annotate_text_size = 40 # Display text on image # I want a GUI, so I can have the text typed in. # How do I do # image_text = input("Enter the text that you want printed on the picture") # camera.annotate_text = ' image_text ' # Text annotation on the image #camera.annotate_text = ' Text goes here!!! :) ' # Image effects: negative, solarize, *sketch, denoise, *emboss, oilpaint, hatch # gpen, *pastel, *watercolor, film, blur, saturation, colorswap, washedout,
from picamera import PiCamera, Color #get these obects in here from time import sleep #and this one camera = PiCamera() #make a camera object called 'camera' num = 0 #this is a counter num2 = 0 #this too effectsList = ['sketch', 'posterise', 'gpen', 'cartoon', 'negative', 'solarize', 'pastel', 'none', 'denoise', 'emboss', 'oilpaint', 'hatch', 'watercolor', 'film', 'blur', 'saturation', 'colorswap', 'washedout', 'colorpoint', 'colorbalance', 'deinterlace1', 'deinterlace2'] #this long boi contains all the effects we're gonna rotate through while(num < 22): #do this 22 times (we used a while loop because for loops are really gross in Python) camera.start_preview() #open the camera window camera.image_effect = effectsList[num] #set the effect to element 'num' of the effects list (first time is 'sketch', then 'posterise', etc.) camera.annotate_text_size = 55 #set text size camera.annotate_background = Color('Blue') #set background color camera.annotate_text = "This is effect " + effectsList[num] #write some text that says what affect we're using sleep(5) #pause for 5 seconds if(num2 < 5): #for the first 5 iterations, camera.capture('/home/pi/Desktop/' + effectsList[num] + '.jpg') #take a photo at this location with filename of effect type num2 = num2 + 1 #increment this counter num = num + 1 #increment this counter camera.stop_preview() #close the camera window
from picamera import PiCamera, Color from time import sleep camera = PiCamera() camera.resolution = (1920,1080) camera.framerate = 30 camera.start_preview() camera.awb_mode = 'fluorescent' camera.exposure_mode = 'auto' camera.annotate_text = "1920x1080 30fr auto exposure awb-flourescent" camera.annotate_text_size = 50 camera.annotate_background = Color('black') camera.annotate_foreground = Color('white') camera.start_recording('/home/pi/darren.h264') sleep(10) #camera.capture('/home/pi/Desktop/fools.jpg') camera.stop_recording() camera.stop_preview()
from picamera import PiCamera, Color from time import sleep camera = PiCamera() camera.resolution = (1920, 1080) # Resolucion maxima para la grabacion de video es 1920 x 1080. camera.framerate = 15 # Para lograr la resolucion maxima se debe configurar los cuadros por segundo en "15". camera.rotation = 0 # Rotar la imagen en 0, 90, 180 o 270 grados camera.start_preview() # Dentro del parentesis se puede escribir (alpha=200) lo que permite generar transparencia en la preview. Pero no en el video. camera.exposure_mode = 'auto' # Exposicion de la fotografia. Por defecto es "auto". Opciones (off, auto, night, nightpreview, backlight, spotlight, sports, snow, beach, verylong, fixedfps, antishake, fireworks) camera.awb_mode = 'auto' # Balance de blacos. Por defecto es "auto". Opciones (off, auto, sunlight, cloudy, shade, tungsten, fluorescent, incandescent, flash, horizon) camera.image_effect = 'none' # Opciones de efectos en la fotografia (none, negative, solarize, sketch, denoise, emboss, oilpaint, hatch, gpen, pastel, watercolor, film, blur, saturation, colorswap, washedout, posterise, colorpoint, colorbalance, cartoon, deinterlace1, deinterlace2) camera.annotate_background = Color('white') # Color del background del texto camera.annotate_foreground = Color('black') # Color de las letras del texto camera.annotate_text = "Escuela Las Cruces" # Texto que llevara el video camera.annotate_text_size = 70 # Va de 6 a 160. Por defecto es 32. camera.brightness = 50 # Brillo de la fotografia (Por defecto es 50%). Va de 0 a 100. camera.contrast = 50 # Constraste de la fotografia (Por defecto es 50%). Va de 0 a 100. camera.start_recording('/home/pi/video.h264') # Direccion donde se guardara el video, se debe cambiar el nombre de cada archivo. sleep(10) # Tiempo(en segundos) de grabacion camera.stop_recording() camera.stop_preview() # Para observar el video se debe abrir la Terminal e igresar el siguiente codigo # omxplayer video.h264 y se da ENTER. El nombre del video dependera del nombre "video.h264" que le hayamos dado al archivo.
print photo_disp_ratio print photo_disp_size print photo_disp_offset This makes: (752, 448) (1640, 1232) 1.33116883117 (564, 448) (94, 0) ''' #pi camera stuff camera = PiCamera() camera.rotation = 90 camera.annotate_background = Color('black') camera.resolution = (1640, 1232) #timing image overlays. This is the 54321 that shows up before a snap timing = [] for i in range(5): img = Image.open('images/%d.png' % (i + 1)) pad = Image.new('RGB', ( ((img.size[0] + 31) // 32) * 32, ((img.size[1] + 15) // 16) * 16, )) pad.paste(img, (0, 0)) o = camera.add_overlay(pad.tostring(), size=img.size) o.alpha = 0