예제 #1
0
def main():
    global color_flag
    path = "/home/pi/Pictures/vilib/color_detection/"

    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)
    time.sleep(2)

    print(manual)
    while True:
        try:
            key = input().lower()
            if key in ['0', '1', '2', '3', '4', '5', '6']:
                color_flag = color_list[int(key)]
                color_detect(color_flag)
            elif key == "s":
                show_info()
            elif key == 'q':
                _time = time.strftime("%y-%m-%d_%H-%M-%S", time.localtime())
                Vilib.take_photo(photo_name=str(_time), path=path)
                print("The photo save as %s%s.jpg" % (path, _time))
            elif key == "g":
                Vilib.camera_close()
                break
        except KeyboardInterrupt:
            Vilib.camera_close()
            break
def main():
    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)
    Vilib.image_classify_set_model(
        path='/home/pi/pan-tilt-hat/models/mobilenet_v1_0.25_224_quant.tflite')
    Vilib.image_classify_set_labels(
        path='/home/pi/pan-tilt-hat/models/labels_mobilenet_quant_v1_224.txt')
    Vilib.image_classify_switch(True)
예제 #3
0
def main():
    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)
    Vilib.human_detect_switch(True)

    while True:
        object_show()
        sleep(0.2)
예제 #4
0
def main():
    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)
    Vilib.hands_detect_switch(True)
    joints = []
    while True:
        joints = Vilib.detect_obj_parameter['hands_joints']

        if isinstance(joints, list) and len(joints) == 21:
            print(joints[8])

        sleep(1)
예제 #5
0
def main():

    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)

    path = "/home/pi/Pictures/vilib/continuous_shooting"

    print(manual)
    while True:
        key = readchar().lower()
        servo_control(key)
        if key == 'q':
            continuous_shooting(path, interval_ms=50, number=10)
        elif key == 'g':
            Vilib.camera_close()
            break
        sleep(0.01)
예제 #6
0
def main():

    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)
    sleep(2)
    print(manual)
    while True:
        key = readchar().lower()
        # rec control
        rec_control(key)
        # servo control
        servo_control(key)
        # esc
        if key == 'g':
            Vilib.camera_close()
            break

        sleep(0.1)
def main():
    global key

    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)

    sleep(2)
    print(manual)
    sleep(0.2)
    t = threading.Thread(target=keyboard_scan)
    t.setDaemon(True)
    t.start()

    path = "/home/pi/Videos/vilib/time_lapse"
    check_dir(path)

    while True:
        servo_control(key)

        # time-lapse photography
        if key == 'q':
            # check path
            output = path + '/' + strftime("%Y-%m-%d-%H-%M-%S", localtime())
            check_dir(output)
            # take a picture every 3 seconds for 3600 seconds
            continuous_shooting(output, interval_s=3, duration_s=3600)
            # video_synthesis
            name = strftime("%Y-%m-%d-%H-%M-%S", localtime())
            video_synthesis(name=name,
                            output=output,
                            path=path,
                            fps=30,
                            format='.jpg',
                            datetime=True)
        # esc
        if key == 'g':
            Vilib.camera_close()
            global breakout_flag
            breakout_flag = True
            sleep(0.1)
            print('The program ends, please press CTRL+C to exit.')
            break
        sleep(0.01)
예제 #8
0
def main():
    path = "/home/pi/Pictures/vilib/panorama"
    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)
    sleep(2)

    print(manual)
    while True:
        key = readchar()
        # take photo
        if key == 'q':
            print("panorama shooting ...")
            panorama_shooting(path)
        # esc
        if key == 'g':
            print('Quit')
            Vilib.camera_close()
            break

        sleep(0.01)
예제 #9
0
def main():
    path = "/home/pi/Pictures/vilib/"

    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)
    time.sleep(2)

    print(manual)
    while True:
        try:
            key = input().lower()
            if key == "q":
                _time = time.strftime("%y-%m-%d_%H-%M-%S", time.localtime())
                Vilib.take_photo(photo_name=str(_time), path=path)
                print("The photo save as %s%s.jpg" % (path, _time))
            elif key == "g":
                Vilib.camera_close()
                break
        except KeyboardInterrupt:
            Vilib.camera_close()
            break
예제 #10
0
def main():
    Vilib.camera_start(vflip=True, hflip=True)
    Vilib.display(local=True, web=True)
    Vilib.object_detect_set_model(path='/opt/vilib/detect.tflite')
    Vilib.object_detect_set_labels(path='/opt/vilib/coco_labels.txt')
    Vilib.object_detect_switch(True)
예제 #11
0
    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)
        sleep(.5)