我需要使用函数返回的结果设置使用SimpleCV拍摄的照片的分辨率,这将是以下代码:
def resolutionselection():
print"""
Ahora tenemos que escoger el formato y resolución de las fotos:
1 - 10x15.
2 - 15x20.
"""
answer = raw_input("→")
if answer == "1":
print("Has seleccionado hacer las fotos en 10x15.\n")
resolution = ['2304', '1536']
return resolution
elif answer == "2":
print("Has seleccionado hacer las fotos en 15x20.\n")
resolution = ['2048', '1536']
return resolution
else:
print("No estamos colaborando...")
exit(0)
px = resolutionselection()
cam = Camera(prop_set={'width':px[0], 'height':px[1]})
但它给了我一个错误:
^{pr2}$编辑: 我发布了完整的代码,以澄清: #--编码:utf-8--
import time
from SimpleCV import Camera
import RPi.GPIO as GPIO
from sys import exit
sequence = 001 # Starts the sequence number for the photos.
event_name = "Event" # Indicates the name of the event, used in the filename of the photos.
kiosk = "./" # Without choosing, same folder as the program.
cam = Camera(prop_set={'width':2304, 'height':1536}) # Initializes the camera with HR 3:2 format.
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def kioskselection():
print"""
Primero, tenemos que escoger el Kiosco que va a imprimir:
1 - Kodak Wedding.
2 - Kodak Voyage.
"""
answer = raw_input("→\t")
if answer == "1":
print("Has seleccionado Kodak Wedding.\n")
kiosk = "/media/kodakwedding/"
return kiosk
elif answer == "2":
print("Has seleccionado Kodak Voyage. \n")
kiosk = "/media/kodakvoyage/"
return kiosk
else:
print("No estamos colaborando...")
exit(0)
def resolutionselection():
print"""
Ahora tenemos que escoger el formato y resolución de las fotos:
1 - 10x15.
2 - 15x20.
"""
answer = raw_input("→\t")
if answer == "1":
print("Has seleccionado hacer las fotos en 10x15.\n")
resolution = [2304, 1536]
print(resolution)
return resolution
elif answer == "2":
print("Has seleccionado hacer las fotos en 15x20.\n")
resolution = [2048, 1536]
return resolution
print(resolution)
else:
print("No estamos colaborando...")
exit(0)
kiosk = kioskselection()
px = resolutionselection()
cam = Camera(prop_set={'width':px[0], 'height':px[1]})
print("PUSH DA BUTTON!")
while True:
input_state = GPIO.input(17)
if input_state == False:
img = cam.getImage()
img.save("%s%s - %d.jpg" % (kiosk, event_name, sequence))
time.sleep(1)
print("Foto '%s - %d.jpg', guardada." % (event_name, sequence))
sequence += 1
目前没有回答
相关问题 更多 >
编程相关推荐