Flash and Hardware
Upcoming SlideShare
Loading in...5
×
 

Flash and Hardware

on

  • 3,370 views

A walk through the various hardware integration touch points one might make from Adobe Flash Player.

A walk through the various hardware integration touch points one might make from Adobe Flash Player.

Statistics

Views

Total Views
3,370
Views on SlideShare
3,359
Embed Views
11

Actions

Likes
0
Downloads
29
Comments
0

1 Embed 11

http://www.slideshare.net 11

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Flash and Hardware Flash and Hardware Presentation Transcript

  • Flash and Hardware Kevin Hoyt [email_address] Platform Evangelist Adobe Systems, Inc.
  • Agenda
    • Why?
    • Web Camera
    • Socket Basics
    • Phidgets
    • WiiFlash
    • Arduino
  •  
  • Why?
    • Programmers work really hard
    • All our work lives in this shiny box
    • Turn off the box and all of our work is gone
    • We’ve got nothing to show for our effort
    • Sorry, that’s frustrating!
  • import flash.display.BitmapData; import flash.media.Camera; import flash.media.Video; ... public var video:Video = new Video( 320, 240 ); video.attachCamera( Camera.getCamera() ); addChild( video ); ... var bmp:BitmapData = new BitmapData( 320, 240 ); bmp.draw( video );
  • Using a Web Camera
    • Hardware already on your machine
    • Import the required libraries
    • Create the video object
    • Attach the web camera
    • Use BitmapData.draw() to access pixels
    • Process to your hearts content
  • 0 = 3211 1 = 2221 2 = 2122 3 = 1411 4 = 1132 5 = 1231 6 = 1114 7 = 1312 8 = 1213 9 = 3112
  • Reading Barcodes
    • Sharpen and extract sample rows (1 pixel)
    • The first lines serve as segment markers
    • Extract seven segments per number
    • Segment colors alternate for each digit
    • Check sum at the end
    • Try line variations to maximize success
  • for( var h:Number = 0; h < video.height; h++ ) { for( var w:Number = 0; w < video.width; w++ ) { average = bmpd.getPixel( w, h ); r2 = ( average >> 16 ) & 0xFF; g2 = ( average >> 8 ) & 0xFF; b2 = average & 0xFF; distance = Math.sqrt( Math.pow( r2 - r1, 2 ) + Math.pow( g2 - g1, 2 ) + Math.pow( b2 - b1, 2 ) ); } }
  • Color Intensity
    • Get a sample color (triggered by user input)
    • Iterate through all the pixels at desired rate
    • Determine color distance from sample
    • Track pixel position with least distance
    • Rotate sprite based on distance from center
  • Barcode Reader Computer Vision
    • Flash Player 9 and before (9.0.124)
      • Policy file served independently
      • Sockets can connect to 1024 or higher
    • Flash Player 10 and forward
      • Port 843 or the specific destination port
      • Prevents DNS rebinding attacks
    • Adobe AIR doesn’t care about policy files
  •  
  • Phidgets
    • Plug and play USB prototyping
    • Numerous sensors as well as motor control
    • Support for multiple operating systems
    • Support for multiple languages (inc. AS3)
    • Phidgets service is a proxy socket server
    • AS3 library available for sensors and events
  • Some Types of Phidgets
    • Infrared distance
    • Force
    • Motion
    • Temperature
    • Light
    • Sonar
    • Linear touch
    • Circular touch
    • Accelerometer
    • Ph
    • Thermocouple input
    • Encoder
  • public var phidget = new PhidgetInterfaceKit(); phidget.addEventListener( PhidgetDataEvent.SENSOR_CHANGE, doSensor ); phidget.open( &quot;localhost&quot;, 5001 ); ... public function doSensor( event:PhidgetDataEvent ):void { picture.alpha = Number( event.Data ) / MAX_RANGE; }
  • Inventory Manager Phidget Overload
  •  
  • WiiFlash
    • Open source project by Thibault Imbert
    • Integrates Wii Remote and Flash via Bluetooth
    • Provides socket server for various OSs
    • Provides AS3 library for server interaction
    • Drives events for most Wii Remote changes
    • No support for sensor bar (really an emitter)
  • wiimote = new Wiimote(); wiimote.addEventListener( ButtonEvent.A_PRESS, doAButton ); wiimote.addEventListener( ButtonEvent.A_RELEASE, doAButton ); wiimote.addEventListener( WiimoteEvent.UPDATE, doUpdate ); wiimote.connect(); ... public function doAButton( event:ButtonEvent ):void { trace( event.type ); } public function doUpdate( event:WiimoteEvent ):void { trace( wiimote.pivot ); }
  • Vision Revisited Event Charting
  •  
  • Arduino
    • Open source prototyping platform
    • Primarily targeted at hobbyists
    • Processing/Wiring language/IDE
    • Can be connected to a PC or standalone
    • Purchasing pre-assembled costs about $65
  • Sample Project
    • Connect the board to your computer
    • Connect an LED to the board
    • Run the development environment
    • Write and upload a program to the board
    • Watch your Arduino go to work for you
    • Countless “shields” offer infinite possibilities
  • Flash Integration
    • Install Firmata on the Arduino for serial access
    • Use serial proxy ( SerProxy ) to create a socket
    • Use a socket library to communicate out
    • Glue documented well by Protolab
  • With Flash Without Flash
  • Flash and Hardware Kevin Hoyt [email_address] Platform Evangelist Adobe Systems, Inc.
  • References
    • Barcode Reader
    • Basic Computer Vision
    • Socket Policy Files
    • Phidgets
    • WiiFlash
    • Arduino