Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Whose turn is it anyway? Augmented reality board games.

Whose turn is it anyway? Augmented reality board games.

Board games are great, but who has time to keep track of what's going on when you just want to have fun? In the spirit of over-engineering we'll look at PitchCar -- probably one of the simplest games in the world -- and see how far we can go with web tech, image processing, and a bunch of math. Expect to see plenty of code, some surprising problems and solutions, and of course: A live demo.

Dave Tapley

April 25, 2017
Tweet

Other Decks in Programming

Transcript

  1. +-----------------------+ | | | +--------------+ | action +----------+ | |

    | | cable | | | | <element> | +------------> | Rails | | | | | | | | | </element> | <------------+ | server | | | | | | | | +--------------+ | +----------+ | | +-----------------------+
  2. class VideoChannel < ApplicationCable::Channel def receive(data) uri = URI::Data.new data['image_uri']

    data = uri.data # aka after the comma File.open('image.jpg', 'wb') do |f| f.write data end image = IplImage.load 'image.jpg'
  3. <input v-model="range.red.min" @change="setHSV" /> <input v-model="range.red.max" @change="setHSV" /> <input v-model="range.green.min"

    @change="setHSV" /> <input v-model="range.green.max" @change="setHSV" /> <input v-model="range.blue.min" @change="setHSV" /> <input v-model="range.blue.max" @change="setHSV" /> methods: { setHSV: function () { this.channel.perform('set_hsv_range', { range: this.range })
  4. class VideoChannel < ApplicationCable::Channel def set_hsv_range(data) range = JSON.parse data['range']

    min = CvScalar.new range['red']['min'], # ... max = CvScalar.new range['red']['max'], # ... # .... mask = image.in_range min, max end end
  5. circles = mask.hough_circles # ... car = circles.first if car

    CarChannel.broadcast_to 'blue', x: car.x, y: car.y else CarChannel.broadcast_to 'blue', missing: true end