{"id":1694,"date":"2009-12-03T13:56:02","date_gmt":"2009-12-03T18:56:02","guid":{"rendered":"http:\/\/www.walking-productions.com\/notslop\/2009\/12\/03\/simple-flash-video-by-the-pixel\/"},"modified":"2009-12-10T13:05:36","modified_gmt":"2009-12-10T18:05:36","slug":"simple-flash-video-by-the-pixel","status":"publish","type":"post","link":"https:\/\/www.walking-productions.com\/notslop\/2009\/12\/03\/simple-flash-video-by-the-pixel\/","title":{"rendered":"Simple Flash Video By The Pixel"},"content":{"rendered":"<pre>\r\npackage\r\n{\r\n\timport flash.display.Sprite;\r\n\timport flash.media.Camera;\r\n\timport flash.media.Video;\r\n\timport flash.display.Bitmap;\r\n\timport flash.display.BitmapData;\r\n\timport flash.utils.ByteArray;\r\n  \timport flash.events.Event;\r\n\timport flash.utils.Timer;\r\n\timport flash.events.TimerEvent;\r\n\r\n\tpublic class VideoProcessing extends Sprite\r\n\t{\r\n\t\t\/\/ Camera\r\n        private var camera:Camera;\r\n\r\n        \/\/ My Video\r\n        private var videoOut:Video; \r\n\r\n\t\t\/\/ My Bitmapdata\r\n\t\tprivate var bmpd:BitmapData;\r\n\t\t\r\n\t\t\/\/ Bitmap\r\n\t\tprivate var bmp:Bitmap;\r\n\t\t\r\n\t\tprivate var timer:Timer;\r\n\r\n        public function VideoProcessing()\r\n        {\r\n\t\t\ttrace(\"Starting\");\r\n\t\t\t\r\n\t\t\t\/\/ Setup the camera\r\n\t\t\tcamera = Camera.getCamera(); \r\n\r\n\t\t\t\/\/ Video components\r\n\t\t\tvideoOut = new Video();\r\n\r\n\t\t\t\/\/ Set positions\r\n\t\t\tvideoOut.x = 0;\r\n\t\t\tvideoOut.y = 0;\r\n\r\n\t\t\t\/\/ Attach camera to our video\r\n            videoOut.attachCamera(camera); \r\n\t\t\taddChild(videoOut);\r\n\t\t\t\r\n\t\t\t\/\/ Create the bitmapdata object\r\n        \tbmpd = new BitmapData(320,240);\r\n\t\t\t\r\n       \t\t\/\/ Create the bitmap image\r\n\t\t\tbmp = new Bitmap(bmpd);\r\n       \t\r\n\t       \t\/\/ Add it to the stage\r\n\t       \tbmp.x = 0;\r\n    \t   \tbmp.y = 240;\r\n       \t\taddChild(bmp);\t\t\t\r\n\t\t\t\r\n\t\t\t\/\/ Create timer\r\n\t\t\ttimer = new Timer(10,0);\r\n\t\t\ttimer.addEventListener(TimerEvent.TIMER, grabFrame);\r\n\t\t\ttimer.start();\r\n\r\n\t\t\ttrace(\"done starting\");\r\n\t\t\t\r\n\t\t} \r\n\r\n\r\n        private function grabFrame(e:TimerEvent):void \r\n        {\r\n\t\t\t\/\/trace(\"timer\");\r\n\t\t\t\r\n\t\t\t\/\/ Save the frame to the bitmapdata object\r\n\t\t\tbmpd.draw(videoOut);\r\n\r\n\t\t\t\/\/ Modify the bmpd\r\n\t\t\t\/\/http:\/\/itp.nyu.edu\/~dbo3\/cgi-bin\/ClassWiki.cgi?ICMVideo#removeStillBg\t\t\t\r\n    \t\tfor (var row:int=0; row&lt;bmpd.height; row=row+1) { \/\/for each row\r\n    \t\t\tfor(var col:int=0; col&lt;bmpd.width; col=col+1) { \/\/for each column\r\n\t\t\t      \t\/\/get the color of this pixels\r\n      \t\t\t\tvar pix:uint = bmpd.getPixel(col,row);\r\n\t\t\t\t\t\r\n\t\t\t\t\tvar red:int = pix &gt;&gt; 16;\r\n\t\t\t\t\tvar green:int = pix &gt;&gt; 8 &amp; 0xff;\r\n\t\t\t\t\tvar blue:int = pix &amp; 0xff\r\n\r\n\t\t\t\t\tif (red &gt; 50 && green &gt; 50 && blue &gt; 50)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbmpd.setPixel(col,row,0);\r\n\t\t\t\t    }\r\n\t\t\t\t}\r\n\t\t\t}\r\n    \t\r\n        }\r\n\t}\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>package { import flash.display.Sprite; import flash.media.Camera; import flash.media.Video; import flash.display.Bitmap; import flash.display.BitmapData; import flash.utils.ByteArray; import flash.events.Event; import flash.utils.Timer; import flash.events.TimerEvent; public class VideoProcessing extends Sprite { \/\/ Camera private var camera:Camera; \/\/ My Video private var videoOut:Video; \/\/ My Bitmapdata private var bmpd:BitmapData; \/\/ Bitmap private var bmp:Bitmap; private var timer:Timer; public function VideoProcessing() { &hellip; <a href=\"https:\/\/www.walking-productions.com\/notslop\/2009\/12\/03\/simple-flash-video-by-the-pixel\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Simple Flash Video By The Pixel<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[87],"class_list":["post-1694","post","type-post","status-publish","format-standard","hentry","category-thoughts","tag-code-as3-flash-video"],"_links":{"self":[{"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/posts\/1694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/comments?post=1694"}],"version-history":[{"count":1,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/posts\/1694\/revisions"}],"predecessor-version":[{"id":1697,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/posts\/1694\/revisions\/1697"}],"wp:attachment":[{"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/media?parent=1694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/categories?post=1694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.walking-productions.com\/notslop\/wp-json\/wp\/v2\/tags?post=1694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}