Skip to content
GuessTheFormat is an experiment for photographers: can you tell the difference between camera sensor formats just by looking at a photo?
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
conf
public
test
.gitignore
LICENSE.md
README.md
build.sbt

README.md

GuessTheFormat

GuessTheFormat (GTF) is an experiment for photographers: can you tell the difference between camera sensor formats just by looking at a photo?

View a demo video of the application on YouTube, or see guesstheformat.com/about for more information. Since you're looking at this git repository, check out app/views/about.scala.html.

GuessTheFormat Animated Example Image

Notes

This README.md was written a full four years after this project was last worked on. The intent here is not to showcase my current programming skills, but to hand off this project to someone else who may want to take over, fork, or maintain it.

Please contact me to become a contributor/collaborator, or just fork this repository.

Project Structure

This is a Scala Play Framework application. See the build.sbt file for library dependencies.

There are two main actions:

  1. Fetch a random photo from the DB: GET /photo
  2. Make a sensor format guess about a photo (and get a result back): POST /guess/:photoId/:formatGuess/:otherFormat

See the conf/routes file for more information about the each route.

There are two recurring jobs in app/Global.scala that will each run 30-seconds after server start-up, and then be scheduled to run periodically:

  1. Flickr "Explore" photo population: controllers.PhotoController.populatePhotosFrom. This is used to generate a DB cache of "Interesting" Flickr explore photos, which is used for random selection.
  2. Stats rollup, for the stats page (app/views/stats/stats.scala.html): controllers.StatsController.statsRollup

The conf/cameras.csv file must be maintained and updated with the EXIF info of popular cameras (as found on Flickr). Disclaimer: this file currently has Amazon referral links for certain cameras.

Configuration

The conf/schema.sql contains the MySQL database schema that's required, and conf/cameras.csv contains the data that should be loaded into the cameras table.

  1. Set up a MySQL instance with a gtf database.
  2. Generate a new application secret.
  3. Get a Flickr API key.
  4. Update the conf/application.conf and conf/application.prod.conf files with your Play application secret, Flickr API keys, and MySQL instance connection details.
  5. Run the conf/schema.sql against the gtf db.
  6. Populate the cameras table using the script below.
LOAD DATA LOCAL INFILE 'cameras.csv'
REPLACE INTO TABLE cameras
FIELDS TERMINATED BY ',' ENCLOSED BY "'"
IGNORE 1 LINES
(id, exifMake, exifModel, format, displayText, adCode);

Running

sbt run

Deployment

This application will run just fine on a single EC2 t2.micro instance.

  1. Follow the configuration instructions above, first (get your MySQL db set up and populated, update the config files, etc).
  2. Update the application version number in the build.sbt file.
  3. play clean
  4. play compile
  5. play dist
  6. SCP /GTF/target/universal/GTF-<version>.zip to location of choice
  7. unzip
  8. update get_mem_opts() in /var/www/GTF-<version>/bin/gtf to:
      get_mem_opts () {
        echo "-Xms256m -Xmx512m -XX:MaxPermSize=128m -XX:ReservedCodeCacheSize=128m"
      }

License

MIT. See LICENSE.md.

You can’t perform that action at this time.