SDIO - Time lapse photography:Use UVC to take photos and save to SD Card

Preparation

  • Ameba x 1
  • SD card or MicroSD card x 1
  • SD sniffer x 1 (optional)
  • Logitech C170 web cam x 1
  • Micro USB OTG adapter x 1

Example

In this example, we use UVC to take photos and save to SD card at regular time, which is similar to time lapse photography.
Open the sample code in “File” -> “Examples” -> “AmebaSdFatFs” -> “time_lapse_photography”
In the sample code, we start the UVC at first, then initialize SD FAT FS. In loop(), use UVC to capture photo every three seconds, and the captured photos are numbered in 0001.jpeg, 0002.jpeg, 0003.jpeg, …
1
There are some tools to turn these photos to a video. We use ffmpeg here: https://ffmpeg.org/
In Windows OS environment, type the command in the directory of all UVC photos:
ffmpeg -framerate 30 -i %04d.jpeg -vf fps=30 -pix_fmt yuv420p output.mp4

The explanation of the arguments in the command:
-framrate: By specifying this argument, you tell ffmpeg to use the time handled by framerate to be the timeline. Here we use 30, which means in 30 photos are displayed per second.
-i: use this argument to specify input file name. We use “%04d.jpeg” to tell ffmpeg to read the files from 0000.jpeg, 0001.jpeg, 0002.jpeg, …
fps: the framerate of output video, we use 30 frames per second here.
The last argument is the output file name.

Demo video:

Code reference

The sample code is comprised of two parts: use UVC to capture photo, and write file to SD card.
The UVC part please refer to previous “UVC – Use UVC To Send Image” example.
And SD part please refer tp the “SDIO – Edit Files In SD Card” example.
Please confirm that QQ communication software is installed