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 continuous_shooting(path, interval_ms: int = 50, number=10): print("continuous_shooting .. ") path = path + '/' + strftime("%Y-%m-%d-%H.%M.%S", localtime()) for i in range(number): Vilib.take_photo(photo_name='%03d' % i, path=path) print("take_photo: %s" % i) sleep(interval_ms / 1000) print("continuous_shooting done,the pictures save as %s" % path) sleep(0.2)
def panorama_shooting(path): global panAngle, tiltAngle temp_path = "/home/pi/Pictures/vilib/panorama/.temp/" imgs = [] # check path check_dir(path) check_dir(temp_path) # take photo for a in range(panAngle, -81, -5): panAngle = a pan.set_angle(panAngle) sleep(0.1) num = 0 for angle in range(-80, 81, 20): for a in range(panAngle, angle, 1): panAngle = a pan.set_angle(a) sleep(0.1) sleep(0.5) # sleep(0.5) print(num, angle) Vilib.take_photo(photo_name='%s' % num, path=temp_path) sleep(0.2) num += 1 # stitch image stitcher = cv2.Stitcher_create(cv2.Stitcher_SCANS) for index in range(num): imgs.append(cv2.imread('%s/%s.jpg' % (temp_path, index))) print('imgs num: %s, ' % len(imgs)) status, pano = stitcher.stitch(imgs) # imwrite and imshow print('status: %s , %s' % (status, Status_info[status])) if status == 0: cv2.imwrite( '%s/%s.jpg' % (path, strftime("%Y-%m-%d-%H.%M.%S", localtime())), pano) cv2.imshow('panorama', pano) # remove cache os.system('sudo rm -r %s' % temp_path)
def continuous_shooting(path, interval_s=3, duration_s=3600): print('\nStart time-lapse photography, press the "e" key to stop') start_time = time() node_time = start_time while True: if time() - node_time > interval_s: node_time = time() Vilib.take_photo(photo_name=strftime("%Y-%m-%d-%H-%M-%S", localtime()), path=path) if key == 'e' or time() - start_time > duration_s: break sleep(0.01) # second
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