예제 #1
0
 def __init__(self):
     Vilib.camera_start(True)
     self.sensitivity = sensitivity
     self.capture = cv2.VideoCapture(0)
예제 #2
0
 def __init__(self):
     # start camera and opencv
     Vilib.camera_start(True)
     self.cap = cv2.VideoCapture(0)
     self.video_read()
예제 #3
0
# cam_Servo_x = Servo(PWM("P1"))
# cam_Servo_y = Servo(PWM("P2"))

# cam_Servo_x.angle(0)
# cam_Servo_y.angle(0)
# dir_Servo.angle(0)

# cam_coor_x = 0
# cam_coor_y = 0
# car_dir_angle = 0

Vilib.cdf_flag = True
Vilib.hdf_flag = True
Vilib.color_change('blue')
# car_start()
Vilib.camera_start()

# def motion_control(coor):
#     global cam_coor_x,cam_coor_y,car_dir_angle
#     time_delay = 0.03
#     stop_width_list =[25,20]

#     sub_list = np.array([0,0])
#     add_list = np.array([0,0])
#     center_coor = np.array([160,120])

#     add_list = center_coor + stop_width_list
#     sub_list = center_coor - stop_width_list

#     if coor[0] > add_list[0]:
#         cam_coor_x +=2
예제 #4
0
#!/usr/bin/python3
import json
import sys
sys.path.append(r'/opt/ezblock')
from ezblock import __reset_mcu__
import time
__reset_mcu__()
time.sleep(0.01)
from vilib import Vilib
from ezblock import WiFi

with open('config.json', 'r') as configuration:
    data = configuration.read()

obj = json.loads(data)

Vilib.camera_start(True)
Vilib.color_detect_switch(True)
Vilib.detect_color_name('red')
WiFi().write(str(obj['country']), str(obj['ssid']), str(obj['key']))


def forever():
    pass


if __name__ == "__main__":
    while True:
        forever()
예제 #5
0
        self.pi.set_PWM_dutycycle(self.pin, duty)

    def get_angle(self):
        return self.angle

    # will be called automatically when the object is deleted
    # def __del__(self):
    #     pass

    def map(self, x, in_min, in_max, out_min, out_max):
        return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min


if __name__ == '__main__':
    from vilib import Vilib
    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)

    pan = Servo(pin=13, max_angle=90, min_angle=-90)
    tilt = Servo(pin=12, max_angle=30, min_angle=-90)
    panAngle = 0
    tiltAngle = 0
    pan.set_angle(panAngle)
    tilt.set_angle(tiltAngle)
    sleep(1)

    while True:
        for angle in range(0, 90, 1):
            pan.set_angle(angle)
            tilt.set_angle(angle)
            sleep(.01)