Exemplo n.º 1
0
 def init(self):
     if config[botname]["type"] == "dev":
         self.dev = serial.Serial(config[botname]["arduinoDev"], config[botname]["arduinoDevSpeed"])
     elif config[botname]["type"] == "file":
         self.f = open(config[botname]["file"], "w")
     elif config[botname]["type"] == "spi":
         spi.initialize(0, 32, 250000, 0)
     elif config[botname]["type"] == "socket":
         self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         self.socket.connect((config[botname]["socketIP"], config[botname]["socketPort"]))
Exemplo n.º 2
0
import spi
import cv2
import sys

spi.initialize()

cascPath = sys.argv[1]
faceCascade = cv2.CascadeClassifier(cascPath)

video_capture = cv2.VideoCapture(0)

faceHeight = 200

while True:
    # Capture frame-by-frame
    ret, frame = video_capture.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    faces = faceCascade.detectMultiScale(
        gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE
    )

    captureHeight = cap.get(4)

    # Draw a rectangle around the faces
    for (x, y, w, h) in faces:
        distance = (faceHeight * captureHeight) / h
        # pos = Vector(x + w/2, y + h/2, distance)
        spi.transfer((x + w / 2, y + h / 2, distance))
        cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
Exemplo n.º 3
0
import sys
import spi

spi.initialize(0,32,250000,0)
str=sys.argv[1]
crc = 0
for b in sys.argv[1]:
	crc += ord(b)
crc &= 0xFF
print("CRC:",crc)
list_c = tuple(map(ord,list(str))+[crc,10])
print list_c
spi.transfer(list_c)
spi.end()
Exemplo n.º 4
0
import spi
import time

#initialize(mode, bitspermessage, speed, delay)

spi.initialize(0, 1, 500000, 0)
a = spi.transfer((192,))
print a