Create a gist now

Instantly share code, notes, and snippets.

@jwarchol /LogoBooth.md Secret
Last active Sep 3, 2015

What would you like to do?
TED2015 Logo Booth Technical Details
#!/usr/bin/env ruby
require 'rubygems'
require 'gphoto4ruby'
require 'sinatra'
require 'json'
require 'thin'
require './blinkstick.rb' # https://github.com/arvydas/blinkstick-ruby/blob/master/blinkstick.rb
$stdout.sync = true
capture_counter = 0;
set :bind, '0.0.0.0'
set :server, 'thin'
ports = GPhoto2::Camera.ports
if ports.any?
cam = GPhoto2::Camera.new(ports.first)
cam["imagesize"] = "2992x2000"
else
puts "No Camera Found"
exit
end
b = BlinkStick.find_all.first
red = Color::RGB.new(255,0,0)
green = Color::RGB.new(0,255,0)
white = Color::RGB.new(255,255,255)
post '/blink' do
response['Access-Control-Allow-Origin'] = "*"
b.color = red
sleep 0.20
b.off
{blink: "good"}.to_json
end
post '/capture/:timer' do
response['Access-Control-Allow-Origin'] = "*"
filename = "photo_#{Time.now.to_i}.jpg"
b.color = white
cam.capture.save(new_name: "public/#{filename}").delete
b.off
capture_counter += 1
{image: request.base_url + "/" + filename}.to_json
end

TED 2015 Logo Booth Technical Details

For a background on the project and some fantastic example photos, check out The red TED letters go out to play: Building TED2015’s logo photobooth

Components

Technical Flow

The user interface for the Logo Booth was a custom web interface on a tablet. The tablet was a Samsung Galaxy Tab Pro 10.1", chosen for it's affordable price and retina screen. Users were prompted by the attract screen to place their TED conference badge photo on the top of the reader located just to the left of the screen. On the reverse of the badge is a unique NFC "tag". Inside the reader box is a circuit board from Adafruit Industries (just down the street from TED HQ) called a PN532 breakout board. This device can interface with the badge NFC tags when they're within a few inches of it. In order to get the information on which NFC tag was read to the web service coordinating the whole Logo Booth, a Raspberry Pi micro computer was hidden in the base of the stand, powered by a hefty USB battery pack. Over wifi it posted the unique NFC ID, allowing the coordinating service to look that ID up against records from TED's event management system, bringing back the name and photo of the person whose badge was scanned. The coordinating service then pushed a message via websockets to the tablet interface causing the attendee to be greeted by name and their photo shown confirming who will be associated with this photo. Up to four attendees could "badge in" on a single photo and each would receive an email and TEDConnect push notification when it was done.

Once everyone was badged in a short countdown started and they scurried over to pose by the letters. Straight ahead a USB LED BlinkStick attached to the camera mounting flashed red to draw their attention to where the camera was. As the countdown completed a request was sent from the tablet to the camera controller to capture the photo. The camera controller was another Raspberry Pi micro computer that was attached to the rigging on the ceiling. Connected to it via USB were the BlinkStick light, the Nikon D5200 camera, and a USB WiFi adapter for network communication. Using the open source GPhoto2 camera control library this small web service would trigger the shutter and save the captured photo to its local storage, finally responding to the tablet's request with a URL where the photo could be accessed. Using this response the tablet displayed a preview of the image, rotated to compensate for the inverted camera and cropped in CSS to show only the properly framed portion of the captured photo.

If the attendees were happy with the photo, they'd tap "Send" and a request was posted to the main web service recording the local URL of the photo, and which attendees were in it. Once recorded, a series of asynchronous background processing began. Using the GraphicsMagick image processing library the photo was rotated 180 degrees and cropped to match the preview. A small TED2015 watermark was composited over it and the final photo was optimized for the web. The final image was then stored in the cloud and a request was posted to the at.ted.com photo sharing website. The URL (example) was then used in the email and TEDconnect message sent to the attendees badged into the photo.

Finally the tablet interface reset, ready for the next photo.

Geeky bits

Originally we wanted to use the tablet to read the NFC badges but the current state of NFC on tablets isn't great. Often they read from the back (no good here) or are not popular enough to have high quality aftermarket stands. In the end we opted to find the optimal tablet/stand combo and use an external NFC reader.

Unable to find an existing NFC reader that was open enough for our needs we intergrated a few bits of Open Source Hardware in a custom-built enclosure. The Adafruit NFC Breakout has a spot for connecting an FTDI interface to it. The FTDI Friend is a small adapter between this lower level communication interface and the standard USB one common on computers. By directly soldering the FTDI Friend to the NFC breakout, I was able to create a compact package that had an easy and modular interface to the Raspberry Pi. An asthetically pleasing white USB cable wrapped around the gooseneck holding the reader to the stand. Once connected, the open source LibNFC library was used (via the "nfc" ruby gem).

The coordinating web service used a Node.js process to allow the websocket connection between the tablet and the coordination service. The Redis NoSQL database was used to pre-cache badge data for lower latency acccess, and as a pub/sub bridge between the Rails site and the Node websocket.

Ceiling Gear

Tablet Stand

Besides these technical bits, I'll end with a shout out to TED's Vancouver staff and the talented (and patient!) electricians and riggers who made this physically possible and looking great.

#!/usr/bin/env ruby
require 'rubygems'
require 'nfc'
require 'http'
trap("INT") { puts "Shutting down."; exit}
ctx = NFC::Context.new
# Open the first available USB device
dev = ctx.open nil
# You can even run in an infinite loop if you'd like to continually find
# tags:
cache = {}
loop do
tag = dev.poll
if tag.is_a? NFC::ISO14443A
tag_id = tag.to_s
puts "Found #{tag_id}"
cache.delete_if {|k,v| k < Time.now - 10}
if cache.values.include?(tag_id)
puts "..seen recently, skipping this time"
else
cache[Time.now] = tag_id
t = Time.now.to_f
puts "Initiating Badge POST"
HTTP.post(ENV["SERVICE_URL"], form: {nfcid: tag_id})
puts "Completed Badge POST (#{Time.now.to_f - t})"
end
sleep 0.5
else
sleep 0.5
end
end
Owner

jwarchol commented May 14, 2015

Comment here if you have any questions! 😄

kenseii commented May 27, 2015

1.can you release a full documentation like a tutorial of how to build it(the software and the assembling part)

Owner

jwarchol commented Jun 25, 2015

The software not included above is just the proprietary integration bits for interfacing with TED's systems. The assembly was almost entirely "plug the USB in" for the final design. Do you have specific questions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment