コード例 #1
0
def rgt(x):
    pantilthat.servo_one(x)
    return
コード例 #2
0
    return


def up(z):
    pantilthat.servo_two(z)
    return


def dwn(z):
    pantilthat.servo_two(z)
    return


#Main Program Loop
x, z, i = 0, 0, 5
pantilthat.servo_one(x)
pantilthat.servo_one(z)
while c != ord('q'):
    c = stdscr.getch()
    if c == ord('a') and x <= 90:
        for i in range(3):
            a = threading.Thread(target=lft, args=(x, ))
            a.setDaemon(True)
            a.start()
        x = x + 1

    if c == ord('d') and x >= -90:
        for i in range(3):
            a = threading.Thread(target=rgt, args=(x, ))
            a.setDaemon(True)
            a.start()
コード例 #3
0
def nope(x):
    if x >= 0:
        pantilthat.servo_one(-90)
        sleep(.15)
        pantilthat.servo_one(90)
        sleep(.15)
        pantilthat.servo_one(-90)
        sleep(.15)
        pantilthat.servo_one(90)
        sleep(.15)
        pantilthat.servo_one(0)
    else:
        pantilthat.servo_one(90)
        sleep(.15)
        pantilthat.servo_one(-90)
        sleep(.15)
        pantilthat.servo_one(90)
        sleep(.15)
        pantilthat.servo_one(-90)
        sleep(.15)
        pantilthat.servo_one(x)
        return
コード例 #4
0
import cv2
import numpy as np
import pantilthat

cap = cv2.VideoCapture(0)
pantilthat.servo_enable(1, True)
pantilthat.servo_enable(2, True)

pantilthat.servo_one(0)
pantilthat.servo_two(0)

while True:
    _, frame = cap.read()
    hsv_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

    # red color
    low_red = np.array([161, 155, 84])
    high_red = np.array([179, 255, 255])
    red_mask = cv2.inRange(hsv_frame, low_red, high_red)

    ##Detect biggest red object
    contours, _ = cv2.findContours(red_mask, cv2.RETR_TREE,
                                   cv2.CHAIN_APPROX_SIMPLE)
    contours = sorted(contours, key=lambda x: cv2.contourArea(x), reverse=True)

    #draw rectangle on biggest contour
    for cnt in contours:
        (x, y, w, h) = cv2.boundingRect(cnt)

        cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
コード例 #5
0
import pantilthat
import time
import math


while True:
    # Set the maximum high pulse for a servo in microseconds.
    # pantilthat.servo_pulse_max(index, 100)
    # set position of servo one in degrees
    pantilthat.servo_one(-20)
    # set position of servo two in degrees
    pantilthat.servo_two(0)
    # get position of servo one
    #pantilthat.get_pan()

    hori = list(range(-20,20))
    vert = list(range(0,-60,-5))

    for j in vert:
        pantilthat.tilt(j)
        for i in hori:
            pantilthat.pan(i)
            time.sleep(0.01)
        
        

        

コード例 #6
0
ファイル: aff.py プロジェクト: UTAGNATI/PST_VRWATCH
import pantilthat
import math

while True:

    pantilthat.servo_one(0)
    pantilthat.servo_two(0)
コード例 #7
0
import pantilthat
import time
import math

# Set the maximum high pulse for a servo in microseconds.
# pantilthat.servo_pulse_max(index, 100)
# set position of servo one in degrees
pantilthat.servo_one(-90)
# set position of servo two in degrees
pantilthat.servo_two(-10)
# get position of servo one
pantilthat.get_pan()

# -----
a = 0
stop = 0
while True:
    # Get the time in seconds
    t = time.time()

    # G enerate an angle using a sine wave (-1 to 1) multiplied by 90 (-90 to 90)
    a = math.sin(t * 2) * 90

    # Cast a to int for v0.0.2
    a = int(a)

    pantilthat.pan(a)
    pantilthat.tilt(0)

    # Two decimal places is quite enough!
    print(a, t)
コード例 #8
0
        self.stop_event.set()
        self.join()

    def stop_camera(self):
        self.pi_camera.close()


c_thread = Camerathread()
c_thread.start()
pantilthat.servo_enable(1, True)
pantilthat.servo_enable(2, True)

v_angle = 0
p_angle = 0

pantilthat.servo_one(v_angle)
pantilthat.servo_two(p_angle)

sk_command = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sk_camera = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sk_command.sendto("Hello", ip_port_1)
time.sleep(1)
sk_camera.sendto("Hello", ip_port_2)
time.sleep(1)
#sk_command.connect(ip_port_1)
#sk_camera.connect(ip_port_2)
comm_thread = CommandRecvthread(comm_socket=sk_command)
comm_thread.start()
input_thread = InputThread()
input_thread.start()
im_thread = Imagesendthread(sk_camera)