Wednesday, 05 July 2017 13:58

Display last photo taken on Android Phone

Posted by
Rate this item
(1 Vote)
Selfie with audience from "As Três Patetas em Chamas" Selfie with audience from "As Três Patetas em Chamas"

Bash shell script and other settings to download and display the last photo taken on an Android phone. The script is run on a computer and communicates with an Android phone cia WiFi. Tested on Linux. Not particularly efficient, as due to security issues on the Android disabling the running of commands on the remote device via SSH, it is necessarily to download all photos in a designated directory in each cycle (if anyone knows how to get around this, please leave a comment below!). Requires an SSH server app to be running on the Android and for the Android to be configured as a WiFi hub. It also requires the Android to have a copy of an RSA or DSA SSH public key. It's best that the phone is configured to take low resolution photos and the person taking photos will need to periodically delete all the photos in the selected directory to keep the downloads fast. Quite quick to do.

Used for a theatre performance of the play "As Três Patetas em Chamas" (adaptation of Chekhov's "Three Sisters") at the Departamento de Artes Cênicas, Universidade de Brasília, July, 2017, directed by Simone Reis. Images taken by the actors were projected during the performance.

The script:

 #!/bin/bash

# Mobile phone data
remote_dir=/storage/extSdCard/DCIM/Camera  
port=57846 
dst=This email address is being protected from spambots. You need JavaScript enabled to view it..1   # username in SSH server app and IP address of mobile phone. All the Androids I tested had this IP

# local directory on computer where photos are to be downloaded to
cd /home/username/projects/3patetas

# create a start up image of your choice in directory where you will store images
# in my case I created a black image called black.jpg
cp black.jpg image.jpg  

#keep displaying the most recent image with the utility "feh"
feh -F --reload 1 image.jpg&

#fetch images from the phone each 2 seconds (should probably be less frequent)
#name the most recent photo as "image.jpg"
while true; do
    scp -P $port -oHostKeyAlgorithms=+ssh-dss $dst:$remote_dir/* /home/iain/projects/3patetas
    sleep 2
    [ -f "2" ] && rm 2 # remove strange file downloaded from mobile
    cp `ls -t /home/username/projects/3patetas | head -1` /home/username/projects/3patetas/image.jpg
    # In the following line -t for timeout, -N for just 1 character
    read -t 0.25 -N 1 input
    if [[ $input = "q" ]] || [[ $input = "Q" ]]; then
        # The following line is for the prompt to appear on a new line.
        echo
        break 
    fi
done

exit 0

How to use:

1. On the computer, make sure you have SSH and "feh" installed (and anything else required in the script not installed by default).
2. On the Android, install an SSH server app. I chose "SSH Server" and it works well.
3. On the computer, create an RSA key pair and email or transfer a copy of the public key to your phone.
4. On the phone, save the RSA public key to a known location and also discover to which directory the phone saves its photos.
5. In SSH Server, create a new server, give it a name an allocate a port number (or note the port number automatically allocated)
6. Click the "user" tab in SSH Server and create a new user, giving the user a name. 
7. Deselect "enable password" and select "enable public key" then browse to find the key previously stored in step 4.
8. Leave the SSH Server app, saving your settings.
9. Still on the Android, turn WiFi off and set up your phone as an active WiFi router, WiFi Hotspot or whatever.
10. On your computer, connect to the Android's WiFi.
11. Edit the script changing the remote_dir, port, username, local download directory and anything else that needs changing.
      Also edit the name of your start up image, if not "black.jpg" (create this image too, and place it in the local download directory).
12. Mark script as executable and run it.
13. Debug.
14. Use "q" as your escape character.

Read 3497 times Last modified on Thursday, 06 July 2017 10:44

Latest Articles & News

  • Botanica: navigable, immersive sound art
  • Three-dimensional sound design with Mosca
  • The Telephonist
    The Telephonist The Telephonist (A Telefonista) is a theatrical and sound installation involving performance by Simone Reis and sound and new media art by Iain Mott. The work incorporates a modified antique…
  • New Mosca release coming soon
    A new version of the software Mosca will shortly be released, implementing work by Thibaud Keller. The release will bring support for new ambisonic libraries as well as VBAP, OSC…
  • O Espelho (The Mirror)
    O Espelho (The Mirror) is a theatrical sound installation inspired in part by the story of the same name by 19th century Brazilian writer Machado de Assis. It is by…
  • A New Method for Interactive Sound Spatialisation
    * Published in Proceedings of the 1996 International Computer Music Conference.Iain MottConservatorium of MusicUniversity of This email address is being protected from spambots. You need JavaScript enabled to view it. SosninSchool of Arts and MediaLa Trobe This email address is being protected from spambots. You need JavaScript enabled to view it. paper describes a new interface for interactive…
  • The Talking Chair: Notes on a sound sculpture
     (Iain Mott, Leonardo 28:1, MIT Press, 1995)The Talking Chair is an interactive listening environment created in collaboration by designer Marc Raszewski and myself, a composer. Integrating sculpture, electronics and industrial…