<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joshua Ho's Blog</title>
	<atom:link href="http://www.josh-ho.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.josh-ho.com/blog</link>
	<description>A Developer's Blog</description>
	<lastBuildDate>Thu, 09 Sep 2010 02:08:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>HTML 5 &#8211; Canvas</title>
		<link>http://www.josh-ho.com/blog/?p=314</link>
		<comments>http://www.josh-ho.com/blog/?p=314#comments</comments>
		<pubDate>Thu, 09 Sep 2010 02:08:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=314</guid>
		<description><![CDATA[HTML 5 brings a lot of new elements and tags and hands them to developers / designers to develop websites. Previously I wrote about the &#60;video> tag and how to create a video element and playing a video &#8211; Blog post can be found her. In this post, I&#8217;m going to explore the &#60;canvas> tag. [...]]]></description>
			<content:encoded><![CDATA[<p>HTML 5 brings a lot of new elements and tags and hands them to developers / designers to develop websites.  Previously I wrote about the &lt;video> tag and how to create a video element and playing a video &#8211; <a href="http://www.josh-ho.com/blog/?p=292">Blog post can be found her</a>.  In this post, I&#8217;m going to explore the &lt;canvas> tag.  The Canvas element is an HTML object that allows for dynamic objects to be rendered on a webpage.</p>
<p>We can start of an HTML 5 document as follows:<br />
<code><br />
&lt;!DOCTYPE HTML><br />
&lt;html><br />
&lt;head><br />
&lt;title>HTML 5 Canvas Tag Test&lt;/title><br />
&lt;/head><br />
&lt;body><br />
... code goes in here<br />
&lt;/body><br />
&lt;/html><br />
</code></p>
<p>To create the canvas tag we just call &lt;canvas>.  There are 3 important parameters that we can apply to the &lt;canvas> tag</p>
<table>
<tr>
<td width='150'>id
<td>
<td>assigns an identifer to the &lt;canvas> tag</td>
</tr>
<tr>
<td>width
<td>
<td>defines the width of the canvas tag</td>
</tr>
<tr>
<td>height
<td>
<td>defines the height of the canvas tag</td>
</tr>
</table>
<p>With that in mind we apply those properties on our tag as follows.  In this example we are going to designate the canvas as a 400&#215;400 pixel canvas.<br />
<code><br />
&lt;canvas id="myCanvas" width="400" height="400">&lt;/canvas><br />
</code></p>
<p>If we save everything and upload the file now, we would not see anything from our &lt;canvas> tag.  The only problem is, we did not assign anything to be rendered inside that canvas object and thus nothing is displayed.</p>
<p>In order to draw an object we can use javascript to draw a box inside of our object.  In our case we want to draw a 200&#215;200 pixel red box inside our canvas object.<br />
<code><br />
&lt;script><br />
var canvas = document.getElementById('myCanvas');<br />
var canvasContext = canvas.getContext("2d");<br />
canvasContext.fillStyle="#FF0000";<br />
canvasContext.fillRect(0,0,200,200);<br />
&lt;/script><br />
</code></p>
<p>What we have done is accessed the canvas tag and applied the getContext object on the canvas.  getContext() is a built in HTML 5 object that can create objects inside the canvas.  We apply the getContext() in our canvasContext variable and with that we can assign the colour &#8211; fillStyle; red (#FF0000), and what object to draw &#8211; fillRect; (x, y, width, height &#8211; 0, 0, 200, 200).  If we want to move the rectangle we can adjust the x and y values in the fillRect, which would change the x and y location of the red box we have just created.</p>
<p>That is it, we now can draw on our canvas using HTML 5 and Javascript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=314</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML 5 &#8211; Video Tag</title>
		<link>http://www.josh-ho.com/blog/?p=292</link>
		<comments>http://www.josh-ho.com/blog/?p=292#comments</comments>
		<pubDate>Sat, 04 Sep 2010 16:06:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=292</guid>
		<description><![CDATA[The W3C &#8211; The World Wide Web Consortium has started updating the HTML standard for displaying objects on the web. They are the ones that define how HTML tags should work. With HTML 5, the W3C is starting to move away from the reliance on plugins to play video or audio objects, while also creating [...]]]></description>
			<content:encoded><![CDATA[<p>The W3C &#8211; The World Wide Web Consortium has started updating the HTML standard for displaying objects on the web.  They are the ones that define how HTML tags should work.  With HTML 5, the W3C is starting to move away from the reliance on plugins to play video or audio objects, while also creating new HTML tags that are commonly used on websites &#8211; such as footers, or navigation.  More importantly, HTML 5 came out with new API&#8217;s that are available for use.</p>
<p>In this example we will take a look at one of the new tags &#8211; video.  And use the new API&#8217;s defined in HTML 5 to play / pause the video.</p>
<p>Creating an HTML 5 document is not hard. It is the same as creating the HTML 4 standard.<br />
<code><br />
&lt;!DOCTYPE HTML><br />
&lt;html><br />
&lt;head><br />
&lt;title>HTML 5 Video Tag Test&lt;/title><br />
&lt;/head><br />
&lt;body><br />
... code goes in here<br />
&lt;/body><br />
&lt;/html><br />
</code></p>
<p>Now we want to add the video tag.  According to the W3C &#8211; <a href="http://dev.w3.org/html5/spec/Overview.html#video" onclick="pageTracker._trackPageview('/outgoing/dev.w3.org/html5/spec/Overview.html_video?referer=');">http://dev.w3.org/html5/spec/Overview.html#video</a> we can define a video tag by using &lt;video&gt;.  There are some attributes that we can use to define the video tag:</p>
<table>
<tr>
<td width='150'>src
<td>
<td>defines the video source</td>
</tr>
<tr>
<td>width and height
<td>
<td>defines the width and height of the video object</td>
</tr>
<tr>
<td>loop
<td>
<td>allows the video object to loop at the end of the video</td>
</tr>
<tr>
<td>autoplay
<td>
<td>defines if the video should play once the video tag has been loaded</td>
</tr>
<tr>
<td>controls
<td>
<td>defines if the video controls should be displayed</td>
</tr>
<tr>
<td>preload
<td>
<td>defines if the video should preload the file when the website loads</td>
</tr>
</table>
<p>In our example we want to use the src and the controls so we can start and stop playing.  To do so we have to include the video tag in our code.  We must define controls as &#8220;controls&#8221; so that the browser would display the basic, play / pause buttons.<br />
<code><br />
&lt;video controls="controls" src="myvideo.ogg"><br />
 your browser does not support the video tag<br />
&lt;/video><br />
</code></p>
<p>As you can see I have a simple copy inside the video tag that claims that the user&#8217;s browser does not support the video tag.  With HTML 5 still being worked on, not all browsers can view the HTML 5 standard.  As a result, those browsers would not be able to render the video tag.  Instead they would see the copy &#8220;your browser does not support the video tag&#8221;.</p>
<p>Also note, because HTML 5 has not been fully standardized yet, the video tag is still up in the air.  Different browsers can only play different video types.  Firefox and Opera browsers can play .ogg files &#8211; more commonly known as Ogg Vorbis, while Safari can play H264 videos.  Chrome can play both ogg and H264 files.  The debate on which video files to play is still underway.  Ogg Vorbis is open source while H264 is not.  However since the video tag has not been fully standardized yet, this debate still continues.</p>
<p>In our case we are going with the .ogg format.  Now if you are on a Safari browser, you can change the src to a .mp4 file format, which uses the H264 video.</p>
<p>Now we do not need to use the browser&#8217;s controls to play / pause the video.  We can use the HTML 5 Video API for that.</p>
<p>We can add a couple of anchor tags to our code so we can play or pause the video.</p>
<p><code><br />
&lt;a href="#" onClick="myControlFunction('play');">Play&lt;/a><br />
&lt;a href="#" onClick="myControlFunction('pause');">Pause&lt;/a><br />
</code></p>
<p>We can use javascript to control the video tag and use the HTML 5 Video API.  According to the W3C we can tell the video object to play and pause by using the play() and pause() methods.</p>
<p><code><br />
&lt;script><br />
function myControlFunction(videoSelect){<br />
&nbsp;&nbsp;var video = document.querySelector('video');<br />
&nbsp;&nbsp;if( videoSelect == "play" ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;video.play();<br />
&nbsp;&nbsp;} else if( videoSelect == "pause" ){<br />
&nbsp;&nbsp;&nbsp;&nbsp;video.pause();<br />
&nbsp;&nbsp;}<br />
}<br />
&lt;/script><br />
</code></p>
<p>What this code does is that it searches for the video tag and sets it in the variable I designated called &#8220;video&#8221;.  With the object in my &#8220;video&#8221; variable, I can use the Video API methods of play() and pause(), to play or pause the video.  I passed in a small variable into my function which would tell me which button was pressed.  If the play button was pressed, I want the video to play and vice versa.</p>
<p>And there we have it, a simple play pause video demo using HTML 5 and the Video HTML 5 API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=292</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Seize The Summer with Molson Canadian</title>
		<link>http://www.josh-ho.com/blog/?p=279</link>
		<comments>http://www.josh-ho.com/blog/?p=279#comments</comments>
		<pubDate>Sat, 10 Jul 2010 19:18:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=279</guid>
		<description><![CDATA[The summer is here and we have lunched a new Facebook application with Molson Canadian. It is a pretty neat application where people can earn badges for doing things the love and eventually win prizes for doing those things. I am pretty excited for this application, it is a very fun application. We utilized the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.josh-ho.com/blog/Images/sts.jpg" alt="Molson Canadian Seize The Summer" /></p>
<p>The summer is here and we have lunched a new Facebook application with Molson Canadian.  It is a pretty neat application where people can earn badges for doing things the love and eventually win prizes for doing those things.  I am pretty excited for this application, it is a very fun application.  We utilized the Facebook API fully and integrated with our own customized API to produce a Facebook application we are happy to showcase.</p>
<p>Check it out</p>
<p><a href="http://apps.facebook.com/seizethesummer" onclick="pageTracker._trackPageview('/outgoing/apps.facebook.com/seizethesummer?referer=');">Molson Canadian Seize The Summer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=279</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NXNEi</title>
		<link>http://www.josh-ho.com/blog/?p=281</link>
		<comments>http://www.josh-ho.com/blog/?p=281#comments</comments>
		<pubDate>Wed, 16 Jun 2010 19:23:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[New Media]]></category>
		<category><![CDATA[NXNEi]]></category>
		<category><![CDATA[presentations]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=281</guid>
		<description><![CDATA[[youtube]http://www.youtube.com/watch?v=Mk1xjbA-ISE[/youtube]I have just returned from North by Northeast interactive (NXNEi). It is the sister event to South by Southwest. I was very impressed with all of the presentations, I learned quite a lot and it has helped me understand where developers, creative thinkers and everyone believes technology would continue. It is a breath of fresh [...]]]></description>
			<content:encoded><![CDATA[<p>[youtube]http://www.youtube.com/watch?v=Mk1xjbA-ISE[/youtube]I have just returned from North by Northeast interactive (NXNEi).  It is the sister event to South by Southwest.  I was very impressed with all of the presentations, I learned quite a lot and it has helped me understand where developers, creative thinkers and everyone believes technology would continue.  It is a breath of fresh air for me I got to return back to my university days of studying new media concepts and it was very surreal to listen to speakers reflect on those concepts.  I got to meet some very interesting people and get to talk to them and I really thought that was cool.</p>
<p>One of my favourite presentations was by Zachary Lieberman and The Intersection of Interaction, Play, Humor and Design.  Zach is one of the best new media artists that I have ever seen.  He was the developer to openFrameworks (<a href="http://www.openframeworks.cc/" onclick="pageTracker._trackPageview('/outgoing/www.openframeworks.cc/?referer=');">http://www.openframeworks.cc/</a>) an open source toolkit where &#8220;creativity&#8221; drives the final product.  Some of his works can be seen around the world and he has received many awards for the works that he has done.  In his presentation we saw many of his works including the Augmented Reality Magic &#8211; an art piece that uses Augmented Reality as a means to show magic tricks from the eye of the magician and his EyeWriter Initiative &#8211; where he developed the tools that could track the user&#8217;s eye and have a pen write according to the user&#8217;s eye movements.  I was very impressed with all of his works and definitely look forward to seeing more of his work in the future.</p>
<p>You can see some of his work here:<br />
<a href="http://thesystemis.com/" onclick="pageTracker._trackPageview('/outgoing/thesystemis.com/?referer=');">http://thesystemis.com/</a><br />
[youtube]http://www.youtube.com/watch?v=Mk1xjbA-ISE[/youtube]</p>
<p>Another presentation I was impressed with was Thought-Controlled Everything by Trevor Coleman.  Trevor is from InteraXon a thought-controlled computing.  InteraXon develops devices that could pick up brain waves which would affect how the user would interact the device.  Trevor displayed videos showing people being able to play musical instruments that could be played through thought.  I was amazed at the advancement of interactive technologies and how people were able to harness the invisible to affect the real world.  With continued advancements in thought processing I can see this type of technology aiding people which I think is a really good cause.  I definitely want to keep my eye to wait and see what InteraXon and how the technology develops.</p>
<p>You can see some of InteraXon&#8217;s work here:<br />
<a href="http://www.interaxon.ca/" onclick="pageTracker._trackPageview('/outgoing/www.interaxon.ca/?referer=');">http://www.interaxon.ca/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=281</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dentyne Action Packs &#8211; Cool AR</title>
		<link>http://www.josh-ho.com/blog/?p=276</link>
		<comments>http://www.josh-ho.com/blog/?p=276#comments</comments>
		<pubDate>Mon, 05 Apr 2010 17:00:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=276</guid>
		<description><![CDATA[Dentyne Action Pack After months of hard work I have been working with Aesthetec Inc to launch the Dentyne Action Pack &#8211; an AR makeout contest. We used Augmented Reality markers and place them on the back of Dentyne Ice packs. Users can use these packs in order to choose to make out with virtual [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dentyne.ca/" onclick="pageTracker._trackPageview('/outgoing/www.dentyne.ca/?referer=');">Dentyne Action Pack</a></p>
<p>After months of hard work I have been working with Aesthetec Inc to launch the Dentyne Action Pack &#8211; an AR makeout contest.  We used Augmented Reality markers and place them on the back of Dentyne Ice packs.  Users can use these packs in order to choose to make out with virtual characters.  You can record your session and have lots of fun with it.</p>
<p>This was a project where we had lots of fun, definitely check out the website and have some fun with AR.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=276</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixel Bender Basic Pixel Manipulation Tutorial</title>
		<link>http://www.josh-ho.com/blog/?p=267</link>
		<comments>http://www.josh-ho.com/blog/?p=267#comments</comments>
		<pubDate>Sat, 20 Mar 2010 18:43:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=267</guid>
		<description><![CDATA[So I dove into Pixel Bender in my previous post ( see Pixel Bender ). What we will dive into in this tutorial are basics in variables and hardcore pixel manipulation. When you open Pixel Bender, a lot of basics are already filled out for you, this is known as the Kernal Syntax. The first [...]]]></description>
			<content:encoded><![CDATA[<p>So I dove into Pixel Bender in my previous post ( see <a href="http://www.josh-ho.com/blog/?p=259">Pixel Bender</a> ).  </p>
<p>What we will dive into in this tutorial are basics in variables and hardcore pixel manipulation.</p>
<p>When you open Pixel Bender, a lot of basics are already filled out for you, this is known as the Kernal Syntax.</p>
<p>The first portion is the information about the Kernal&#8217;s metadata:<br />
<code><br />
<languageVersion : 1.0;></p>
<p>kernel NewFilter<br />
<   namespace : "Your Namespace";<br />
    vendor : "Joshua";<br />
    version : 1;<br />
    description : "My First Basic Pixel Bender Manipulation Filter";<br />
><br />
</code></p>
<p>You can indicate in the kernal a set of name value metadata for your Pixel Bender Filter.  In our case we can just the name and description of what we are doing.</p>
<p>The second part of the Pixel Bender Kernal is where all of our code is declared.  When you start a new Pixel Bender Kernal Filter it looks like this<br />
<code><br />
{<br />
    input image4 src;<br />
    output pixel4 dst;</p>
<p>    void<br />
    evaluatePixel()<br />
    {<br />
        dst = sampleNearest(src,outCoord());<br />
    }<br />
}<br />
</code></p>
<p>With Pixel Bender, we need to indicate a source, and in this case we are loading an image and storing the image in a variable called src.  We are typing the variable as an image4.  An image4 type indicates that this image would contain the 4 different types of pixel colour values ( Red, Green, Blue, Alpha ).  We also have an output called dst which returns our manipulated pixels ( again using the 4 different types of pixel colour values ) so we can view the manipulated image.  We have a function called evaluatePixel which runs through all of the pixels and where we can manipulate the data accordingly.</p>
<p>If we load an image( Select File > Load Image 1 &#8211; or press ctrl + 1 / command + 1 ).  And hit run, at the bottom right corner.  We have our first running Pixel Bender Filter.  It currently does nothing, but load the image.</p>
<p>Now let&#8217;s manipulate some colour.  Say I want to adjust the red in the photo.  Lets add this code.<br />
<code><br />
pixel4 pix = sampleNearest( src, outCoord() );<br />
pix *= pixel4( 2, 1, 1, 1 ); //R, G, B, A<br />
dst = pix;<br />
</code></p>
<p>What we have done is taken each pixel and multiplied the red value by 2.  I have stored each pixel in a variable called pix, and I multiplied the red value by 2.  I set the output dst to my variable pix and now we have an image that has the red&#8217;s more prominent.  This is just a static example, now we want to dynamically adjust these values to our own discretion.  What we would need to do is create a parameter.</p>
<p><code><br />
    parameter float red<br />
    <<br />
        maxValue: float( 5 );<br />
        minValue: float( 0 );<br />
        defaultValue: float( 1 );<br />
    >;</p>
<p>    parameter float green<br />
    <<br />
        maxValue: float( 5 );<br />
        minValue: float( 0 );<br />
        defaultValue: float( 1 );<br />
    >;</p>
<p>    parameter float blue<br />
    <<br />
        maxValue: float( 5 );<br />
        minValue: float( 0 );<br />
        defaultValue: float( 1 );<br />
    >;</p>
<p>    parameter float alpha<br />
    <<br />
        maxValue: float( 1 );<br />
        minValue: float( 0 );<br />
        defaultValue: float( 1 );<br />
    >;<br />
</code></p>
<p>These are 4 parameters that we can now adjust.  We are proving each parameter with a set of rules &#8211; a maxmium value, a minmium value and a default value.  We need to make one adjustment to our evaluatePixel() and we should be good to go.</p>
<p><code><br />
pixel4 pix = sampleNearest( src, outCoord() );<br />
pix *= pixel4( red, green, blue, alpha ); //R, G, B, A<br />
dst = pix;<br />
</code></p>
<p>Now we have variables tied to the red, green, blue, and alpha channels. The cool thing about pixel bender is that it can be exported and loaded into AS3 &#8211; Min requirements: Flash player 10.  Adobe created 2 special classes that tie in with Pixel Bender &#8211; Shader (<a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Shader.html" onclick="pageTracker._trackPageview('/outgoing/help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Shader.html?referer=');">http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Shader.html</a>) and ShaderFilter (<a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/filters/ShaderFilter.html" onclick="pageTracker._trackPageview('/outgoing/help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/filters/ShaderFilter.html?referer=');">http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/filters/ShaderFilter.html</a>).  </p>
<p>Pixel Bender files can be loaded with URLLoaders.  Once the pixel bender is loaded, you can cast the data as a Shader Class.  Shader&#8217;s can access the variables inside of Pixel Bender and adjust the values.  Once the values are adjusted you can load the shader through a ShaderFilter filter and apply that on any DisplayObjects to view your result.</p>
<p>Below is a quick example of applying the above pixel bender filter onto a webcam feed and adjust the Red in the webcam feed.<br />
<code><br />
private var video:Video;<br />
var camera:Camera;<br />
video = new Video( 320, 240 );<br />
var i:uint = Camera.names.length;<br />
while ( i-- ) {<br />
    if ( Camera.names[i] == "USB Video Class Video" ) {<br />
	break;<br />
    }<br />
}</p>
<p>if ( i == uint.MAX_VALUE ) {<br />
   camera = Camera.getCamera();<br />
} else {<br />
   camera = Camera.getCamera( i.toString() );<br />
}</p>
<p>camera.setMode( 320, 240, 30 );<br />
video.attachCamera( camera );</p>
<p>var loader:URLLoader = new URLLoader( new URLRequest( "MyPixelBender.pbj" ) );<br />
loader.dataFormat = URLLoaderDataFormat.BINARY;<br />
loader.addEventListener( Event.COMPLETE, loadShader );</p>
<p>private function loadShader( evt:Event ):void {<br />
var shader:Shader = new Shader( evt.target.data );<br />
shader.data.red.value = [0.5];<br />
var shaderFilter:ShaderFilter = new ShaderFilter( shader );<br />
video.filters = [shaderFilter];<br />
addChild( video );<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=267</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixel Bender</title>
		<link>http://www.josh-ho.com/blog/?p=259</link>
		<comments>http://www.josh-ho.com/blog/?p=259#comments</comments>
		<pubDate>Thu, 18 Feb 2010 03:11:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=259</guid>
		<description><![CDATA[Pixel Bender (formerly known by its codename: Hydra) is an image processing algorithm that optimizes image and video processing. In other words, it is a really useful tool to process image and video without killing performance. I&#8217;ve had a chance to sit down and play with the IDE. Pixel Bender&#8217;s syntax is based on OpenGL [...]]]></description>
			<content:encoded><![CDATA[<p>Pixel Bender (formerly known by its codename: Hydra) is an image processing algorithm that optimizes image and video processing.  In other words, it is a really useful tool to process image and video without killing performance.</p>
<p>I&#8217;ve had a chance to sit down and play with the IDE. Pixel Bender&#8217;s syntax is based on OpenGL Shading Language (GLSL).  It is quite different than working with AS3.</p>
<p>Pixel Bender code example:<br />
<code><br />
kernel NewFilter<br />
<   namespace : "Your Namespace";<br />
    vendor : "Joshua";<br />
    version : 1;<br />
    description : "Text Pixel Bender";<br />
><br />
{<br />
    input image4 src;<br />
    output pixel4 dst;<br />
    parameter float testInputValue<<br />
     minValue: float( 1 );<br />
        maxValue: float( 100 );<br />
        defaultValue: float( 1 );<br />
    >;<br />
void evaluatePixel() {<br />
    //code goes here<br />
}<br />
</code></p>
<p>Where as AS3 looks like:<br />
<code><br />
package<br />
{<br />
//@author Joshua Ho<br />
public class MyClass {<br />
  public function MyClass() {<br />
     //code goes here<br />
  }<br />
}<br />
</code></p>
<p>Now this is just a semiotic difference.  The real importance is how both these two languages can work together and really make some pretty cool projects come to life.<br />
Below is an example :<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_PixelBender_1154754923"
			class="flashmovie"
			width="320"
			height="240">
	<param name="movie" value="http://www.josh-ho.com/labs/pixelbender/PixelBender.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.josh-ho.com/labs/pixelbender/PixelBender.swf"
			name="fm_PixelBender_1154754923"
			width="320"
			height="240">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer" onclick="pageTracker._trackPageview('/outgoing/adobe.com/go/getflashplayer?referer=');pageTracker._trackPageview('/outgoing/adobe.com/go/getflashplayer?referer=http%3A%2F%2Fwww.josh-ho.com%2Fblog%2Fwp-admin%2Fpost-new.php');"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>This is a webcam feed that pixelates based off my Pixel Bender file.  Now this type of pixelation can be done via actionscript.  However the performance using Pixel Bender is not hindered when applying a pixelate filter.  Normally with actionscript all of the processing is done by the CPU, the greater the data the more calculations the CPU has to make, thus slowing down the flash application.  In an application like this, the flash application would drop framerate (see the top right corner for framerate values).  By using Pixel Bender we can have the image and video processing done by the GPU, allowing the CPU to focus on the webcam feed and thus an increase in performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=259</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &amp; Twitter API &#8211; Pooling data into a service</title>
		<link>http://www.josh-ho.com/blog/?p=250</link>
		<comments>http://www.josh-ho.com/blog/?p=250#comments</comments>
		<pubDate>Thu, 11 Feb 2010 02:20:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pool Data]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=250</guid>
		<description><![CDATA[Source: http://apiwiki.twitter.com/ The Twitter API is a tool for developers to gain access to Twitter&#8217;s core data in order to build useful applications involving Twitter. It is quite neat to be able to access live data and be able to visualize the tweets of the world (or trends) or be able to pool live data [...]]]></description>
			<content:encoded><![CDATA[<p>Source: <a href="http://apiwiki.twitter.com/" onclick="pageTracker._trackPageview('/outgoing/apiwiki.twitter.com/?referer=');">http://apiwiki.twitter.com/</a></p>
<p>The Twitter API is a tool for developers to gain access to Twitter&#8217;s core data in order to build useful applications involving Twitter.</p>
<p>It is quite neat to be able to access live data and be able to visualize the tweets of the world (or trends) or be able to pool live data and stream it through one service.  This post is just to show the simplicity, but provides developers the tools necessary to build out a really neat application.</p>
<p><strong>Goal:</strong><br />
To pool data (Finding and populating all data using the trend test &#8211; #test) into a single Twitter account.</p>
<p>Twitter has many different wrappers for their API;  you can find a full list here. (<a href="http://apiwiki.twitter.com/Libraries" onclick="pageTracker._trackPageview('/outgoing/apiwiki.twitter.com/Libraries?referer=');">http://apiwiki.twitter.com/Libraries</a>).  We can use a wide variety of languages, but for this exercise we are using PHP.</p>
<p>The API that I am using is the Twitter class by Tijs Verkoyen &#8211; (you can download the API at:<a href="http://classes.verkoyen.eu/twitter/" onclick="pageTracker._trackPageview('/outgoing/classes.verkoyen.eu/twitter/?referer=');">http://classes.verkoyen.eu/twitter/</a>).  I found the documentation really helpful and provides me with all of the calls that are needed for this example.</p>
<p>The first step is to figure out how to post to twitter using the API.:<br />
<code><br />
<?php<br />
  include "twitter.php";<br />
  $twitter = new Twitter("username","password"); //replace username and password with your account's username and password;<br />
  $userText = "Testing Twitter API";<br />
  $twitter ->updateStatus($userText );<br />
?><br />
</code></p>
<p>If we run this, you can see in your Twitter account that you have just updated your status to say &#8220;Testing Twitter API&#8221;.  Now you can pass in more parameters such as links or other Twitter accounts and Twitter will automatically provide links where necessary.</p>
<p>So now we are half way there; the next step we need to look at is to pool in all of the data.  In our example we want to pool in all information related to the trend #test.  Now this can be whatever you want.  I am using the Twitter search to return the results I want.  Now the Twitter search returns results as an ATOM RSS feed.  We need to parse the RSS feed so that we can extract the core data.  In this case I recommend an Atom Feed reader (<a href="http://www.the-art-of-web.com/php/atom/#source" onclick="pageTracker._trackPageview('/outgoing/www.the-art-of-web.com/php/atom/_source?referer=');">http://www.the-art-of-web.com/php/atom/#source</a>).  We can extract the search results for #test.</p>
<p><code><br />
<?PHP<br />
  include "atomparser.php";<br />
  $url = "http://search.twitter.com/search.atom?q=%23test";<br />
  $atom_parser = new myAtomParser($url);<br />
  $output .= $atom_parser->getOutput();<br />
  echo $output;<br />
?><br />
</code></p>
<p>We now have the code to read in the Twitter RSS feed and parsed all of the information.  However we now have too much information, all we want is what people tweeted and post that.  I found it easier to go through the Atom parser and comment out all of the unnecessary data.  I added a line break (&#8220;<br/>&#8221; ) to indicate every new post visually.  I can break all of the line breaks and push them into an array for me to loop through and push those results to Twitter.</p>
<p>Now that we have both parts of the code we need to combine the two code so that we can post onto Twitter from the results we were given from the RSS feed.</p>
<p><code><br />
<?php<br />
  include "twitter.php";<br />
  include "myatomparser.php";<br />
  //load in the RSS<br />
  $url = "http://search.twitter.com/search.atom?q=%23test";<br />
  $post_to_Twitter = new array();<br />
  $atom_parser = new myAtomParser($url);<br />
  $output .= $atom_parser->getOutput();<br />
  // initialize twitter<br />
  $twitter = new Twitter("username","password"); //replace username and password with your account's username and password;<br />
  //$userText = "Testing Twitter API"; //not necessary anymore we are posting from the results that we were given from the RSS feed.<br />
  $post_to_Twitter = explode( "<br/>", $output );<br />
  foreach( $post_to_Twitter as $me ) {<br />
	  echo $me;<br />
	  $user_text = $me;<br />
          sleep(1);<br />
  }<br />
  $twitter ->updateStatus($userText );<br />
?><br />
</code></p>
<p>I added a delay &#8211; sleep(), to allow the Twitter API receive each result post, then receive the next result. And that is it we have now developed a small piece of code that grabs the data from the Twitter search results and post it onto your twitter status update.</p>
<p>enjoy.</p>
<p>P.S if you need help with the commenting part, you can download my version of the atom parser here( ).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=250</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 Mac FileReference Type workaround</title>
		<link>http://www.josh-ho.com/blog/?p=243</link>
		<comments>http://www.josh-ho.com/blog/?p=243#comments</comments>
		<pubDate>Wed, 18 Nov 2009 01:53:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=243</guid>
		<description><![CDATA[Today I was in a conundrum. I was working on an upload script in AS3 that checks the file type and uploads it to a server. I had a problem with the FileReference class and Mac&#8217;s. (on Windows it was ok, but Mac&#8217;s did not work). According to the Actionscript 3 docs, all I need [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was in a conundrum.  I was working on an upload script in AS3 that checks the file type and uploads it to a server.  I had a problem with the FileReference class and Mac&#8217;s.  (on Windows it was ok, but Mac&#8217;s did not work).  According to the Actionscript 3 docs, all I need to do to check the type of a file is call the property type. ( see documentation: <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/FileReference.html" onclick="pageTracker._trackPageview('/outgoing/livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/FileReference.html?referer=');">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/FileReference.html</a>)</p>
<p>Normally the code would look like this:</p>
<p><code><br />
var file:FileReference = new FileReference();<br />
trace( file.type ); //where file.type would return the file type.<br />
</code></p>
<p>On a Mac machine, file.type returns null.  However file.name returns the file name as it is supposed to.  I could not find any real solutions, but instead just wrote a workaround class for this.</p>
<p><code><br />
public static function extractFileType(fileName:String):String {<br />
  var extensionIndex:Number = fileName.lastIndexOf(".");<br />
  if (extensionIndex == -1) {<br />
    return "";<br />
  } else {<br />
    return "." + fileName.substr(extensionIndex + 1,fileName.length);<br />
  }<br />
}<br />
</code></p>
<p>What this function does takes the file name and searches for the &#8220;.&#8221; and grabs the remaining characters returning the characters as a string.  This imitates FileReference type property where it returns the file type as a string.</p>
<p>I have uploaded my simple class that can be downloaded here:<br />
<a href="http://www.josh-ho.com/blog/Files/FileReferenceType.zip">http://www.josh-ho.com/blog/Files/FileReferenceType.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=243</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Face Recognition &#8211; AS3 Update</title>
		<link>http://www.josh-ho.com/blog/?p=230</link>
		<comments>http://www.josh-ho.com/blog/?p=230#comments</comments>
		<pubDate>Fri, 13 Nov 2009 03:24:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Preview]]></category>
		<category><![CDATA[Thesis]]></category>

		<guid isPermaLink="false">http://www.josh-ho.com/blog/?p=230</guid>
		<description><![CDATA[Hello I am back again. Here is an update to my Face Recognition progress. As you can see, I have gotten basic face recognition under way. Performance wise, I have a lot to improve on and I have a long way to go. But I am making progress &#8211; one small triumph at a time [...]]]></description>
			<content:encoded><![CDATA[<p>Hello I am back again.</p>
<p>Here is an update to my Face Recognition progress.</p>
<p><img src="http://www.josh-ho.com/blog/Images/facerecognition.jpg" alt="Face Recognition Image 1" /></p>
<p>As you can see, I have gotten basic face recognition under way.  Performance wise, I have a lot to improve on and I have a long way to go.  But I am making progress &#8211; one small triumph at a time <img src='http://www.josh-ho.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  I am using a Microsoft Xbox Live Camera, which pumps out great framerates at 640&#215;480.  I used the same camera for my Thesis project last year with the multitouch table.  I might switch over to the PS Eye, which I heard can pump out greater framerates at 640&#215;480.</p>
<p>I have setup an alpha test of my face recognition.  Check it out<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_face_888969013"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="http://www.josh-ho.com/labs/facereco/face.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.josh-ho.com/labs/facereco/face.swf"
			name="fm_face_888969013"
			width="400"
			height="300">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer" onclick="pageTracker._trackPageview('/outgoing/adobe.com/go/getflashplayer?referer=');pageTracker._trackPageview('/outgoing/adobe.com/go/getflashplayer?referer=http://www.josh-ho.com/blog/wp-admin/post-new.php');"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.josh-ho.com/blog/?feed=rss2&amp;p=230</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
