This small project brings together bunch of my hobbies together. I got to play with carpentry, photography and software/technology including face detection.
I have run out of places in the home to hang photo frames and as a way around I was planning to get a digital photo frame. When I upgraded my home desktop to 2 x 4K monitors I had my old dell 28" 1080p monitor lying around. I used that and a raspberry pi to create a photo frame. It boasts of the following features
- A real handmade frame
- 1080p display
- Auto sync from OneDrive
- Remotely managed
- Face detection based image crop
- Low cost (uses raspberry pi)
In my previous project of smart-mirror, I focused way too much on the framing monitor part and finally had the problem that the raspberry-pi and the monitor is so well contained inside the frame that I have a hard time accessing it and replacing stuff. So this time my plan was to build a simple lightweight frame that is put on the monitor using velcro fasteners so that I can easily remove the frame. The monitor is actually on its own base, so the frame is just cosmetic and doesn't bear the load of the monitor. Rather the monitor and its base holds the frame in place.
I bought a 2" trim from Homedepot and cut out 4 pieces using a saw and then joined them using just wood glue. To let the glue cure, I held the corners using corner clamp for 12 hours. The glue is actually stronger than the trim itself, so once it dries there is no chance of things falling apart.
On the back of the frame I attached a small piece of wood, on which I added velcro. I also glued velcro to the top of the monitor. These two strips of velcro keeps the frame on the monitor.
Now the frame can be attached loosely to the monitor just by placing on it.
After that I got a raspberry-pi and connected it to the monitor using hdmi cable and attached the raspberry pi with zip ties to the frame. All low tech till this point.
I always get my base setup
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install xrdp # install remote desktop
sudo apt-get install vim # my editor of choice
sudo apt-get install git
git clone https://github.com/abhinababasu/share # get my shell
cp share/.vimrc .
cp share/.bash_aliases .
cp share/.bashrc .
cp share/.bash_aliases .
sudo apt-get install unclutter # hide mouse pointer in slide show
To keep things fresh, reboot midnight every day, add the following to /etc/crontab
0 0 * * * root reboot
1. sudo vim /boot/config.txt
2. Add the line: display_rotate=3
Push PicsI use FrameMaker for managing photos I take. My workflow for this case is as follows
- All images are tagged with keyword "frame" in lightroom.
- I use smart folder to see all these images and then publish to a folder named Frame in OneDrive
Sync OneDrive to Raspberry Pi
I used the steps in https://jarrodstech.net/how-to-raspberry-pi-onedrive-sync/
- curl -L https://raw.github.com/pageauc/rclone4pi/master/rclone-install.sh | bash
- rclone config
- Enter n (for a new connection) and then press enter
- Enter a name for the connection (i’ll enter onedrive) and press enter
- Enter the number for One Drive
- Press Enter for client ID
- Press Enter for Client Secret
- Press n and enter for edit advanced config
- Enter y for auto config
- A browser window will now open, log in with your Microsoft Account and select yes to allow OneDrive
- Choose right option for OneDrive personal
- Now select the OneDrive you would like to use, you will probably only have one OneDrive linked to your account. This will be 0
- Y for subsequent questions
- To Sync once: rclone sync -v onedrive:Frame /home/pi/frame
- Setup automatic sync every one hour
- echo "rclone sync -v onedrive:Frame /home/pi/frame" > ~/sync.sh
- chmod +x ~/sync.sh
- crontab -e
- Add the line: 1 * * * * /home/pi/sync.sh
There are many options that I could find online to show the photos. But I chose to go with the easiest one, use the xscreensaver. However, there are some issues and most likely this is something I will revisit.
- Disable screen blanking after some time of no use
- vi /etc/lightdm/lightdm.conf
- Addd the line[SeatDefaults]
xserver-command=X -s 0 -dpms
- Enable auto-login, so that on restart you directly get logged in and then into screensaver
- sudo raspi-config
'Boot Options' then 'Desktop / CLI' then 'Desktop Autologin'. Then right arrow
twice and Finish and reboot.
- Setup screen saver
- sudo apt-get -y install xscreensaver
- sudo apt-get -y install xscreensaver-gl-extra
These are my screen saver settings to show the photos in /home/pi/frame as slideshow
Problems and solving with Face Detection
My photos are rarely 9:16 portraits, that means an ugly black box on the top and bottom of the images.
Obvious approach is to crop using some batch tool. But that would mean the crop could arbitrarily cut images out. Consider the following image
Cropping in a batch tool that picks up arbitrary area of the image generated something like below, which is obviously not acceptable.
To solve this I build a tool at https://github.com/abhinababasu/img. It takes my other project on detecting faces in images and then ensures that in the cropped image the face is retained. E.g. the tool above generates the following image.