Flash and Hardware

  • 1,561 views
Uploaded on

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,561
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
30
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Flash and Hardware Kevin Hoyt [email_address] Platform Evangelist Adobe Systems, Inc.
  • 2. Agenda
    • Why?
    • Web Camera
    • Socket Basics
    • Phidgets
    • WiiFlash
    • Arduino
  • 3.  
  • 4. 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!
  • 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 );
  • 6. 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
  • 7. 0 = 3211 1 = 2221 2 = 2122 3 = 1411 4 = 1132 5 = 1231 6 = 1114 7 = 1312 8 = 1213 9 = 3112
  • 8. 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
  • 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 ) ); } }
  • 10. 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
  • 11. Barcode Reader Computer Vision
  • 12.
    • 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
  • 13.  
  • 14. 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
  • 15. Some Types of Phidgets
    • Infrared distance
    • Force
    • Motion
    • Temperature
    • Light
    • Sonar
    • Linear touch
    • Circular touch
    • Accelerometer
    • Ph
    • Thermocouple input
    • Encoder
  • 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; }
  • 17. Inventory Manager Phidget Overload
  • 18.  
  • 19. 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)
  • 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 ); }
  • 21. Vision Revisited Event Charting
  • 22.  
  • 23. 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
  • 24. 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
  • 25. 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
  • 26. With Flash Without Flash
  • 27. Flash and Hardware Kevin Hoyt [email_address] Platform Evangelist Adobe Systems, Inc.
  • 28. References
    • Barcode Reader
    • Basic Computer Vision
    • Socket Policy Files
    • Phidgets
    • WiiFlash
    • Arduino