• Benvenuti su RaspberryItaly!
Benvenuto ospite! Login Login con Facebook Registrati Login with Facebook


Valutazione discussione:
  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5

[-]
Tags
come in 6 asa velocita fare modulo foto di 800 con una pithon secondi camera e

Modulo camera. Come fare una foto con velocita di 6 secondi e asa 800 in pithon!!!
#1
Salve! Sono un designer e utilizzo una rspberry pi 3 in un proggetto e un modulo fotocamera. Capisco un può di HTML e PHP ma non di Pithon, e vorrei che qualcuno mi aiutasse a risolvere un problema, che sembra abastanza semplice. Devo scatare un afoto (utilizzo in pulsante, quindi GPO 16 pecisamente), e ho provato con questo script che ho trovato in rete ma cè qualcosa (o forse tante cose) che non va, perche mi ritorna un errore e non completa l'operazione.

Ecco lo script che funziona (ma non ho aggiunto che voglio una sposizione di 6 secondi a iso 800):

#!/usr/bin/env python

from time import sleep
import os
import RPi.GPIO as GPIO
import subprocess
import datetime
import pygame
from pygame.locals import *


#setup pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(16,GPIO.IN)

#setup variables
count = 0
up = False
down = False
command = ""
filename = ""
#camera_pause  = "650"
camera_pause  = "1000"

print("Raspberry Pi - Point & Shoot Camera v2.2")
print("-with pygame and screen, and messaging")



running = True;


pygame.init()
screen = pygame.display.set_mode((320,240))
#screen = pygame.display.set_mode((0,0),pygame.FULLSCREEN)

width, height = screen.get_size()

background = pygame.image.load("/home/pi/camera/homeimage.jpeg");
background.convert_alpha()
background = pygame.transform.scale(background,(width,height))



screen.blit(background,(0,0),(0,0,width,height))

#logo = pygame.image.load("rpilogo.jpeg");
logo = pygame.image.load("/home/pi/camera/raspberrypilogo.png")

logo = pygame.transform.scale(logo,(150,200))

screen.blit(logo,(20,0))


font = pygame.font.SysFont("arial", 65, bold=1)

font2 = pygame.font.SysFont("arial", 55, bold=0)
textsurface = font.render("Raspberry Pi", 1, pygame.Color(255,255,255))
screen.blit(textsurface,(20,280))
textsurface = font2.render("Point & Shoot Camera", 1, pygame.Color(255,255,255))
screen.blit(textsurface,(20,350))



def takepic(imageName):
   writemessage("taking photo...")
   command = "sudo raspistill -o " + imageName + " -q 100 -rot 160 -t " + camera_pause
   print(command)

   os.system(command)
   writemessage("loading photo...")

def loadpic(imageName):
   print("loading image: " + imageName)
   
   background = pygame.image.load(imageName);
   background.convert_alpha()
   background = pygame.transform.scale(background,(width,height))
   screen.blit(background,(0,0),(0,0,width,height))

   font = pygame.font.SysFont("arial", 40, bold=0)
   textsurface = font.render(imageName, 1, pygame.Color(0,0,0))
   screen.blit(textsurface,(20,0))

   logo = pygame.image.load("/home/pi/camera/raspberrypilogo.png")
   logo = pygame.transform.scale(logo,(75,100))
   screen.blit(logo,(20,300))
   

def movepic(imageName):
   command = "sudo mv " + imageName + " /home/pi/camera/images/" + imageName
   print(command)
   os.system(command)

   
def writemessage(message):
   screen.fill(pygame.Color(0,0,0))
   #screen.blit(background,(0,0),(0,0,width,height))
   font = pygame.font.SysFont("arial", 50, bold=1)
   textsurface = font.render(message, 1, pygame.Color(255,255,255))
   screen.blit(textsurface,(35,40))
   pygame.display.update()


   
while running:
   if(up == True):
       if(GPIO.input(16)==False):
           print("button 16 pressed")
           now = datetime.datetime.now()
           timeString = now.strftime("%Y-%m-%d_%H:%M:%S")
           print("request received: " + timeString)
           filename = "photo-" + timeString + ".jpg"
           takepic(filename)
           loadpic(filename)
           movepic(filename)
           
   up = GPIO.input(16)
   count = count + 1
   
   pygame.display.update()
   sleep(.1)

   for event in pygame.event.get():
       if event.type == pygame.KEYDOWN:
           running = False
           

   
   
#never hit
print("end of loop");


   
   
E questo invece è lo stesso ma ho cercato di inserire il tempo di sposizione:


#!/usr/bin/env python
from picamera import PiCamera
from time import sleep
from fractions import Fraction
import os
import RPi.GPIO as GPIO
import subprocess
import datetime
import pygame
from pygame.locals import *


#setup pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(16,GPIO.IN)

#setup variables
count = 0
up = False
down = False
command = ""
filename = ""
#camera_pause  = "650"
camera = PiCamera(resolution=(1280, 720), framerate=Fraction(1, 6))
camera.shutter_speed = 6000000
camera.iso = 800
sleep(30)
camera.exposure_mode = 'off'
camera_pause  = "500"

print("Raspberry Pi - Point & Shoot Camera v2.2")
print("-with pygame and screen, and messaging")


running = True;


pygame.init()
screen = pygame.display.set_mode((320,240))
#screen = pygame.display.set_mode((0,0),pygame.FULLSCREEN)

width, height = screen.get_size()

background = pygame.image.load("/home/pi/camera/homeimage.jpeg");
background.convert_alpha()
background = pygame.transform.scale(background,(width,height))



screen.blit(background,(0,0),(0,0,width,height))

#logo = pygame.image.load("rpilogo.jpeg");
#logo = pygame.image.load("/home/pi/camera/raspberrypilogo.png")

#logo = pygame.transform.scale(logo,(150,200))

screen.blit(logo,(20,0))


font = pygame.font.SysFont("arial", 65, bold=1)

font2 = pygame.font.SysFont("arial", 55, bold=0)
textsurface = font.render("Raspberry Pi", 1, pygame.Color(255,255,255))
screen.blit(textsurface,(20,280))
textsurface = font2.render("Point & Shoot Camera", 1, pygame.Color(255,255,255))
screen.blit(textsurface,(20,350))



def takepic(imageName):
   writemessage("taking photo...")
   command = "sudo raspistill -o " + imageName + " -q 100 -rot 160 -t " + camera_pause
   print(command)

   os.system(command)
   writemessage("loading photo...")

def loadpic(imageName):
   print("loading image: " + imageName)
   
   background = pygame.image.load(imageName);
   background.convert_alpha()
   background = pygame.transform.scale(background,(width,height))
   screen.blit(background,(0,0),(0,0,width,height))

   font = pygame.font.SysFont("arial", 40, bold=0)
   textsurface = font.render(imageName, 1, pygame.Color(0,0,0))
   screen.blit(textsurface,(20,0))

   logo = pygame.image.load("/home/pi/camera/raspberrypilogo.png")
   logo = pygame.transform.scale(logo,(75,100))
   screen.blit(logo,(20,300))
   

def movepic(imageName):
   command = "sudo mv " + imageName + " /home/pi/camera/images/" + imageName
   print(command)
   os.system(command)

   
def writemessage(message):
   screen.fill(pygame.Color(0,0,0))
   #screen.blit(background,(0,0),(0,0,width,height))
   font = pygame.font.SysFont("arial", 50, bold=1)
   textsurface = font.render(message, 1, pygame.Color(255,255,255))
   screen.blit(textsurface,(35,40))
   pygame.display.update()


   
while running:
   if(up == True):
       if(GPIO.input(16)==False):
           print("button 16 pressed")
           now = datetime.datetime.now()
           timeString = now.strftime("%Y-%m-%d_%H:%M:%S")
           print("request received: " + timeString)
           filename = "photo-" + timeString + ".jpg"
           takepic(filename)
           loadpic(filename)
           movepic(filename)
           
   up = GPIO.input(16)
   count = count + 1
   
   pygame.display.update()
   sleep(.1)

   for event in pygame.event.get():
       if event.type == pygame.KEYDOWN:
           running = False
           

   
   
#never hit
print("end of loop");
   


Qualcuno mi può dare una mano??? Grazie!!! Big Grin
Risposta
  


Vai al forum:


Navigazione:
Forum con nuovi Post
Forum senza nuovi post
Forum bloccato
Forum Redirect