コード例 #1
0
ファイル: Concept.py プロジェクト: R3zk0n/Infosec
import time
from time import sleep

print '''PUT ASCII ART HERE BECAUSE ASCII!!!
         '''
User = raw_input("Please select a function to test: \n")

if User == 1:
    Led()
if User == 2:
    loop()
if User == 3:
    servo()


board = Arduino()
sensor = Sensor(board, "A0")

def loop():
    value = sensor.value or 1
    value = value / 2

    print value

    sensor.on()



def servo():
servo.set_position(180)
sleep(2)
コード例 #2
0
ファイル: servo.py プロジェクト: imtvm/PyOpenCV
from BreakfastSerial import Arduino
from components import *
from time import sleep

board = Arduino('/dev/cu.usbmodem1421')
s = Servo(board, 9)
s.reset()

while True:
    cmd = input("command: ")

    if cmd != "q":
        s.set_position(cmd)
    else:
        s.reset()
        break
コード例 #3
0
#this one is made for servos

import cv2
from BreakfastSerial import Arduino
from components import *

face_cas = cv2.CascadeClassifier(
    'cascades/data/haarcascade_frontalface_alt2.xml'
)  #the file you need to recoginze faces can be swapped out for the other ones in the data file

board = Arduino("/dev/cu.usbmodem1421")

cap = cv2.VideoCapture(0)  #Sets the video input to the main webcam

MIN_X, MAX_X, MIN_Y, MAX_Y = 150, 400, 50, 225

#telling the user where to move to be in the optimal placement on the screen, or if servos were involved then where to move the servo so that the face is in the middle


def check_location(
    x, y, w, h
):  #needs to be fixed because when the subject is very close to the camera, all points will be outside the min and max values
    left_x = x
    right_x = x + w
    top_y = y
    bottom_y = y + h

    if left_x < MIN_X:
        print("move left")
        while (left_x < MIN_X):
            break
import tensorflow as tf
import tflearn
from BreakfastSerial import Arduino, Servo
from time import sleep
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
import numpy as np
from PIL import Image
import cv2
import imutils

# global variables
bg = None
board = Arduino("/dev/ttyACM0")
servol = Servo(board, "8")
servor = Servo(board, "9")
servom = Servo(board, "10")
servoi = Servo(board, "11")
servot = Servo(board, "12")


def resizeImage(imageName):
    basewidth = 100
    img = Image.open(imageName)
    wpercent = (basewidth / float(img.size[0]))
    hsize = int((float(img.size[1]) * float(wpercent)))
    img = img.resize((basewidth, hsize), Image.ANTIALIAS)
    img.save(imageName)