SunFounder PiCrawler Kit
(continued from previous page)
elif rec_flag == 'pause':
rec_flag = 'start'
Vilib.rec_video_start()
print_overwrite('continue')
# stop
elif key == 'e' and rec_flag != 'stop':
key = None
rec_flag = 'stop'
Vilib.rec_video_stop()
print_overwrite("The video saved as %s%s.avi"%(Vilib.rec_video_set["path
˓→"],vname),end='\n')
# quit
elif key == readchar.key.CTRL_C or key in readchar.key.ESCAPE_SEQUENCES:
Vilib.camera_close()
print('\nquit')
break
sleep(0.1)
if __name__ == "__main__":
main()
How it works?
Functions related to recording include the following:
• Vilib.rec_video_run(video_name) : Started the thread to record the video. video_name is the
name of the video file, it should be a string.
• Vilib.rec_video_start() : Start or continue video recording.
• Vilib.rec_video_pause() : Pause recording.
• Vilib.rec_video_stop() : Stop recording.
Vilib.rec_video_set["path"] = "/home/pi/video/test/" sets the storage location of video files.
3.9 Bull Fight
Make PiCrawler an angry bull! Use its camera to track and rush the red cloth!
64 Chapter 3. Play with Python