Your SlideShare is downloading. ×
0
Flash and Hardware Kevin Hoyt [email_address] Platform Evangelist Adobe Systems, Inc.
Agenda <ul><li>Why? </li></ul><ul><li>Web Camera </li></ul><ul><li>Socket Basics </li></ul><ul><li>Phidgets </li></ul><ul>...
 
Why? <ul><li>Programmers work really hard </li></ul><ul><li>All our work lives in this shiny box </li></ul><ul><li>Turn of...
import flash.display.BitmapData; import flash.media.Camera; import flash.media.Video; ... public var video:Video = new Vid...
Using a Web Camera <ul><li>Hardware already on your machine </li></ul><ul><li>Import the required libraries </li></ul><ul>...
0 = 3211 1 = 2221 2 = 2122 3 = 1411 4 = 1132 5 = 1231 6 = 1114 7 = 1312 8 = 1213 9 = 3112
Reading Barcodes <ul><li>Sharpen and extract sample rows (1 pixel) </li></ul><ul><li>The first lines serve as segment mark...
for( var h:Number = 0; h < video.height; h++ )  { for( var w:Number = 0; w < video.width; w++ )  { average = bmpd.getPixel...
Color Intensity <ul><li>Get a sample color (triggered by user input) </li></ul><ul><li>Iterate through all the pixels at d...
Barcode Reader Computer Vision
<ul><li>Flash Player 9 and before (9.0.124) </li></ul><ul><ul><li>Policy file served independently </li></ul></ul><ul><ul>...
 
Phidgets <ul><li>Plug and play USB prototyping </li></ul><ul><li>Numerous sensors as well as motor control </li></ul><ul><...
Some Types of Phidgets <ul><li>Infrared distance </li></ul><ul><li>Force </li></ul><ul><li>Motion </li></ul><ul><li>Temper...
public var phidget = new PhidgetInterfaceKit(); phidget.addEventListener(  PhidgetDataEvent.SENSOR_CHANGE,  doSensor ); ph...
Inventory Manager Phidget Overload
 
WiiFlash <ul><li>Open source project by Thibault Imbert </li></ul><ul><li>Integrates Wii Remote and Flash via Bluetooth </...
wiimote = new Wiimote(); wiimote.addEventListener( ButtonEvent.A_PRESS, doAButton ); wiimote.addEventListener( ButtonEvent...
Vision Revisited Event Charting
 
Arduino <ul><li>Open source prototyping platform </li></ul><ul><li>Primarily targeted at hobbyists </li></ul><ul><li>Proce...
Sample Project <ul><li>Connect the board to your computer </li></ul><ul><li>Connect an LED to the board </li></ul><ul><li>...
Flash Integration <ul><li>Install  Firmata  on the Arduino for serial access </li></ul><ul><li>Use serial proxy ( SerProxy...
With Flash Without Flash
Flash and Hardware Kevin Hoyt [email_address] Platform Evangelist Adobe Systems, Inc.
References <ul><li>Barcode Reader </li></ul><ul><li>Basic Computer Vision </li></ul><ul><li>Socket Policy Files </li></ul>...
Upcoming SlideShare
Loading in...5
×

Flash and Hardware

1,623

Published on

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

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,623
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
31
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Flash and Hardware"

  1. 1. Flash and Hardware Kevin Hoyt [email_address] Platform Evangelist Adobe Systems, Inc.
  2. 2. Agenda <ul><li>Why? </li></ul><ul><li>Web Camera </li></ul><ul><li>Socket Basics </li></ul><ul><li>Phidgets </li></ul><ul><li>WiiFlash </li></ul><ul><li>Arduino </li></ul>
  3. 4. Why? <ul><li>Programmers work really hard </li></ul><ul><li>All our work lives in this shiny box </li></ul><ul><li>Turn off the box and all of our work is gone </li></ul><ul><li>We’ve got nothing to show for our effort </li></ul><ul><li>Sorry, that’s frustrating! </li></ul>
  4. 5. 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 );
  5. 6. Using a Web Camera <ul><li>Hardware already on your machine </li></ul><ul><li>Import the required libraries </li></ul><ul><li>Create the video object </li></ul><ul><li>Attach the web camera </li></ul><ul><li>Use BitmapData.draw() to access pixels </li></ul><ul><li>Process to your hearts content </li></ul>
  6. 7. 0 = 3211 1 = 2221 2 = 2122 3 = 1411 4 = 1132 5 = 1231 6 = 1114 7 = 1312 8 = 1213 9 = 3112
  7. 8. Reading Barcodes <ul><li>Sharpen and extract sample rows (1 pixel) </li></ul><ul><li>The first lines serve as segment markers </li></ul><ul><li>Extract seven segments per number </li></ul><ul><li>Segment colors alternate for each digit </li></ul><ul><li>Check sum at the end </li></ul><ul><li>Try line variations to maximize success </li></ul>
  8. 9. 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 ) ); } }
  9. 10. Color Intensity <ul><li>Get a sample color (triggered by user input) </li></ul><ul><li>Iterate through all the pixels at desired rate </li></ul><ul><li>Determine color distance from sample </li></ul><ul><li>Track pixel position with least distance </li></ul><ul><li>Rotate sprite based on distance from center </li></ul>
  10. 11. Barcode Reader Computer Vision
  11. 12. <ul><li>Flash Player 9 and before (9.0.124) </li></ul><ul><ul><li>Policy file served independently </li></ul></ul><ul><ul><li>Sockets can connect to 1024 or higher </li></ul></ul><ul><li>Flash Player 10 and forward </li></ul><ul><ul><li>Port 843 or the specific destination port </li></ul></ul><ul><ul><li>Prevents DNS rebinding attacks </li></ul></ul><ul><li>Adobe AIR doesn’t care about policy files </li></ul>
  12. 14. Phidgets <ul><li>Plug and play USB prototyping </li></ul><ul><li>Numerous sensors as well as motor control </li></ul><ul><li>Support for multiple operating systems </li></ul><ul><li>Support for multiple languages (inc. AS3) </li></ul><ul><li>Phidgets service is a proxy socket server </li></ul><ul><li>AS3 library available for sensors and events </li></ul>
  13. 15. Some Types of Phidgets <ul><li>Infrared distance </li></ul><ul><li>Force </li></ul><ul><li>Motion </li></ul><ul><li>Temperature </li></ul><ul><li>Light </li></ul><ul><li>Sonar </li></ul><ul><li>Linear touch </li></ul><ul><li>Circular touch </li></ul><ul><li>Accelerometer </li></ul><ul><li>Ph </li></ul><ul><li>Thermocouple input </li></ul><ul><li>Encoder </li></ul>
  14. 16. 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; }
  15. 17. Inventory Manager Phidget Overload
  16. 19. WiiFlash <ul><li>Open source project by Thibault Imbert </li></ul><ul><li>Integrates Wii Remote and Flash via Bluetooth </li></ul><ul><li>Provides socket server for various OSs </li></ul><ul><li>Provides AS3 library for server interaction </li></ul><ul><li>Drives events for most Wii Remote changes </li></ul><ul><li>No support for sensor bar (really an emitter) </li></ul>
  17. 20. 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 ); }
  18. 21. Vision Revisited Event Charting
  19. 23. Arduino <ul><li>Open source prototyping platform </li></ul><ul><li>Primarily targeted at hobbyists </li></ul><ul><li>Processing/Wiring language/IDE </li></ul><ul><li>Can be connected to a PC or standalone </li></ul><ul><li>Purchasing pre-assembled costs about $65 </li></ul>
  20. 24. Sample Project <ul><li>Connect the board to your computer </li></ul><ul><li>Connect an LED to the board </li></ul><ul><li>Run the development environment </li></ul><ul><li>Write and upload a program to the board </li></ul><ul><li>Watch your Arduino go to work for you </li></ul><ul><li>Countless “shields” offer infinite possibilities </li></ul>
  21. 25. Flash Integration <ul><li>Install Firmata on the Arduino for serial access </li></ul><ul><li>Use serial proxy ( SerProxy ) to create a socket </li></ul><ul><li>Use a socket library to communicate out </li></ul><ul><li>Glue documented well by Protolab </li></ul>
  22. 26. With Flash Without Flash
  23. 27. Flash and Hardware Kevin Hoyt [email_address] Platform Evangelist Adobe Systems, Inc.
  24. 28. References <ul><li>Barcode Reader </li></ul><ul><li>Basic Computer Vision </li></ul><ul><li>Socket Policy Files </li></ul><ul><li>Phidgets </li></ul><ul><li>WiiFlash </li></ul><ul><li>Arduino </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×