<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.1" -->
<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/"
	>

<channel>
	<title>labs.grinant.com</title>
	<link>http://labs.grinant.com</link>
	<description>Personal blog for testing purposes</description>
	<pubDate>Sat, 09 Aug 2008 16:42:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.1</generator>
	<language>en</language>
			<item>
		<title>Webcam 3D Cube Control</title>
		<link>http://labs.grinant.com/?p=10</link>
		<comments>http://labs.grinant.com/?p=10#comments</comments>
		<pubDate>Sat, 09 Aug 2008 16:15:43 +0000</pubDate>
		<dc:creator>Edgar Griñant</dc:creator>
		
	<category>AS3</category>
	<category>PaperVision3D</category>
	<category>Soulwire</category>
	<category>Webcam</category>
		<guid isPermaLink="false">http://labs.grinant.com/?p=10</guid>
		<description><![CDATA[Inspired by quasimodo&#8217;s minority cube I have tryed to make my own based on PaperVision3D (as 3D engine for the cube) and Soulwire (motion tracking). Here&#8217;s the result:






Note: You need a webcam to see this demo in action. Nothing is being recorded (no data is being sent to server).
A big difference between quasimodo&#8217;s and mine its [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a href="http://incubator.quasimondo.com/flash/minority_cube.php" target="_blank">quasimodo&#8217;s minority cube</a> I have tryed to make my own based on <a href="http://blog.papervision3d.org" target="_blank">PaperVision3D</a> (as 3D engine for the cube) and <a href="http://www.soulwire.co.uk" target="_blank">Soulwire</a> (motion tracking). Here&#8217;s the result:</p>
<p>
<object type="application/x-shockwave-flash" width="415" height="320">
<param name="movie" value="http://labs.grinant.com/uploads/2008/08/webcam_control.swf" />
<embed src="http://labs.grinant.com/uploads/2008/08/webcam_control.swf" type="application/x-shockwave-flash" width="415" height="320" >
</object>
</p>
<p><strong>Note: You need a webcam to see this demo in action. Nothing is being recorded (no data is being sent to server).</strong></p>
<p>A big difference between quasimodo&#8217;s and mine its that he can track your hand screwing (that&#8217;s really nice, so you can rotate all the axis). Another diference is that mine is Open Source <img src='/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Please respect the credits.</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p102');">[<span id="p102_symbol">+</span>]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p10code2'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr style="display:none" id="p102"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
</pre></td><td class="code" id="p10code2"><pre class="actionscript3"><span style="color: #3f5fbf;">/*
 * CREDITS
 * ¯¯¯¯¯¯¯
 * MAIN SOURCE:
 *  Author:  Edgar Griñant
 *  Website: labs.grinant.com
 *
 * SOULWIRE CLASS:
 * Author:  Justin Windle
 * Website: soulwire.co.uk
 *
 * PAPERVISION3D CLASSES:
 *  Author:  Carlos Ulloa
 *  Website: blog.papervision3d.org
 *
 * INSPIRED BY QUASIMODO'S MINORITY CUBE (incubator.quasimondo.com/flash/minority_cube.php)
 */</span>
&nbsp;
<span style="color: #9900cc; font-weight: bold;">package</span> 
<span style="color: #000000;">&#123;</span>
 <span style="color: #009900;">// FLASH CLASSES</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">Camera</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">Video</span>;
 <span style="color: #009900;">// SOULWIRE CLASS</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> com.soulwire.media.MotionTracker;
 <span style="color: #009900;">// PAPERVISION3D CLASSES</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.cameras.Camera3D;
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.primitives.Cube;
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.<span style="color: #004993;">render</span>.BasicRenderEngine;
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.<span style="color: #004993;">scenes</span>.Scene3D;
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.Viewport3D;
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.DisplayObject3D;
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.utils.MaterialsList;
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.core.proto.MaterialObject3D;
 <span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.BitmapFileMaterial;
 <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main extends <span style="color: #004993;">Sprite</span>
 <span style="color: #000000;">&#123;</span>
  <span style="color: #3f5fbf;">/*______________
   ||PRIVATE VARS||
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯*/</span>
  <span style="color: #009900;">// SOULWIRE</span>
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> motionTracker <span style="color: #000000; font-weight: bold;">:</span>MotionTracker;
  
  <span style="color: #009900;">// PAPERVISION</span>
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> viewport  <span style="color: #000000; font-weight: bold;">:</span>Viewport3D;
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> scene   <span style="color: #000000; font-weight: bold;">:</span>Scene3D;
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> camera   <span style="color: #000000; font-weight: bold;">:</span>Camera3D;
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cube   <span style="color: #000000; font-weight: bold;">:</span>Cube;
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> renderer  <span style="color: #000000; font-weight: bold;">:</span>BasicRenderEngine;
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> universe  <span style="color: #000000; font-weight: bold;">:</span>DisplayObject3D;
  
  <span style="color: #3f5fbf;">/*_____________
   ||CONSTRUCTOR||
    ¯¯¯¯¯¯¯¯¯¯¯¯¯*/</span>
  <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">// PAPERVISION3D ENVIRONMENT</span>
   init3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   createCube<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">// SOULWIRE MOTION TRACKING SETUP</span>
   soulwire<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">// EVENT HANDLER ON ENTER FRAME (TRACK, ROTATE THE CUBE THEN RENDER)</span>
   <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>, <span style="color: #004993;">track</span> <span style="color: #000000;">&#41;</span>;
  <span style="color: #000000;">&#125;</span>
  
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> soulwire<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">// All of these variables can be changed to get a more acurate motion tracking</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> camW<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">320</span>;
   <span style="color: #6699cc; font-weight: bold;">var</span> camH<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">240</span>;
   <span style="color: #6699cc; font-weight: bold;">var</span> blur<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">20</span>;
   <span style="color: #6699cc; font-weight: bold;">var</span> brightness<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">20</span>;
   <span style="color: #6699cc; font-weight: bold;">var</span> contrast<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">150</span>;
   <span style="color: #6699cc; font-weight: bold;">var</span> minArea<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">10</span>;
&nbsp;
   <span style="color: #009900;">// Create the camera</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> cam<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Camera</span> = <span style="color: #004993;">Camera</span>.<span style="color: #004993;">getCamera</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   cam.<span style="color: #004993;">setMode</span><span style="color: #000000;">&#40;</span> camW, camH, <span style="color: #004993;">stage</span>.<span style="color: #004993;">frameRate</span> <span style="color: #000000;">&#41;</span>;
   
   <span style="color: #009900;">// Create a video</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> vid<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Video</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Video</span><span style="color: #000000;">&#40;</span> camW, camH <span style="color: #000000;">&#41;</span>;
   vid.<span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span> cam <span style="color: #000000;">&#41;</span>;
   
   <span style="color: #009900;">// Create the Motion Tracker</span>
   motionTracker = <span style="color: #0033ff; font-weight: bold;">new</span> MotionTracker<span style="color: #000000;">&#40;</span> vid <span style="color: #000000;">&#41;</span>;
   
   <span style="color: #009900;">// We flip the input as we want a mirror image</span>
   motionTracker.flipInput = <span style="color: #0033ff; font-weight: bold;">true</span>;
   
   <span style="color: #009900;">// Apply some filters to ease the tracking</span>
   motionTracker.blur = blur;
   motionTracker.brightness = brightness;
   motionTracker.contrast = contrast;
   motionTracker.minArea = minArea;
  <span style="color: #000000;">&#125;</span>
  
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">track</span><span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">// Tell the MotionTracker to update itself</span>
   motionTracker.<span style="color: #004993;">track</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   
   <span style="color: #009900;">// Rotate the cube</span>
   cube.rotationY <span style="color: #000000; font-weight: bold;">-</span>= <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>motionTracker.<span style="color: #004993;">x</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> cube.rotationY<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">20</span>;
   cube.rotationX <span style="color: #000000; font-weight: bold;">-</span>= <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>motionTracker.<span style="color: #004993;">y</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> cube.rotationX<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">20</span>;
   
   <span style="color: #009900;">// Render the scene</span>
   renderer.renderScene<span style="color: #000000;">&#40;</span>scene, camera, viewport<span style="color: #000000;">&#41;</span>;
  <span style="color: #000000;">&#125;</span>
  
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> init3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">// VIEWPORT</span>
   viewport = <span style="color: #0033ff; font-weight: bold;">new</span> Viewport3D<span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> viewport <span style="color: #000000;">&#41;</span>;
&nbsp;
   <span style="color: #009900;">// RENDERER</span>
   renderer = <span style="color: #0033ff; font-weight: bold;">new</span> BasicRenderEngine<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
   <span style="color: #009900;">// SCENE</span>
   scene = <span style="color: #0033ff; font-weight: bold;">new</span> Scene3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
   <span style="color: #009900;">// CAMERA</span>
   camera = <span style="color: #0033ff; font-weight: bold;">new</span> Camera3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   camera.z = <span style="color: #000000; font-weight:bold;">-1000</span>;
   
   <span style="color: #009900;">// UNIVERSE</span>
   universe = <span style="color: #0033ff; font-weight: bold;">new</span> DisplayObject3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   scene.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>universe<span style="color: #000000;">&#41;</span>;
  <span style="color: #000000;">&#125;</span>
  
  <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createCube<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">// Set the textures</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> materials<span style="color: #000000; font-weight: bold;">:</span>MaterialsList = <span style="color: #0033ff; font-weight: bold;">new</span> MaterialsList<span style="color: #000000;">&#40;</span>
   <span style="color: #000000;">&#123;</span>
    all<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapFileMaterial<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;&lt;a href=&quot;</span>http<span style="color: #000000; font-weight: bold;">:</span><span style="color: #009900;">//labs.grinant.com/uploads/2008/08/cube.png&quot;&gt;http://labs.grinant.com/uploads/2008/08/cube.png&lt;/a&gt;&quot;)</span>
   <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">// Create the cube</span>
   cube = <span style="color: #0033ff; font-weight: bold;">new</span> Cube<span style="color: #000000;">&#40;</span>materials<span style="color: #000000;">&#41;</span>;
   universe.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>cube<span style="color: #000000;">&#41;</span>;
  <span style="color: #000000;">&#125;</span>
  
 <span style="color: #000000;">&#125;</span>
 
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRSS>http://labs.grinant.com/?feed=rss2&amp;p=10</wfw:commentRSS>
		</item>
		<item>
		<title>Webcam Glowing Edges</title>
		<link>http://labs.grinant.com/?p=8</link>
		<comments>http://labs.grinant.com/?p=8#comments</comments>
		<pubDate>Wed, 06 Aug 2008 23:17:34 +0000</pubDate>
		<dc:creator>Edgar Griñant</dc:creator>
		
	<category>AS3</category>
	<category>Webcam</category>
		<guid isPermaLink="false">http://labs.grinant.com/?p=8</guid>
		<description><![CDATA[Demo of how to display a webcam device applying filters.






Note: You need a webcam to see this demo in action. Nothing is being recorded (no data is being sent to server).

[+]View Code ACTIONSCRIPT31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package &#123;
 import flash.display.Sprite;
 import flash.display.DisplayObject;
 import flash.display.Stage;
 import flash.media.Video;
 import flash.media.Camera;
 import flash.filters.ConvolutionFilter;
 
 public class Main extends Sprite&#123;
  // Init global variables
  var vid:Video;
  
  public function Main&#40;&#41;
  &#123;
   // Main actions
   setupCamera&#40;&#41;;
   applyFilter&#40;&#41;;
  &#125;
  
  function setupCamera&#40;&#41;
  &#123;
   // Init camera.
   var cam:Camera = [...]]]></description>
			<content:encoded><![CDATA[<p>Demo of how to display a webcam device applying filters.</p>
<p>
<object type="application/x-shockwave-flash" width="420" height="315">
<param name="movie" value="http://www.grinant.com/labs/mnt/w0207/d06/s04/b02a35d0/www/grinant.net/labs/wp-content/uploads/2008/08/webcam_glowingedges.swf" />
<embed src="http://www.grinant.com/labs/mnt/w0207/d06/s04/b02a35d0/www/grinant.net/labs/wp-content/uploads/2008/08/webcam_glowingedges.swf" type="application/x-shockwave-flash" width="420" height="315" >
</object>
</p>
<p><strong>Note: You need a webcam to see this demo in action. Nothing is being recorded (no data is being sent to server).</strong></p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p84');">[<span id="p84_symbol">+</span>]</a></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p8code4'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr style="display:none" id="p84"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code" id="p8code4"><pre class="actionscript3"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">DisplayObject</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Stage</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">Video</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span>.<span style="color: #004993;">Camera</span>;
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.filters</span>.<span style="color: #004993;">ConvolutionFilter</span>;
 
 <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main extends <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#123;</span>
  <span style="color: #009900;">// Init global variables</span>
  <span style="color: #6699cc; font-weight: bold;">var</span> vid<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Video</span>;
  
  <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">// Main actions</span>
   setupCamera<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #004993;">applyFilter</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
  <span style="color: #000000;">&#125;</span>
  
  <span style="color: #339966; font-weight: bold;">function</span> setupCamera<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">// Init camera.</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> cam<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Camera</span> = <span style="color: #004993;">Camera</span>.<span style="color: #004993;">getCamera</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">// Create the video zone.</span>
   vid = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Video</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">// Camera will be the source of the video.</span>
   vid.<span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span>cam<span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">// Add the video object to the stage.</span>
   <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>vid<span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">// Adjust the webcam picture to match width and height of the stage.</span>
   vid.<span style="color: #004993;">width</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>;
   vid.<span style="color: #004993;">height</span> = <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>;
  <span style="color: #000000;">&#125;</span>
  
  <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">applyFilter</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">// Create the filter through a convolution matrix.</span>
   <span style="color: #009900;">// Create the matrix.</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">matrix</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #000000;">&#91;</span> <span style="color: #000000; font-weight:bold;">-0.25</span>, <span style="color: #000000; font-weight:bold;">-3</span>, <span style="color: #000000; font-weight:bold;">-0.25</span>,
         <span style="color: #000000; font-weight:bold;">-3</span>,    <span style="color: #000000; font-weight:bold;">12</span>,    <span style="color: #000000; font-weight:bold;">-3</span>,
         <span style="color: #000000; font-weight:bold;">-0.25</span>, <span style="color: #000000; font-weight:bold;">-3</span>, <span style="color: #000000; font-weight:bold;">-0.25</span> <span style="color: #000000;">&#93;</span>;
   <span style="color: #009900;">// Create the ConvolutionFilter object.</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> convolution<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ConvolutionFilter</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ConvolutionFilter</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">// Specify the lenght of the matrix.</span>
   convolution.<span style="color: #004993;">matrixX</span> = <span style="color: #000000; font-weight:bold;">3</span>;
   convolution.<span style="color: #004993;">matrixY</span> = <span style="color: #000000; font-weight:bold;">3</span>;
   <span style="color: #009900;">// Assign the matrix.</span>
   convolution.<span style="color: #004993;">matrix</span> = <span style="color: #004993;">matrix</span>;
   convolution.<span style="color: #004993;">divisor</span> = <span style="color: #000000; font-weight:bold;">1</span>;
   <span style="color: #009900;">// Apply the filter.</span>
   vid.<span style="color: #004993;">filters</span> = <span style="color: #000000;">&#91;</span>convolution<span style="color: #000000;">&#93;</span>;
  <span style="color: #000000;">&#125;</span>
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRSS>http://labs.grinant.com/?feed=rss2&amp;p=8</wfw:commentRSS>
		</item>
	</channel>
</rss>
