Hallo,
nun eine Funktion des Bots mit Kamera: "Spionage-PiBot"
Zuerst ein Code, mit dem der Bot via Tastatur ferngesteuert werden kann:
Code:
#These are the keyboard mappings
#z = Go forward
#q = Stop going forward or back
#b = Go back
#g= Go left
#h = Go right
#Get the GPIO module
import RPi.GPIO as GPIO
#Get the time module
import time
#A routine to control a pair of pins
def ControlAPairOfPins(FirstPin,FirstState,SecondPin,SecondState):
print "Controlling them pins"
if FirstState == "1":
GPIO.output(int(FirstPin),True)
else:
GPIO.output(int(FirstPin),False)
if SecondState == "1":
GPIO.output(int(SecondPin),True)
else:
GPIO.output(int(SecondPin),False)
#Just retur
return
####Main body of code
#Get rid of warnings
GPIO.setwarnings(False)
#Set the GPIO mode
GPIO.setmode(GPIO.BOARD)
#Set the pins to be outputs
GPIO.setup(19,GPIO.OUT)
GPIO.setup(21,GPIO.OUT)
GPIO.setup(23,GPIO.OUT)
GPIO.setup(24,GPIO.OUT)
while True:
MyChar = raw_input("Press a character:")
print "You pressed: " + MyChar
if MyChar == "z":
ControlAPairOfPins("19","1","21","0")
ControlAPairOfPins("23","0","24","1")
print "Forward"
elif MyChar == "q":
ControlAPairOfPins("19","0","21","0")
ControlAPairOfPins("23","0","24","0")
print "Stop"
elif MyChar == "b":
ControlAPairOfPins("19","0","21","1")
ControlAPairOfPins("23","1","24","0")
print ("Back")
elif MyChar == "g":
ControlAPairOfPins("19","0","21","1")
ControlAPairOfPins("23","0","24","1")
print "Left"
elif MyChar == "h":
ControlAPairOfPins("19","1","21","0")
ControlAPairOfPins("23","1","24","0")
print "Right"
else:
print "Not a command"
Dann die Kamera einschalten:
Code:
raspivid -o - -t 999999 -hf -w 640 -h 360 -fps 25|cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264
Und mittels VLC spionieren
http://raspi.tv/2013/how-to-stream-v...blet-using-vlc
Viel Spass!
Lesezeichen