Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
/ photobooth Public archive

Cloud-connected talking photobooth using TensorFlow

License

Notifications You must be signed in to change notification settings

androidthings/photobooth

Repository files navigation

Android Things Photobooth

Introduction

This project contains all the code required to build a cloud-connected, talking photobooth powered by Android Things. This is the codebase that was used in the Photobooth demo at Google I/O 2017. It will take your photo, style it with Tensorflow, upload it to the cloud, and print the photo out. Upon request, it can also share your photo to its twitter account.

This demo uses the following Google platforms and APIs:

Note: The Android Things Console will be turned down for non-commercial use on January 5, 2022. For more details, see the FAQ page.

Pre-requisites

  • One Android-Things powered device with a connected camera. This demo ran on a Raspberry Pi 3, but is in no way limited to that device.

  • One Google Assistant device. It's a talking photobooth, so you need something to handle the VUI. You can use a Google Home, or build your own.

(Optional)

  • To print out QR codes, you can use a thermal printer. Modify the code to use the ThermalPrinter class instead of HttpImagePrint.

(Optional)

  • A regular printer to print out photos. This will need to be attached to a print server. Setting up the server is beyond the scope of this document.

Getting Started

Most of the steps here are best described by existing documentation, which is better to link to than to paraphrase. In order, do the following.

  • Set up your Android Things device.

  • Import this project in Android Studio

  • Add Firebase to your Android project

    • Follow the instructions for setting up Google Cloud Storage for Firebase. Be sure to set up storage security rules. You'll want the rules set so that anybody can download the photos, but only authenticated "users" of the application (only the signed APK for your application) can upload photos. Here is the rule to copy/paste:
    service firebase.storage {
        match /b/{bucket}/o {
          match /{allPaths=**} {
            allow read: if true;
            allow write: if request.auth != null;
          }
        }
    }
    
  • Deploy the Google Cloud Functions which are located in project-root/firebase

    • These interact with multiple services you will also need to set up:

      • To share on Twitter, you'll need a Twitter API key.
      • To generate shortened URLs you'll need an API key for Google's URL Shortener.
      • Once you have the keys, add them to your [Environment Configuration] so they'll be retrieved from the server at runtime. Modify firebase/functions/photos.js to point to the correct environment variables. The code block to modify will look like this:
      /**
       * Twitter Info
       */
       var TWTR_CONSUMER_KEY = functions.config().twitter.consumer_key;
       var TWTR_CONSUMER_SECRET = functions.config().twitter.consumer_secret;
       var TWTR_ACCESS_TOKEN_KEY = functions.config().twitter.access_token_key;
       var TWTR_ACCESS_TOKEN_SECRET = functions.config().twitter.access_token_secret;
      
      /**
       * API key for the Google URL shortener API
       * https://developers.google.com/url-shortener/v1/getting_started#APIKey
       */
      var URL_SHORTENER_API_KEY = functions.config().shorturl.key;
      
  • Code for the Google Assistant app (the voice UI) is in the agent/ directory. To deploy it, follow the Getting Started Guide for Actions On Google.

  • Printing strategies will vary - For the photobooth demo we set up CUPS on a second Raspberry Pi and attached it to a Photobooth printer (the setup of CUPS and various printer models is wildly beyond the scope of this document). It's also possible (and likely easier) to get a printer that supports Google Cloud Print, and use the sendJobs API call to activate a print job over the internet.

Support and Discussion

If you've found an error in this sample, please file an issue: https://github.com/androidthings/photobooth/issues

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.

Enable auto-launch behavior

This Android Things app is currently configured to launch only when deployed from your development machine. To enable the main activity to launch automatically on boot, add the following intent-filter to the app's manifest file:

<activity ...>

    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.HOME"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>

</activity>

License

Copyright 2017 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Cloud-connected talking photobooth using TensorFlow

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published