Creating cloud-compatible photo frames with Raspberry Pi

Image credit: Tomokatsu Yukishita

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 デジタルフォトフレームの売れ筋ランキング
https://www.amazon.co.jp/gp/bestsellers/electronics/675721011/ref=pd_zg_hrsr_electronics

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.

screen reader text
Cloud compatible 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版】
thumbnail
Raspberry Pi 4 は、エントリレベルの PC と同等の電力を供給するアップグレードされたプロセッサで、パフォーマンスが向上しています。 より複雑なプロセスを効率的に実行可能な様に、1GB、 2GB 、4GB のメモリサイズが選択可能になりました。 デュアルmicro-HDMIポートにより、デュアルスクリーン設定が可能(以前のバージョンでは標準HDMIポート1個を搭載) 最大4Kのビデオデコード USB 3.0 ポート× 2 により、他の周辺機器への Faster 接続が可能(旧モデルは USB 2.0 ポート × 4) 電力は USB-C 経由で供給(以前のRaspberry Pi 3 は、5.1V で Micro-USB 経由で給電 )
https://www.amazon.co.jp/dp/B081YD3VL5?linkCode=sl1&tag=snowunderco07-22&linkId=6d662c3fa29490bb00611c5a8a86b54a&language=ja_JP&ref_=as_li_ss_tl&th=1

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/サブモニター/交換用液晶パネル 狭額
thumbnail
【FHD高精細画質・画面に遅延無し】72%NTSC色域とHDR高ダイナミック技術とFHDを採用したこの1920*1080Pモニターは、他の1080Pの45%色域に比べて、画質がより高精細で、しかも色がより鮮やかで、IPSパネル採用で斜めから見てもくっきりキレイに楽しめます、60Hzのリフレッシュ率で映像と音を遅延なく点滅させなく、高音質のスピーカーを内蔵し、迫力のある臨場感をもたらせます、Chongyickの旗艦型番として、ゲーム・ビジネス・テレワーク・在宅勤務用にも最適します、勿論、テレビ会議を行いながら、作業できます。三年間以内に不良を発生したら、修理しないで、新しいモニターを再送致します。
https://www.amazon.co.jp/dp/B088BHMNXW?_encoding=UTF8&psc=1&linkCode=sl1&tag=snowunderco07-22&linkId=c39742142a36af4a5b5fb260a337a386&language=ja_JP&ref_=as_li_ss_tl

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 エコパッケージ
thumbnail
ビデオスピードクラス30(V30)、UHSスピードクラス3(U3)とCLASS10に対応し、4K動画やフルHD動画に最適 容量:32GB 最大読取り速度100MB/秒 2年間限定保証
https://www.amazon.co.jp/dp/B07QC5RKRT?linkCode=sl1&tag=snowunderco07-22&linkId=c67660149844677ac694a73bdf01950b&language=ja_JP&ref_=as_li_ss_tl&th=1
Miuzei Raspberry Pi 4 電源、USB-C(Type C)ケーブル 5.1V 3A 充電器コードスイッチ付き ACアダプタ、互換性ありRaspberry RPi 4 Model B 1GB / 2GB / 4GB / 8GB バージョン PSE認証
thumbnail
【商品仕様】入力電圧:AC100V-240V(海外・国内両用)、出力電圧:DC5.1V、出力電流:最大3A、ケーブルの長さ:1.50m/ 59インチ 高品質 【1年保証】
https://www.amazon.co.jp/dp/B087CF6127?&linkCode=sl1&tag=snowunderco07-22&linkId=bfc9b1bdafb22eadfed371ea224bde4d&language=ja_JP&ref_=as_li_ss_tl

System configuration

Next, consider the system configuration. RaspberryPi uses Raspberry Pi OS.

OS

Raspberry Pi OS
thumbnail
Your Raspberry Pi needs an operating system to work. This is it. Raspberry Pi OS (previously called Raspbian) is our official supported operating system.
https://www.raspberrypi.com/software/

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
thumbnail
Rclone is a command-line program to manage files on cloud storage. It is a feature-rich alternative to cloud vendors' web storage interfaces. Over 70 cloud storage products support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.
https://rclone.org

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.

screen reader text
Installing Raspberry Pi OS

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.

  1. Get a list of specified folders on cloud storage using rclone ls
  2. Start acquiring images at random once a certain amount of images have been acquired.
  3. Display images on FBI from the acquired images
  4. During that time, a certain number of images will be acquired in the background.
  5. Display the next image at random when the specified time comes
  6. Random selection used weighting. When displayed, it is decremented and other images are displayed preferentially.
  7. Run rclone ls and merge the database on week 1
  8. 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 入門 + 応用 +アメリカのシリコンバレー流コードスタイル
現役シリコンバレーエンジニアが教えるPython入門!応用では、データ解析、データーベース、ネットワーク、暗号化、並列化、テスト、インフラ自動化、キューイングシステム、非同期処理など盛り沢山の内容です!
https://www.udemy.com/course/python-beginner/
酒井潤公式ブログ
thumbnail
アメリカ シリコンバレーから情報発信
http://sakaijun.blog.jp/

Source code

The created program is published on github.

GitHub - yukishita/photoView4: クラウド対応スライドショープログラム
thumbnail
クラウド対応スライドショープログラム. Contribute to yukishita/photoView4 development by creating an account on GitHub.
https://github.com/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

Related