Beispiel #1
0
def dwn(z):
    pantilthat.servo_two(z)
    return
Beispiel #2
0
def yep(z):
    if z >= 0:
        pantilthat.servo_two(-90)
        sleep(.15)
        pantilthat.servo_two(90)
        sleep(.15)
        pantilthat.servo_two(-90)
        sleep(.15)
        pantilthat.servo_two(90)
        sleep(.15)
        pantilthat.servo_two(0)
    else:
        pantilthat.servo_two(90)
        sleep(.15)
        pantilthat.servo_two(-90)
        sleep(.15)
        pantilthat.servo_two(90)
        sleep(.15)
        pantilthat.servo_two(-90)
        sleep(.15)
        pantilthat.servo_two(x)
        return
Beispiel #3
0
def up(z):
    pantilthat.servo_two(z)
    return
Beispiel #4
0
sleep(2)

#Main Program Loop
x,z,i=0,0,0
pantilthat.servo_one(x)
pantilthat.servo_one(z)
while c != ord('q'):
	c=stdscr.getch()
	if c == ord('d') and x <= 90:
		pantilthat.servo_one(x)
		x=x+1
	if c == ord('a') and x >= -90:
		pantilthat.servo_one(x)
		x=x-1
	if c == ord('s') and z <=90:
		pantilthat.servo_two(z)
		z=z+1
	if c == ord('w') and z >= -90:
		pantilthat.servo_two(z)
		z=z-1
	if c == ord(' '):
		name='image'+`random.randrange(1,1000)`+'.jpg'
		camera.capture(name)
	if c == ord('v'):
		name='video'+`random.randrange(1,1000)`+'.h264'
		camera.start_recording(name)
		sleep(5)
		camera.stop_recording
#	if c == ord('t'):
#		if y >= 0:
#			pantilthat.servo_two(-90)
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)
Beispiel #6
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)
        
        

        

Beispiel #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)
        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)
im_thread.start()