Creating cloud-compatible photo frames with Raspberry Pi
Introduction
I like taking pictures. I bought a digital SLR camera around 2003 and have been working on photography ever since.
And before I knew it, the total number of shots was 388,524. I took quite a number of photos.
There are also commercially available products
Commercially available photo frames are ones that store data on an SD card or USB memory and display it. Most of the screen sizes are around 7 to 10 inches.
Amazon.co.jp デジタルフォトフレームの売れ筋ランキング
I take pictures about once a week, but when I use a regular photo frame, it’s a pain to enter the data. That’s what I think.
I want a cloud-type photo frame anyway
Frequently uploading photos to an SD card is a chore, and you’ll likely end up not using it any time soon. So, I would like to store photos in cloud storage such as Google Drive and display them on a photo frame.
Perhaps there is no such demand, but I can’t find anything like it on the market.
I don’t have one, so I’ll make one
If you don’t have one, why not make one? So I created a cloud-compatible photo frame.
Prepared
Raspberry Pi 4
Photo frames are always powered on, so it’s best to use one with low power consumption. This time I used Raspberry Pi 4.
【国内正規代理店品】Raspberry Pi4 ModelB 4GB ラズベリーパイ4 技適対応品【RS・OKdo版】
Mobile monitor
A monitor for displaying photos. It is a mobile monitor with FullHD & IPS panel. If it is a mobile monitor, the power supply will be small and the installation flexibility will be high. Most photo frames skimp on monitor quality and are disappointing due to their narrow viewing angles, but the best part is that you can choose the parts you want.
モバイルモニター/モバイルディスプレイ/CHONGYICK 15.6インチ FHD/ゲームモニター /72%NTSC色域 IPSパネル 軽薄型 Type-C/HDMI/全CNC製アルミ スタンドカバー付 PS4/XBOX/switch/PC/Mac/サブモニター/交換用液晶パネル 狭額
Other power supplies
In addition, prepare the SD card and power supply necessary for RaspberryPi operation.
【 サンディスク 正規品 】 2年保証 ドライブレコーダー対応 microSDカード 32GB UHS-I Class10 U3 V30対応 SDSQQNR-032G-GHEIA エコパッケージ
Miuzei Raspberry Pi 4 電源、USB-C(Type C)ケーブル 5.1V 3A 充電器コードスイッチ付き ACアダプタ、互換性ありRaspberry RPi 4 Model B 1GB / 2GB / 4GB / 8GB バージョン PSE認証
System configuration
Next, consider the system configuration. RaspberryPi uses Raspberry Pi OS.
OS
Raspberry Pi OS
This time we will use it as a photo frame, so we will set it up using CLI without using Desktop.
Image display program
To display images, use fbi, which can display images on CLI. *I made a previous version that runs on the GUI on Ubuntu, but it was unstable and I gave up on stable operation.
How to access cloud storage
Use rclone to access cloud storage.
Rclone syncs your files to cloud storage
This rclone will periodically download photos and display them to the FBI.
set up
Installing Raspberry Pi OS
Write the image to the SD card using Raspberry Pi Imager. For this purpose, I think either 32bit or 64bit is fine.
Installing fbi
Once written and started, install it on the Raspberry Pi using the following command.
pi@photo:~ $ sudo apt-get -y install fbi
Granting permissions
If you leave it as is, only superusers will be able to view the image on FBI, so give permission.
pi@raspi3-photo:~ $ ls -Fla /dev/fb0
crw-rw---- 1 root video 29, 0 Apr 7 10:33 /dev/fb0
Add pi to the video group.
sudo usermod -G video pi
Installing rclone
You can install it below.
curl https://rclone.org/install.sh | sudo bash
Creating a slideshow program
2022/5/22 update: A new version has been created. The time from startup to display has been sped up.
overview
I used the following algorithm.
- Get a list of specified folders on cloud storage using rclone ls
- Start acquiring images at random once a certain amount of images have been acquired.
- Display images on FBI from the acquired images
- During that time, a certain number of images will be acquired in the background.
- Display the next image at random when the specified time comes
- Random selection used weighting. When displayed, it is decremented and other images are displayed preferentially.
- Run rclone ls and merge the database on week 1
- In previous versions, the database was recorded in an external file as json, but merging was slow, so it was kept in memory.
Development language
I chose python as a language to study.
2022/5/22 update: The new version is object-oriented and created according to Python etiquette. I recommend Jun Sakai’s course on Udemy.
現役シリコンバレーエンジニアが教えるPython 3 入門 + 応用 +アメリカのシリコンバレー流コードスタイル
酒井潤公式ブログ
Source code
The created program is published on github.
GitHub - yukishita/photoView4: クラウド対応スライドショープログラム
How to use
Just launch the script at startup.
I added the following to my crontab. @reboot has a role similar to the Windows startup that starts at startup.
@reboot /home/pi/photoView4/photoView4.sh
Demonstration
This is a demonstration video of the completed photo frame.
Achieved 1700% faster speed! !
Previous version
The basic operation remains the same, but since it starts after acquiring all the file lists, startup is slow…
Tips
Turn off the display at a specified time
If you use 24-hour display, it is a waste of electricity, so if you are connected via HDMI, you can write the following in crontab.
0 0 * * * /usr/bin/vcgencmd display_power 0
30 6 * * * /usr/bin/vcgencmd display_power 1
In the example above, the display will turn off at midnight and turn on at 6:30 am.
It may also be possible to use a motion sensor or a light sensor.
summary
What did you think? This time I used a Raspberry Pi 4, but I think it can also be run with a lower performance Raspberry Pi Zero or the like. (It may take some time to start up for the first time)
assignment
None for now