<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Redkiing&#039;s Blog</title>
	<atom:link href="http://redkiing.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://redkiing.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sat, 21 Jan 2012 11:57:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='redkiing.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Redkiing&#039;s Blog</title>
		<link>http://redkiing.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://redkiing.wordpress.com/osd.xml" title="Redkiing&#039;s Blog" />
	<atom:link rel='hub' href='http://redkiing.wordpress.com/?pushpress=hub'/>
		<item>
		<title>2011 Summary and Happy 2012</title>
		<link>http://redkiing.wordpress.com/2012/01/21/2011-summary-and-happy-2012/</link>
		<comments>http://redkiing.wordpress.com/2012/01/21/2011-summary-and-happy-2012/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 11:52:38 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[robotics contest]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=523</guid>
		<description><![CDATA[A summary about all the cool stuff I witnessed through out 2011. <a href="http://redkiing.wordpress.com/2012/01/21/2011-summary-and-happy-2012/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=523&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ll find in this post a summary about all the cool stuff I witnessed through out 2011.</p>
<p>Last year came with a heavy agenda. Lots of public events took place during the year. I participated with my ClubElek team-mates at 3 different exhibitions and 4 different contests.</p>
<p><span id="more-523"></span></p>
<h2>Exhibitions</h2>
<h3>Mondial des Métiers, in Lyon, France</h3>
<p>Takes place early February at Lyon, France. Syntec Numerique invites ClubElek every year to share a glimpse of informatics&#8217; career paths to young students and to explain them why computer science is so cool. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Innorobo</h3>
<p>Takes place every year around mid-March at Cité Internationale, Lyon, France. A great place to meet robotics enterprises from all around the world such as iRobot Corporation and Aldebaran Robotics. I can say without fear that our robot wasn&#8217;t as cute as NAO the humanoid robot from Aldebaran. But hey! Ours is not plastic made!</p>
<h3>Industrie expo</h3>
<p>Takes place every 2 years in Lyon, France. It is by far the largest exhibition I&#8217;ve ever been. I can&#8217;t recall the number of times I got lost in between ~800 exhibitors and&nbsp; almost 17 thousand visitors. INSA de Lyon and ClubElek stood along high-profile companies such as ABB, Areva, Dassault Systèmes, Siemens, &#8230; It was a great honour to showcase the outcome of my computer vision project in this expo.</p>
<h2>Contests</h2>
<p>All 4 contests I took part this year were Chess Up related, they were all based on the competition rules I <a title="Eurobot&nbsp;2011" href="http://redkiing.wordpress.com/2010/09/28/eurobot-2011/">announced last year</a>.</p>
<h3>ArcerlorMittal robotics contest</h3>
<p>This contest was sponsored and organized by ArcelorMittal and took place at their Metz Research Center, France.</p>
<p>It was a great opportunity to test our robot and to discover the company from the inside-out. We visited their research facilities and enjoyed their excellent meals. We didn&#8217;t win the competition. However, we won the Jury Prize for the best presentation to the Jury where we explained how our robotics club is organized. The prize: spend the night in a beautiful Chalet. Sauna included. Awesome!</p>
<div id="attachment_766" class="wp-caption aligncenter" style="width: 603px"><a href="http://www.facebook.com/coupeAM2011"><img class="size-full wp-image-766" title="ClubElek_ArcelorMittal_FB" src="http://redkiing.files.wordpress.com/2012/01/clubelek_arcelormittal_fb.jpg?w=593&#038;h=394" alt="ClubElek at ArcerlorMitall 2011 contest" width="593" height="394" /></a><p class="wp-caption-text">ClubElek robot during a performance at ArcelorMittal 2011 contest. Image Credits Facebook coupeAM2011</p></div>
<h3>Rhônes Alpes Robotics Cup</h3>
<p>Better known as &#8220;La Coupe Rhône Alpes&#8221; in France. It is a robotics contest organized by ClubElek which takes place during the &#8220;world-wide&#8221; known event called <a title="Les 24h de l'INSA" href="http://www.24heures.org/" target="_blank">Les 24 heures de l&#8217;INSA</a>, at INSA de Lyon, France.</p>
<p>It is a special contest where teams show their robots off to the public and learn how others have solved the same challenges. The best part of it: the BBQ offered by ClubElek at the end of the day. Yummy!</p>
<h3>French robotics cup</h3>
<p>It was the beginning of June when a bunch robots and their fanatical developers grouped together at La Ferté Bernard to participate at the most important robotics challenge in France: <a href="http://www.planete-sciences.org/robot/index.php?section=pages&amp;pageid=79" target="_blank">La Coupe de France de Robotique</a>. Our team <a title="ClubElek" href="clubelek.insa-lyon.fr" target="_blank">Clubelek</a> was obviously present. We had built a very compelling robot and we all had very high hopes on to what it could achieve, however (or should I say as usual ^^), the robot faced a lot of small problems that took a huge time end effort to solve, so we weren&#8217;t exactly sure if it was going to be able to do everything we planned it to do.</p>
<p>Actually, everything went bad the first few matches against the other robots. Fortunately, we got very good scores in the end; therefore, we got an entry pass to the sixteenth-finals! Call it luck, preparation, hard work or whatever you&#8217;d like but we managed to get into the podium after several other matches!</p>
<p>The video of the last match that gave us our beloved <strong>3rd place</strong> (Our robot is the one at the top red square) :</p>
<p><iframe width="593" height="334" src="http://www.youtube.com/embed/sHv49fXRp6M?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<h3>Eurobot</h3>
<p>As you might already know, being either the 1st or the 2nd best French team, you get to participate at the European robotics contest called Eurobot. And because BHTeam, the 2nd French team, desisted to go, ClubElek got its free ticket to Eurobot 2011 in Russia. Last year&#8217;s Eurobot took place in Astrakhan, Russia.</p>
<p>Russia was a great experience, I got to meet lots of beautiful places and people, tasted new flavours and even learned some new words like привет! All while showing off our little robotics creation. Crazy stuff!</p>
<div id="attachment_764" class="wp-caption aligncenter" style="width: 603px"><a href="http://redkiing.files.wordpress.com/2012/01/imag05391.jpg"><img class="size-full wp-image-764" title="Saint Basil's Cathedral" src="http://redkiing.files.wordpress.com/2012/01/imag05391.jpg?w=593&#038;h=593" alt="Saint Basil's Cathedral" width="593" height="593" /></a><p class="wp-caption-text">Saint Basil&#039;s Cathedral, Moscow, Russia.</p></div>
<h2>Projects</h2>
<p>My 2 main ClubElek&#8217;s projects in 2011 were:</p>
<ol>
<li>A new <a title="A star algorithm" href="http://en.wikipedia.org/wiki/A*_search_algorithm" target="_blank">A* based</a> pathfinder library. A refactor of something I had already done last year but faster and more user/developer friendly.</li>
<li>The second project was even more incredible. To give <a title="The COTBLEDTCID approach to object detection and pose estimation, Part I –&nbsp;Preface" href="http://redkiing.wordpress.com/2011/12/18/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-i-preface/">artificial vision to the robot</a>.</li>
</ol>
<p>I also did a summer internship in <a title="Atos Worldline" href="http://www.atosworldline.com" target="_blank">Atos Worldline</a> where I worked with great people and with some new fancy mobile technologies.</p>
<p>In all 2011 was an amazing year !</p>
<p>Happy 2012!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/523/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/523/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/523/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=523&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2012/01/21/2011-summary-and-happy-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2012/01/clubelek_arcelormittal_fb.jpg" medium="image">
			<media:title type="html">ClubElek_ArcelorMittal_FB</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2012/01/imag05391.jpg" medium="image">
			<media:title type="html">Saint Basil&#039;s Cathedral</media:title>
		</media:content>
	</item>
		<item>
		<title>The COTBLEDTCID approach to object detection and pose estimation, Part V &#8211; Circles detection</title>
		<link>http://redkiing.wordpress.com/2012/01/08/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-v-circles-detection/</link>
		<comments>http://redkiing.wordpress.com/2012/01/08/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-v-circles-detection/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 09:00:17 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Eurobot]]></category>
		<category><![CDATA[Eurobot 2011]]></category>
		<category><![CDATA[Maths]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[OpenCv]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=597</guid>
		<description><![CDATA[Circles detection <a href="http://redkiing.wordpress.com/2012/01/08/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-v-circles-detection/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=597&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Let&#8217;s do a summary of what we have done so far:</p>
<ul>
<li>COT: colour thresholding. We separated yellow objects from the rest.</li>
<li>BLED: blob edge detection. We retrieved the bottom edges of blobs (pawns).</li>
<li>T: transformation. We transformed the image&#8217;s pixels into game field points (aka. pixels to meters).</li>
</ul>
<p>And the last step CID: Circles Detection.</p>
<p>As you may have already noticed, pawns and tower of pawns are in fact circles when viewed from above. Therefore, the bottom edges we found with BLED are also circles&#8217; segments when transformed into game field coordinates (step T). This is the property we&#8217;re exploiting below.</p>
<p><span id="more-597"></span></p>
<h2>Algorithm</h2>
<p>The secret here is to find the centre of the circles defined by the transformed edges. Then, we need to remove those which lay outside the game field, and finally we should merge those circles which are too close to each other.</p>
<p><pre class="brush: plain;">
Transform the bottom edges to field coordinates.
For each bottom edge
  Retrieve the 2 points that are the farthest from each other (The longer the edge, the more precise the centre is likely to be) :
    pLeft  = beginning of the bottom edge
    pRight = end of the bottom edge
  Given two points and the circle's radius (pLeft, pRight, r), find the circle's centre c

Remove any circle placed outside the game field

If any circle c overlaps any other circle c' then
  merge the circles' centre by averaging their positions with the means of a weighted mean to increase precision. The weight being the length of the edge.

</pre></p>
<p>Finding a circle&#8217;s centre is just a matter of solving <img src='http://s0.wp.com/latex.php?latex=%28x+-+h%29%5E2+%2B+%28y+-+k%29%5E2+%3D+r%5E2&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='(x - h)^2 + (y - k)^2 = r^2' title='(x - h)^2 + (y - k)^2 = r^2' class='latex' /> for <img src='http://s0.wp.com/latex.php?latex=c%3D%5Cbegin%7Bpmatrix%7D+h+%5C%5C+k+%5Cend%7Bpmatrix%7D&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='c=&#92;begin{pmatrix} h &#92;&#92; k &#92;end{pmatrix}' title='c=&#92;begin{pmatrix} h &#92;&#92; k &#92;end{pmatrix}' class='latex' /> given 2 points <img src='http://s0.wp.com/latex.php?latex=p_1%3D%5Cbegin%7Bpmatrix%7D+x_1+%5C%5C+y_1+%5Cend%7Bpmatrix%7D&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p_1=&#92;begin{pmatrix} x_1 &#92;&#92; y_1 &#92;end{pmatrix}' title='p_1=&#92;begin{pmatrix} x_1 &#92;&#92; y_1 &#92;end{pmatrix}' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=p_2+%3D+%5Cbegin%7Bpmatrix%7D+x_2+%5C%5C+y_2+%5Cend%7Bpmatrix%7D&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p_2 = &#92;begin{pmatrix} x_2 &#92;&#92; y_2 &#92;end{pmatrix}' title='p_2 = &#92;begin{pmatrix} x_2 &#92;&#92; y_2 &#92;end{pmatrix}' class='latex' /> and the radius <img src='http://s0.wp.com/latex.php?latex=r&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='r' title='r' class='latex' />.</p>
<p>It can be shown that the centre of the circle is given by:<br />
<img src='http://s0.wp.com/latex.php?latex=c+%3D+%5Cfrac%7B1%7D%7B2%7D%28p_1%2Bp2+%29%5Cpm+%5Csqrt%7B%28%5Cfrac%7Br%7D%7Bd%7D%29%5E2-%5Cfrac%7B1%7D%7B4%7D%7D+%5Cbegin%7Bpmatrix%7D+0+%26+-1+%5C%5C+1+%26+0+%5Cend%7Bpmatrix%7D+%28p_2-p_1%29+&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='c = &#92;frac{1}{2}(p_1+p2 )&#92;pm &#92;sqrt{(&#92;frac{r}{d})^2-&#92;frac{1}{4}} &#92;begin{pmatrix} 0 &amp; -1 &#92;&#92; 1 &amp; 0 &#92;end{pmatrix} (p_2-p_1) ' title='c = &#92;frac{1}{2}(p_1+p2 )&#92;pm &#92;sqrt{(&#92;frac{r}{d})^2-&#92;frac{1}{4}} &#92;begin{pmatrix} 0 &amp; -1 &#92;&#92; 1 &amp; 0 &#92;end{pmatrix} (p_2-p_1) ' class='latex' /> where <img src='http://s0.wp.com/latex.php?latex=d+%3D+%7C%7Cp_2+-+p_1%7C%7C+&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='d = ||p_2 - p_1|| ' title='d = ||p_2 - p_1|| ' class='latex' /></p>
<p>This equation has 2 solutions but only one gives the expected result. To choose the right sign, check whether <img src='http://s0.wp.com/latex.php?latex=p_1&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p_1' title='p_1' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=p_2&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p_2' title='p_2' class='latex' /> go counter-clockwise if yes the the sign should be <img src='http://s0.wp.com/latex.php?latex=%2B&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='+' title='+' class='latex' />. In our case we go counter-clockwise because the points are always given from left to right.</p>
<h2>Results</h2>
<p>The original image:</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20116.png"><img class="size-full wp-image-609 aligncenter" title="frame_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20116.png?w=593&#038;h=355" alt="Original image" width="593" height="355" /></a></p>
<p>The binary thresholded image:</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20113.png"><img class="size-full wp-image-605 aligncenter" title="binary_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20113.png?w=593&#038;h=355" alt="Binary image" width="593" height="355" /></a></p>
<p>The bottom edges:<a href="http://redkiing.files.wordpress.com/2011/12/edges_screenshot_01-01-20111.png"><img class="size-full wp-image-608 aligncenter" title="edges_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/edges_screenshot_01-01-20111.png?w=593&#038;h=355" alt="Bottom edges" width="593" height="355" /></a>The transformed bottom edges with the circles rendered on top of them:</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/edges-l0-l1_screenshot_01-01-2011.png"><img class="size-full wp-image-607 aligncenter" title="Edges L0 + L1_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/edges-l0-l1_screenshot_01-01-2011.png?w=593&#038;h=415" alt="Bottom Edges + Circles" width="593" height="415" /></a>The final render :</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/terrain_screenshot_01-01-2011_plus_camera.png"><img class="size-full wp-image-612 aligncenter" title="Terrain_screenshot_01.01.2011_plus_camera" src="http://redkiing.files.wordpress.com/2011/12/terrain_screenshot_01-01-2011_plus_camera.png?w=593&#038;h=415" alt="Terrain rendered with circles and camera view" width="593" height="415" /></a></p>
<h2>Discussion</h2>
<p>We presented a simple yet effective method for finding circles&#8217; centres. This is evidently not the only way of finding them, the more usual approach is by using <a title="Hough Circle Transform, openCV" href="http://opencv.willowgarage.com/documentation/cpp/imgproc_feature_detection.html?#cv-houghcircles" target="_blank">Hough Cirlce Transforms</a>. However, our method is much faster and does not have any special memory requirements as it is not probabilistic and requires only two points, and because the radius is known, high precision is achieved.</p>
<p>Another method we tried was the <a title="Least-Squares fit by R.Bullock" href="http://www.dtcenter.org/met/users/docs/write_ups/circle_fit.pdf" target="_blank">Least-Squares fit by R. Bullock</a>, which gave pretty much the same results with a sightly heavier computational approach. The advantage of this last method is it uses all points from the edge to compute the circles&#8217; centre, this may give better results when the first or the last points of the edge are not correctly found and have an offset. Practically this case rarely happened because pawns, which are yellow, have a very different colour from their entourage which is usually red, blue, green or black, and therefore pawns&#8217; bottom edges are usually correctly determined.</p>
<h2>What&#8217;s next</h2>
<p>The fancy algorithms end here. Yeap, sorry about that. No more maths for today. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A conclusion and a summary of what has been done, what could be improved and what I have learned on the next post.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/597/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=597&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2012/01/08/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-v-circles-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20116.png" medium="image">
			<media:title type="html">frame_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20113.png" medium="image">
			<media:title type="html">binary_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/edges_screenshot_01-01-20111.png" medium="image">
			<media:title type="html">edges_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/edges-l0-l1_screenshot_01-01-2011.png" medium="image">
			<media:title type="html">Edges L0 + L1_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/terrain_screenshot_01-01-2011_plus_camera.png" medium="image">
			<media:title type="html">Terrain_screenshot_01.01.2011_plus_camera</media:title>
		</media:content>
	</item>
		<item>
		<title>The COTBLEDTCID approach to object detection and pose estimation, Part IV &#8211; Transformation</title>
		<link>http://redkiing.wordpress.com/2012/01/07/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-iv-transform/</link>
		<comments>http://redkiing.wordpress.com/2012/01/07/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-iv-transform/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 15:24:18 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Eurobot]]></category>
		<category><![CDATA[Eurobot 2011]]></category>
		<category><![CDATA[Maths]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[OpenCv]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=588</guid>
		<description><![CDATA[Homography transform explained. <a href="http://redkiing.wordpress.com/2012/01/07/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-iv-transform/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=588&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>With the last step we know where the bottom edges of the pawn are located on the image, we just need to find a way to transform the coordinates of those pixels into game field coordinates.</p>
<p>Given a point <img src='http://s0.wp.com/latex.php?latex=p%27&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p&#039;' title='p&#039;' class='latex' /> from the Image plane, we&#8217;d like to transform it into <img src='http://s0.wp.com/latex.php?latex=p&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p' title='p' class='latex' /> from the Game field plane. We can write:</p>
<p><img src='http://s0.wp.com/latex.php?latex=p+%3D+H+%5Ccdot+p%27&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p = H &#92;cdot p&#039;' title='p = H &#92;cdot p&#039;' class='latex' /></p>
<p>We observe that straight lines are kept straight, thus H is called the <a title="Homography" href="http://en.wikipedia.org/wiki/Homography">homography</a> matrix which can be computed if at least 4 different matching points are given for both planes. <img src='http://s0.wp.com/latex.php?latex=%28p1+%5Cleftrightarrow+p1%27%2C+p2+%5Cleftrightarrow+p2%27%2C+p3+%5Cleftrightarrow+p3%27%2C+p4+%5Cleftrightarrow+p4%27%29&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='(p1 &#92;leftrightarrow p1&#039;, p2 &#92;leftrightarrow p2&#039;, p3 &#92;leftrightarrow p3&#039;, p4 &#92;leftrightarrow p4&#039;)' title='(p1 &#92;leftrightarrow p1&#039;, p2 &#92;leftrightarrow p2&#039;, p3 &#92;leftrightarrow p3&#039;, p4 &#92;leftrightarrow p4&#039;)' class='latex' /></p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/homography.png"><img class="size-full wp-image-589 aligncenter" title="homography" src="http://redkiing.files.wordpress.com/2011/12/homography.png?w=593&#038;h=444" alt="Homography" width="593" height="444" /></a>It&#8217;s worth noticing that both <img src='http://s0.wp.com/latex.php?latex=p&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p' title='p' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=p%27&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p&#039;' title='p&#039;' class='latex' /> points are given in <a title="homogeneous coordinates" href="http://en.wikipedia.org/wiki/Homogeneous_coordinates" target="_blank">homogeneus coordinates</a>.</p>
<p><span id="more-588"></span></p>
<h2>Algorithm and code</h2>
<p>1. In order to compute H, the homography matrix. We use the ready to use openCV&#8217;s function: <a title="findHomography" href="http://opencv.itseez.com/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#findhomography" target="_blank">findHomography</a>.</p>
<p><pre class="brush: cpp;">
// Create a column vector with the coordinates of each point (on the field plane)
cv::Mat xField;
xField.create(4, 1, CV_32FC2);
xField.at(0) = ( cv::Point2f(x1, y1) );
xField.atPoint2f&gt;(1) = ( cv::Point2f(x2, y2) );
xField.atPoint2f&gt;(2) = ( cv::Point2f(x3, y3) );
xField.at(3) = ( cv::Point2f(x4, y4) );

// same thing for xImage but with the pixel coordinates instead of the field coordinates, same order as in xField
cv::Mat xImage;
xImage.at(0) = ( cv::Point2f(x1_bis, y1_bis) );
...

// Compute the homography matrix
cv::Mat H = cv::findHomography( xImage, xField );
</pre></p>
<p>2. Whenever we want to find the coordinates of a point on the game field, given a pixel <img src='http://s0.wp.com/latex.php?latex=p%27%28x%2Cy%29&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p&#039;(x,y)' title='p&#039;(x,y)' class='latex' /> on an image. We only need to transform <img src='http://s0.wp.com/latex.php?latex=p%27&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p&#039;' title='p&#039;' class='latex' /> into <img src='http://s0.wp.com/latex.php?latex=p&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p' title='p' class='latex' />:</p>
<p><pre class="brush: cpp;">
// pImage = p'(x,y)
// pImage is in the projective plane
cv::Mat pImage = (cv::Mat_(3,1) &lt;&lt; x, y, 1);
cv::Mat pField = H * pImage;
// pField is in the projective plane (homogeneous coordinates): (X, Y, W). Transform it back to the euclidean plane: (X', Y', 1)
pField        /= pField.at(2);

// p(xField, yField) represent the same point as p'(x, y) but in different planes.
double xField = pField.at(0);
double yField = pField.at(1);
</pre></p>
<h2>Optimizations</h2>
<p>Because (2) is used really often we can avoid doing matrix products during run time by pre-calculating all possible transformations of the image. All game field points corresponding to every pixel of the image are computed in advance and saved into an bi-dimensional array for efficient access. To correlate <img src='http://s0.wp.com/latex.php?latex=p%27&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p&#039;' title='p&#039;' class='latex' /> to <img src='http://s0.wp.com/latex.php?latex=p&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='p' title='p' class='latex' /> we do:</p>
<p><pre class="brush: plain;">
p = pixelsToMeters.at(p')
</pre></p>
<h2>Just for fun</h2>
<p>Using the pixelsToMeters array we can print the area the camera sees of the field:<br />
<a href="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20114.png"><img class="size-full wp-image-593 aligncenter" title="frame_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20114.png?w=593&#038;h=355" alt="What the camera sees" width="593" height="355" /></a><br />
<a href="http://redkiing.files.wordpress.com/2011/12/terrainview.png"><img class="size-full wp-image-594 aligncenter" title="terrainView" src="http://redkiing.files.wordpress.com/2011/12/terrainview.png?w=593&#038;h=415" alt="What the camera sees (Field View)" width="593" height="415" /></a></p>
<h2>What&#8217;s next</h2>
<p>You guessed right we now have the full &#8216;tool-kit&#8217; to precisely link pawns on the image to their positions on the game field plane. How to do it is the subject of the next post.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/588/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/588/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/588/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=588&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2012/01/07/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-iv-transform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/homography.png" medium="image">
			<media:title type="html">homography</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20114.png" medium="image">
			<media:title type="html">frame_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/terrainview.png" medium="image">
			<media:title type="html">terrainView</media:title>
		</media:content>
	</item>
		<item>
		<title>The COTBLEDTCID approach to object detection and pose estimation, Part III &#8211; Blob Edge Detection</title>
		<link>http://redkiing.wordpress.com/2012/01/07/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-iii-blob-edge-detection/</link>
		<comments>http://redkiing.wordpress.com/2012/01/07/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-iii-blob-edge-detection/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 11:29:00 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Eurobot]]></category>
		<category><![CDATA[Eurobot 2011]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[Maths]]></category>
		<category><![CDATA[OpenCv]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=567</guid>
		<description><![CDATA[Blob Edge Detection algorithm explained. <a href="http://redkiing.wordpress.com/2012/01/07/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-iii-blob-edge-detection/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=567&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>There is still too much information we do not need on the B&amp;W image we got on the last step. That&#8217;s why we need to extract the features we do need. One way of accomplishing this is by performing a connected component analysis in binary images, aka blob labelling. However as you&#8217;ll will see, this method is not completely adapted to our needs, so a new approach is proposed: Blob Edge Detection.</p>
<p><span id="more-567"></span></p>
<h2>First approach : blob detection</h2>
<p><a title="cvBlob" href="http://code.google.com/p/cvblob/" target="_blank">cvBlob</a> is a nice library that has many interesting functionalities such as: binary labelling and features extraction, blob tracking and contour detection. It is powered by openCV under the hood.</p>
<p style="text-align:left;">In the beginning of the project I wondered whether this library would be useful for what we were trying to accomplish. I ran some tests and even though the binary labelling approach proposed by cvBlob was good and very fast, it wasn&#8217;t good enough. By using their approach we could have only found the position of single pawns. For instance, the following image uses cvBlob and shows some pawns being correctly recognised, each pawn is labelled with different colours.</p>
<p style="text-align:center;"><a href="http://redkiing.files.wordpress.com/2011/12/8-imag0006_result1.jpg"><img class="size-full wp-image-570" title="8-IMAG0006_result1" src="http://redkiing.files.wordpress.com/2011/12/8-imag0006_result1.jpg?w=593" alt="Everything works as expected"   /></a></p>
<p style="text-align:left;">Problems appeared in more complex situations where several pawns were labelled as a single pawn or where a pawn was labelled twice. The following image shows a group of 3 and 2 different pawns being labelled with the same colour pink and green respectively. This behaviour is caused because those pawns are connected and form a single blob on the binary image (not shown) and thus are labelled with the same colour.<a href="http://redkiing.files.wordpress.com/2011/12/13-imag0007_result3.jpg"><img class="size-full wp-image-571 aligncenter" title="13-IMAG0007_result3" src="http://redkiing.files.wordpress.com/2011/12/13-imag0007_result3.jpg?w=593" alt=""   /></a></p>
<p>The other problem with this method was that some pawns were detected twice. The following image shows a pawn at the right bottom corner being labelled twice (pink and purple) due to the fact that the pawn on the binary image is composed of 2 separate blobs.</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/11-imag0007_result2.jpg"><img class="size-full wp-image-573 aligncenter" title="11-IMAG0007_result2" src="http://redkiing.files.wordpress.com/2011/12/11-imag0007_result2.jpg?w=593" alt="The pawn is detected twice"   /></a>In order to achieve better object detection results, a more robust algorithm was implemented.</p>
<h2>Algorithm</h2>
<p>The main idea behind the algorithm is to separate tower of pawns or single pawns from other pawns. One way of doing it is by searching and labelling blobs&#8217; bottom edges.</p>
<p style="text-align:center;"><a href="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20113.png"><img class="size-full wp-image-576" title="frame_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20113.png?w=593" alt="Original image"   /></a></p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20112.png"><img class="size-full wp-image-574 aligncenter" title="binary_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20112.png?w=593" alt="Binary image"   /></a></p>
<p style="text-align:left;">1. Find the blobs&#8217; bottom edges</p>
<p><pre class="brush: plain;">

Take the B&amp;W image
for every column of the image do
  for every row
    if the pixel is black and the N previous pixels above it are white
    and if the black gap after the current pixel is big enough then
        mark the pixel as being a bottom edge of a pawn
    end if
  end for every row
end for every column

</pre></p>
<p>2. At this point we have a set of pixels P that belong to the bottom of pawns. They are however scattered throughout the rows. The next step is to regroup those pixels by pawns as much as possible. This means to check whether a pixel p from P belongs to the same bottom edge of a given pawn.</p>
<p><pre class="brush: plain;">
Take the set of pixels P that belong to the bottom of pawns
P(1) being the set of pixels P whose column is 1
Create a new list of bottom edges for every pixel p belonging to P(1) and add every p as a first element to them
for every column c of the image, starting with the 2nd one
  for every set of pixels p in P(c)
    if p is near any other pixel w in P(c - 1) then
      add p to the list where w is located
    else
      create a new list of bottom edges
      add p to the list
    end if
  end for set of pixels
end for every column
</pre></p>
<p>3. Now we have a list of bottom lines L, each containing a list of pixels that belong to the bottom of a pawn or a tower of pawns. Unfortunately some contiguous lines do not belong to the same pawn. The following image shows an example of such kind of errors.</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/errorstepdetectedges.png"><img class="size-full wp-image-579 aligncenter" title="errorStepDetectEdges" src="http://redkiing.files.wordpress.com/2011/12/errorstepdetectedges.png?w=593" alt="A single line should not represent more than one pawn"   /></a></p>
<p>This has to be fixed otherwise we&#8217;ll be unable to find the right position of the pawn. The following algorithm fixes this problem.</p>
<p><pre class="brush: plain;">
for every bottom line l of L
  if the line l has a spike, split l at the spike
end for
</pre></p>
<h2>Results</h2>
<p>The algorithm&#8217;s output for the B&amp;W image shown at (1) is shown in the following rendering. Every bottom line l from (L) has been coloured differently to better show the result of the algorithm. A similar approach has been applied to detect the upper edges of the pawns.</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/edges_screenshot_01-01-2011.png"><img class="size-full wp-image-575 aligncenter" title="edges_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/edges_screenshot_01-01-2011.png?w=593" alt=""   /></a></p>
<p>As you may see, any one line belongs to the bottom of one and only one pawn. The reciprocal is not true: two or more lines might belong to the same pawn. This is not a problem as you&#8217;ll see later on.</p>
<h2>Discussion</h2>
<h3>Advantages</h3>
<p>The advantages of the BLED algorithm are :</p>
<ul>
<li>Tower invariant: tower of pawns are not special cases, they are treated and located as if they were single pawns.</li>
<li>Faster than a simple labelling algorithm: the algorithm is faster because only blobs&#8217; bottom edges are connected and labelled. Whereas the other algorithm connects all pixels of a blob.</li>
<li>Noise resistant</li>
</ul>
<h3>Optimizations</h3>
<p>The algorithm in (1) is slow because its searches every pixel of every row of the image. One way of optimizing it is by searching every T rows for white to black changes where T is the minimum gap size between two blobs to be considered different blobs. Once a colour variation is found, search down the image to precisely detect where the white to black change happens. This optimisation is somewhat similar to the idea behind <a title="Pyramids in OpenCV" href="http://opencv.itseez.com/doc/tutorials/imgproc/pyramids/pyramids.html?highlight=pyramid" target="_blank">pyramids</a> but without the aliasing nor the copy of image data overhead.</p>
<h3>Disadvantages</h3>
<ul>
<li>The current algorithm cannot find the height of towers.</li>
<li>Pawns that are exactly behind other pawns are simply ignored and not found.</li>
<li>If an object, such as a robotic arm, is placed between the camera and the middle of a tower of pawns, the algorithm might consider the tower as being two different pawns at different positions.</li>
</ul>
<h3>Other approaches</h3>
<p>In order to detect the pawns&#8217; edges, we could have simply used the more common <a title="Canny Edge Detector" href="http://opencv.itseez.com/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.html" target="_blank">Canny Edge Detector</a>. However, we might have needed to use morphological operations on the image before applying the edge detector, to reduce the heavy noise inherent to the previous colour thresholding step. Moreover, this approach would have found all edges: bottom, upper, left and right of a pawn. A second step would have been necessary so as to extract the bottom edges only, which may be far too complex to do. In summary, by using the Canny Edge Detector we would have added too much of an overhead.</p>
<h2>What&#8217;s next</h2>
<p>We now know where the pawns are on-screen, but how does that help us to know where they are on the game field ? That&#8217;s the whole point of the next post : Transformation.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/567/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/567/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/567/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/567/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/567/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/567/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/567/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/567/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/567/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/567/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/567/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/567/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/567/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/567/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=567&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2012/01/07/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-iii-blob-edge-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/8-imag0006_result1.jpg" medium="image">
			<media:title type="html">8-IMAG0006_result1</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/13-imag0007_result3.jpg" medium="image">
			<media:title type="html">13-IMAG0007_result3</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/11-imag0007_result2.jpg" medium="image">
			<media:title type="html">11-IMAG0007_result2</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20113.png" medium="image">
			<media:title type="html">frame_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20112.png" medium="image">
			<media:title type="html">binary_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/errorstepdetectedges.png" medium="image">
			<media:title type="html">errorStepDetectEdges</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/edges_screenshot_01-01-2011.png" medium="image">
			<media:title type="html">edges_screenshot_01.01.2011</media:title>
		</media:content>
	</item>
		<item>
		<title>The COTBLEDTCID approach to object detection and pose estimation, Part II &#8211; Colour Thresholding</title>
		<link>http://redkiing.wordpress.com/2011/12/19/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-ii-colour-thresholding/</link>
		<comments>http://redkiing.wordpress.com/2011/12/19/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-ii-colour-thresholding/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 11:34:55 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Eurobot]]></category>
		<category><![CDATA[Eurobot 2011]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[colour spaces]]></category>
		<category><![CDATA[rgb colour space]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=541</guid>
		<description><![CDATA[Colour Thresholding <a href="http://redkiing.wordpress.com/2011/12/19/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-ii-colour-thresholding/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=541&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Images are usually too complex to be treated by computers as is. In most cases, they have to be enhanced and simplified before any algorithm can be applied on them. Fortunately for us, the rules of the contest specify that yellow is the colour of pawns and figures we are looking to detect.</p>
<p>Generally speaking, the purpose of Colour Segmentation is to extract information from an image by grouping similar colours. In our algorithm, we implemented colour segmentation by thresholding yellow colours, that is to say, the computer builds a black and white image from the original image where white colour represents yellow colour and black is everything else. This is called colour thresholding.</p>
<p>The problem is, as you may have already guessed, the notion of &#8220;yellow&#8221; colour. For humans, it is relatively easy to tell whether a colour belongs to a group of colours, but for computers this is a whole different story.</p>
<p><span id="more-541"></span></p>
<h2>Colour spaces and thresholding</h2>
<p>Computers work with a limited set of colours, which are usually represented by three additive components Red Green and Blue, RGB for short. All these colours can be represented inside a cube called the <a title="RGB color space" href="http://en.wikipedia.org/wiki/RGB_color_space" target="_blank">RGB Colour Space</a> which, in computer vision, is very difficult to work with. Mainly because colours tend to change too much from a given point A to any other point near of it. There is no &#8220;easy&#8221; way of telling whether a point B belongs to a group of colours due to the fact this subset is not easily represented using <a title="Cartesian coordinates" href="http://en.wikipedia.org/wiki/Cartesian_coordinates" target="_blank">cartesian coordinates</a>. In other words, in this space it is very difficult to say whether a given colour C is pink, or yellow, or even orange.</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/testimage2.png"><img class="aligncenter" title="findYellowOnImage" src="http://redkiing.files.wordpress.com/2011/12/testimage2.png?w=300&#038;h=180" alt="Yellow Thresholding" width="300" height="180" /></a></p>
<p>For instance the following next 2 images represent, in RGB colour space, all colours which are present in the previous image. As you may see, it is impossible to find a simple shape (such as a smaller cube or a <a title="Cuboid" href="http://en.wikipedia.org/wiki/Cuboid" target="_blank">cuboid</a>) that fully envelops all yellow colours.</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/colorspacergb_testimage2.png"><img class="wp-image-547 aligncenter" title="colorSpaceRGB_testImage2" src="http://redkiing.files.wordpress.com/2011/12/colorspacergb_testimage2.png?w=300&#038;h=285" alt="RGB Colour space" width="300" height="285" /></a> <a href="http://redkiing.files.wordpress.com/2011/12/colorspacergb_testimage2-21.png"><img class="size-medium wp-image-550 aligncenter" title="colorSpaceRGB_testImage2-2" src="http://redkiing.files.wordpress.com/2011/12/colorspacergb_testimage2-21.png?w=300&#038;h=283" alt="RGB Colour Space 2" width="300" height="283" /></a></p>
<p>This is one of the reasons why the <a title="HSV colour space" href="http://en.wikipedia.org/wiki/HSL_and_HSV" target="_blank">HSV colour space</a> exists. In this space, colours are represented and organized more like the human eye interprets them, in group of colours. HSV stands for Hue, Saturation an Value and is represented by a <a title="Cylindrical coordinate system" href="http://en.wikipedia.org/wiki/Cylindrical_coordinate_system" target="_blank">cylindrical coordinate system</a>. In this space, many colours such as yellow, are much more easily thresholded because colour segments or subsets may be approximated by &#8220;<a title="Pies in polar coordinates" href="http://commons.wikimedia.org/wiki/File:Point_in_Polar_coordinates.PNG" target="_blank">pies</a>&#8221; which are easily expressed in polar coordinate systems: <img src='http://s0.wp.com/latex.php?latex=%28+r1+%3C+Radius+%3C+r2%2C+theta1+%3C+Angle+%3C+theta+2+%29+&amp;bg=ffffff&amp;fg=666666&amp;s=0' alt='( r1 &lt; Radius &lt; r2, theta1 &lt; Angle &lt; theta 2 ) ' title='( r1 &lt; Radius &lt; r2, theta1 &lt; Angle &lt; theta 2 ) ' class='latex' />.</p>
<p>For the same image as above, the HSV transformation gives :</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/colorspacehsv_testimage2-1.png"><img class="aligncenter" title="colorSpaceHSV_testImage2-1" src="http://redkiing.files.wordpress.com/2011/12/colorspacehsv_testimage2-1.png?w=300&#038;h=266" alt="HSV Colour Space" width="300" height="266" /></a><a href="http://redkiing.files.wordpress.com/2011/12/colorspacehsv-select_testimage2-1.png"><img class="size-medium wp-image-545 aligncenter" title="colorSpaceHSV-select_testImage2-1" src="http://redkiing.files.wordpress.com/2011/12/colorspacehsv-select_testimage2-1.png?w=300&#038;h=265" alt="HSV Colour Space 2" width="300" height="265" /></a> <a href="http://redkiing.files.wordpress.com/2011/12/colorspacehsv-select_testimage2-2.png"><img class="size-medium wp-image-546 aligncenter" title="colorSpaceHSV-select_testImage2-2" src="http://redkiing.files.wordpress.com/2011/12/colorspacehsv-select_testimage2-2.png?w=281&#038;h=300" alt="HSV Colour Space 3" width="281" height="300" /></a></p>
<p>Look how colours may be segmented with different azimuth and radius values.</p>
<p>Nevertheless, as you might have noticed, a single pie is a bit too rough of an approximation of the yellow colour subset. That&#8217;s why we used up to three different &#8220;pies&#8221; at different levels to better threshold the image.</p>
<h2>Algorithm and code</h2>
<p>OpenCV, has done must of the hard work as it can <a title="cvtColor" href="http://opencv.itseez.com/modules/imgproc/doc/miscellaneous_transformations.html?highlight=cvtcolor#cvtcolor" target="_blank">transform colours</a> and <a title="inRange" href="http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=inrange#inrange" target="_blank">threshold them</a>. The code is pretty straight forward :</p>
<p><pre class="brush: cpp;">
// Convert the image into an HSV image
cvtColor(originalImage, hsvImage, CV_BGR2HSV);

// Threshold the hsv iamge
cv::Mat binaryImage;
cv::inRange( hsvImage, cv::Scalar(hueMin, satMin, valueMin),
                       cv::Scalar(hueMax, satMax, valueMax),
                       binaryImage);
</pre></p>
<p>The threshold was repeated up to 3 times with different min and max values to better approximate the yellow set. Unifying the image into a single B&amp;W image was done with help of <a title="bitwise_or" href="http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=bitwise_or#bitwise-or" target="_blank">cv::bitwise_or</a>.</p>
<h2>Results</h2>
<p>In short the algorithm transforms an image from RGB to HSV and then thresholds it several times and merges them into a single black and white image :</p>
<p>Input :</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20112.png"><img class="aligncenter size-full wp-image-560" title="frame_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20112.png?w=593&#038;h=355" alt="Input image" width="593" height="355" /></a></p>
<p>Output :</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20111.png"><img class="aligncenter size-full wp-image-561" title="binary_screenshot_01.01.2011" src="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20111.png?w=593&#038;h=355" alt="Thresholded image" width="593" height="355" /></a></p>
<h2>Discussion</h2>
<h3>Noise</h3>
<p>The output binary image has a lot of noise and many objects that are not inside the game field still appear on the image.</p>
<p>We could have used a combination of  <a title="dilate" href="http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=dilate#dilate" target="_blank">dilate</a> and <a title="erode" href="http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=erode#erode" target="_blank">erode</a> filters to reduce the small noise (cf. <a title="Closing Filter, Noise reduction" href="http://www.iaaf.uwa.edu.au/imageanalysis1.html" target="_blank">Closing filter, </a><a title="Closing Filter, Noise reduction" href="http://www.iaaf.uwa.edu.au/imageanalysis1.html" target="_blank">Noise Reduction</a>), but we decided to leave the image as is and do the filtering in a later step to increase performance.</p>
<p>The objects that are outside the game field aren&#8217;t a problem, as they are rejected later on.</p>
<h3>Lightning</h3>
<p>Another problem we faced was the high illumination variations which resulted in a change of tones and even colours themselves. Even though, the HSV colour space is more robust against lightning variations than the RGB colour space, it is not robust enough as well as many other factors such as lens and cameras&#8217; sensors affect them.</p>
<p>Our solution was to calibrate colours to find the best thresholding values before running the COTBLEDTCID algorithm.</p>
<p>You should better understand the problem with the following images : yellow colours are completely different from one image to the other, even for the human eye. When looking at their HSV representation, we can see a slight yellow HSV variation from the first image to the second one. This variation, even though it is small, is too much of a difference for both images to be sharing the same thresholding values.</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/testimage5.jpg"><img class="aligncenter size-full wp-image-636" title="testImage5" src="http://redkiing.files.wordpress.com/2011/12/testimage5.jpg?w=593&#038;h=332" alt="Yellow Colour 1" width="593" height="332" /></a><a href="http://redkiing.files.wordpress.com/2011/12/hsv_image_2.png"><img class="aligncenter size-medium wp-image-640" title="hsv_image_2" src="http://redkiing.files.wordpress.com/2011/12/hsv_image_2.png?w=300&#038;h=296" alt="HSV colour space for Image 2" width="300" height="296" /></a><a href="http://redkiing.files.wordpress.com/2011/12/imag0035.jpg"><img class="aligncenter size-full wp-image-637" title="IMAG0035" src="http://redkiing.files.wordpress.com/2011/12/imag0035.jpg?w=593&#038;h=354" alt="Yellow Colour 2" width="593" height="354" /></a><a href="http://redkiing.files.wordpress.com/2011/12/hsv_image_1.png"><img class="aligncenter" title="hsv_image_1" src="http://redkiing.files.wordpress.com/2011/12/hsv_image_1.png?w=300&#038;h=300" alt="HSV colour space for Image 1" width="300" height="300" /></a>NB : these 2 pictures were taken with different cameras. That&#8217;s why colour distribution is so different. But, hey. You got the point right ? <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Other approaches</h3>
<p>Colour segmentation is a very well-known problem in computer vision. Many papers have been written on this topic. We could have certainly used a more robust algorithm to detect homogeneous colours such <a title="detect homogeneous color regions" href="http://cg.in.tu-clausthal.de/papers/caip07/caip07_segmentation.pdf" target="_blank">as the one described in this paper</a>. This could have removed the need of constantly doing colour calibrations but would have certainly added a non negligible overhead when separating yellow colours from the rest. As one of our functional requirements was performance, a statical colour model was better suited for our needs.</p>
<h2>What&#8217;s next</h2>
<p>In this step the computer still does not know much about what we&#8217;re looking for, nor about the image it&#8217;s viewing. In the next post I&#8217;ll explain the algorithm that will help the computer understand a bit more about its environment.</p>
<h2>About the colour space visuals</h2>
<p>All renders were made with <a title="ColorSpace" href="http://www.couleur.org/index.php?page=colorspace" target="_blank">ColorSpace</a>. Many thanks to Colantoni Philippe for such an useful software.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/541/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=541&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2011/12/19/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-ii-colour-thresholding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/testimage2.png?w=300" medium="image">
			<media:title type="html">findYellowOnImage</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/colorspacergb_testimage2.png?w=300" medium="image">
			<media:title type="html">colorSpaceRGB_testImage2</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/colorspacergb_testimage2-21.png?w=300" medium="image">
			<media:title type="html">colorSpaceRGB_testImage2-2</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/colorspacehsv_testimage2-1.png?w=300" medium="image">
			<media:title type="html">colorSpaceHSV_testImage2-1</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/colorspacehsv-select_testimage2-1.png?w=300" medium="image">
			<media:title type="html">colorSpaceHSV-select_testImage2-1</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/colorspacehsv-select_testimage2-2.png?w=281" medium="image">
			<media:title type="html">colorSpaceHSV-select_testImage2-2</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20112.png" medium="image">
			<media:title type="html">frame_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/binary_screenshot_01-01-20111.png" medium="image">
			<media:title type="html">binary_screenshot_01.01.2011</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/testimage5.jpg" medium="image">
			<media:title type="html">testImage5</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/hsv_image_2.png?w=300" medium="image">
			<media:title type="html">hsv_image_2</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/imag0035.jpg" medium="image">
			<media:title type="html">IMAG0035</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/hsv_image_1.png?w=300" medium="image">
			<media:title type="html">hsv_image_1</media:title>
		</media:content>
	</item>
		<item>
		<title>The COTBLEDTCID approach to object detection and pose estimation, Part I &#8211; Preface</title>
		<link>http://redkiing.wordpress.com/2011/12/18/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-i-preface/</link>
		<comments>http://redkiing.wordpress.com/2011/12/18/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-i-preface/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 20:58:44 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Eurobot]]></category>
		<category><![CDATA[Eurobot 2011]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[Maths]]></category>
		<category><![CDATA[OpenCv]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=529</guid>
		<description><![CDATA[Introduction to the computer vision algorithms used by ClubElek for the Eurobot 2011 rules. <a href="http://redkiing.wordpress.com/2011/12/18/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-i-preface/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=529&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>A fancy acronym that stands for the process of COlour Thresholding, Blob Edge Detection, Transformation and CIrcle Detection used for locating 3D objects on a plane. The next series of posts will explain the software algorithms used by ClubElek on 2011 to achieve computer vision. The problems we faced, the solutions we implemented and most importantly what we have learned by doing this project.</p>
<p>These posts are targeted to a wide audience with some background in maths and preferably some background in computer vision. Mostly because there are some maths and magic behind the algorithms used, but I&#8217;ll try to keep them as simple and clear as possible. Should you have questions or remarks do not hesitate to comment !</p>
<p>This software was designed to detect &#8220;pawns&#8221; and &#8220;figures&#8221; defined by the Eurobot 2011 rules and was demoed during &#8220;Industrie Lyon&#8221; from 5 april to 8 april 2011. Before continuing reading this post you should read the summary about the <a title="Eurobot 2011 rules" href="http://redkiing.wordpress.com/2010/09/28/eurobot-2011/" target="_blank">rules of the contest</a> so you don&#8217;t get lost.</p>
<p>Besides the 5 previously mentioned steps, 2 other steps were necessary before attempting any computer recognition: terrain calibration and colour calibration. These 2 processes will be explained on separate posts as they are far more complex than the COTBLEDTCID itself.</p>
<p>After the pawns&#8217; positions had been detected by the means of COTBLEDTCID, they were sent wirelessly to the robot through a XBee connection.</p>
<h2>Additional requirements</h2>
<ul>
<li>The software should be used in a real-time environment. The fastest the algorithm, the better.</li>
<li>The software should be easy to use and fast to configure. (Teams have only 1 minute and 30 seconds before a match to completely set up the robot and its peripherals).</li>
</ul>
<h2>Hardware set-up</h2>
<ul>
<li>A Fit-PC-2 disk-less and fan-less computer running a customized ubuntu version controlled through ssh.</li>
<li>3 identical <a title="Microsoft LifeCam Cinema" href="http://www.microsoft.com/hardware/en-us/p/lifecam-cinema" target="_blank">Microsoft LifeCam Cinema</a> webcams. Why 3 cameras should you ask. Well, during a match, there are two robots that constantly move around the table and obfuscate large parts of the terrain, with 3 cameras chances are we see most of the objects on the playing table at any time.</li>
</ul>
<h2>Assumptions made</h2>
<ul>
<li>Light intensity remains constant during the match and after calibration.</li>
<li>The cameras do not move during the match.</li>
</ul>
<p>Both assumptions resulted to be inaccurate but did not affect the result as the detection and pose estimation algorithm is fairly robust.</p>
<h2>Shiny pics</h2>
<p>What the computer sees (note that the robot&#8217;s game field wasn&#8217;t entirely finished by the time):</p>
<p style="text-align:center;"><a href="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20111.png"><img class="size-full wp-image-534" title="whatTheComputerSees" src="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20111.png?w=593&#038;h=355" alt="What the computer sees" width="593" height="355" /></a></p>
<p>What the computer understands: (compare the pawns&#8217; position in both images. You may use the red top corner or the black area at the bottom of the image as a reference)</p>
<p><a href="http://redkiing.files.wordpress.com/2011/12/terrain_screenshot_01-01-2011.png"><img class="aligncenter size-full wp-image-535" title="whatTheComputerUnderstands" src="http://redkiing.files.wordpress.com/2011/12/terrain_screenshot_01-01-2011.png?w=593&#038;h=415" alt="what the computer understands" width="593" height="415" /></a></p>
<p>It&#8217;s fairly accurate isn&#8217;t it ?</p>
<h2>What&#8217;s next</h2>
<p>In the next section I will explain how the Colour Thresholding works and why we need it (COT for short).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/529/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=529&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2011/12/18/the-cotbledtcid-approach-to-object-detection-and-pose-estimation-part-i-preface/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/frame_screenshot_01-01-20111.png" medium="image">
			<media:title type="html">whatTheComputerSees</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/12/terrain_screenshot_01-01-2011.png" medium="image">
			<media:title type="html">whatTheComputerUnderstands</media:title>
		</media:content>
	</item>
		<item>
		<title>Capture Video with OpenCV and VideoInput (Windows only)</title>
		<link>http://redkiing.wordpress.com/2011/03/02/capture-video-with-opencv-and-videoinput-windows-only/</link>
		<comments>http://redkiing.wordpress.com/2011/03/02/capture-video-with-opencv-and-videoinput-windows-only/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 21:17:59 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[OpenCv]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=475</guid>
		<description><![CDATA[As you might have already noticed, the internal&#8217;s opencv camera interface is far from complete. You can capture video from your camera without a hassle but you&#8217;re very limited to what you can do. For instance, let&#8217;s say you have &#8230; <a href="http://redkiing.wordpress.com/2011/03/02/capture-video-with-opencv-and-videoinput-windows-only/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=475&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As you might have already noticed, the internal&#8217;s opencv camera interface is far from complete. You can capture video from your camera without a hassle but you&#8217;re very limited to what you can do.</p>
<p>For instance, let&#8217;s say you have a webcam that can run at HD resolution ( 1280 x 720 px ), you can use the <a href="http://opencv.willowgarage.com/documentation/cpp/highgui_reading_and_writing_images_and_video.html#videocapture">opencv&#8217;s class cv::VideoCapture</a> to get the frames but you&#8217;re going to have a hard time on getting the full resolution out of your device.</p>
<p>To sort out this problem, one could use specialized libraries. The disadvantage : &nbsp;they&#8217;re not usually multi platform so you&#8217;ll find yourself writing classes for every platform where you&#8217;re camera device operates.</p>
<p>Theo &nbsp;developed&nbsp;a very useful video capture library for windows called videoInput.</p>
<p><span id="more-475"></span></p>
<p>You can find <a href="https://github.com/ofTheo/videoInput">the sources here</a>, and the <a href="http://muonics.net/school/spring05/videoInput/">old site here</a>.</p>
<p>This library is already used&nbsp;internally&nbsp;in opencv and can be found somewhere in the&nbsp;source code. However, I find it easier to copy all necessary files into a 3rd party folder and configure the project using those files and cmake.</p>
<p>In this post I will show you how to easily interface the videoInput library with OpenCV. The project is functional but incomplete. Feel free to modify it and to use it as inspiration for your own projects.</p>
<h3>I Files organization</h3>
<p>The root folder is organized in two subfolders :</p>
<ul>
<li>3rdParty :
<ul>
<li>VideoInput/DShow : includes all libs used by VideoInput library itself.</li>
<li>VideoInput/include : contains the header that will be used in our project.</li>
<li>VideoInput/videoInputLib.a : the precompiled VideoInput lib to be linked to our project.</li>
</ul>
</li>
<li>src :
<ul>
<li>CameraWindows.cpp : the camera class that uses VideoInput as its backend.</li>
<li>CameraWindows.h : &nbsp;the class header.</li>
<li>main.cpp</li>
<li>CMakeLists.txt : the configuration file for our project.</li>
</ul>
</li>
</ul>
<h3>II Software architecture</h3>
<p>The CameraWindows class manages all the camera functions and settings. The constructor initializes all camera properties, there is a method to fetch new frames from the camera, a method to get the previously captured frame&nbsp;and the destructor which disconnects the device and frees up all&nbsp;resources.</p>
<p><pre class="brush: cpp;">
class CameraWindows
{
public:
	CameraWindows( const int deviceNb = 0, const int width = 1024, const int height = 720);
	bool fetchNewFrame();
	cv::Mat &amp;getFrame();
	virtual ~CameraWindows();

protected:
	videoInput mVideoInput;
        ...
	unsigned char * mBuffer;

	cv::Mat mFrame;
        ...
};
</pre></p>
<p>The constructor implementation uses videoInput :</p>
<p><pre class="brush: cpp;">
CameraWindows::CameraWindows( const int deviceNb, const int width, const int height ) :
	mDeviceNb ( deviceNb )
{
	...
	// Setup device with video size and connection type
	mVideoInput.setupDevice(mDeviceNb, width, height, VI_COMPOSITE);

	// As requested width and height can not always be accomodated
	// make sure to check the size once the device is setup
	mWidth = mVideoInput.getWidth(mDeviceNb);
	mHeight = mVideoInput.getHeight(mDeviceNb);
	mSize = mVideoInput.getSize(mDeviceNb);

	// Create the buffer where the video will be captured
	mBuffer = new unsigned char[mSize];

	// Disable autofocus and set focus to 0
	mVideoInput.setVideoSettingCamera(mDeviceNb, CameraControl_Focus, mDefaultFocus, CameraControl_Flags_Manual);

	...
}
</pre></p>
<p>The key point here is the use of <em>getPixels </em>method that will write what the camera sees into the buffer. Then if everything goes smooth, we proceed to create an image using the buffer and finally we pass that image on to the frame.</p>
<p><pre class="brush: cpp;">
bool CameraWindows::fetchNewFrame()
{
	//fills pixels in buffer as a BGR (for openCV) unsigned char array - flipping
	bool success = mVideoInput.getPixels(mDeviceNb, mBuffer, false, true);

	if( success )
	{
		cv::Mat image( mHeight, mWidth, CV_8UC3, mBuffer );
		mFrame = image;
		return true;
	}
	else
	{
		std::cout &lt;&lt; &quot;Error loading frame from camera (Windows).&quot; &lt;&lt; std::endl;
  		return false;
  	}
}
</pre></p>
<p>The program displays the camera contents in a window until a key is pressed.</p>
<p><pre class="brush: cpp;">
int main( int argc, char** argv )
{
	CameraWindows camera;

	cv::namedWindow(&quot;camera&quot;);
	 
	for( ;; )
    {
        if ( camera.fetchNewFrame() )
        {
        	cv::imshow(&quot;camera&quot;, camera.getFrame() );
        }

        if( cv::waitKey(30) &gt;= 0 )
		{
        	break;
		}
    }
	
	return 0;
}

</pre></p>
<p>And the CMakeLists.txt file. It might be a bit hard to understand if you&#8217;re not used to cmake.</p>
<p><pre class="brush: perl;">
# Project properties
SET( projectName cameraWindows )
PROJECT( ${projectName}_PRJ )
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# OPENCV
FIND_PACKAGE( OpenCV REQUIRED )

# VIDEOINPUT
FIND_PATH( VIDEO_INPUT_INCLUDE videoInput.h ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/VideoInput/include )
FIND_PATH( VIDEO_INPUT_LIB_DIR videoInputLib.a ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/VideoInput )

link_directories( ${VIDEO_INPUT_LIB_DIR}/DShow )

INCLUDE_DIRECTORIES( ${VIDEO_INPUT_INCLUDE} )
INCLUDE_DIRECTORIES( ${VIDEO_INPUT_LIB_DIR} )

SET( VINPUT_LIB ${VIDEO_INPUT_LIB_DIR}/videoInputLib.a )
SET( VINPUT_LIB2 ddraw dxguid ole32 oleaut32 strmbasd strmbase strmiids uuid )

# EXECUTABLE
ADD_EXECUTABLE( ${projectName} main.cpp CameraWindows.cpp)

TARGET_LINK_LIBRARIES( ${projectName} ${OpenCV_LIBS} ${VINPUT_LIB} ${VINPUT_LIB2} )
</pre></p>
<h3>III Setting up the CMake project</h3>
<p>As usual launch cmake and fill in the blanks. If you&#8217;re using eclipse don&#8217;t forget to indicate whether you&#8217;re using debug or release mode (CMAKE_BUILD_TYPE) and to link it with the correct opencv &nbsp;( OpenCV_DIR ).</p>
<p><a href="http://redkiing.files.wordpress.com/2011/03/cmakevideoinput.png"></a><a href="http://redkiing.files.wordpress.com/2011/03/cmakevideoinput1.png"><img class="aligncenter size-full wp-image-514" title="CMakeVideoInput" src="http://redkiing.files.wordpress.com/2011/03/cmakevideoinput1.png?w=593" alt=""   /></a><br />
Then you can open the project cmake created for you. Double click the solution file if you&#8217;re using visual studio, or import the project to your workspace if using&nbsp;ecplise.</p>
<p><a href="http://redkiing.files.wordpress.com/2011/03/importprojectvideoinput.png"><img class="aligncenter size-full wp-image-498" title="importProjectVideoInput" src="http://redkiing.files.wordpress.com/2011/03/importprojectvideoinput.png?w=593" alt=""   /></a></p>
<h3>IV Final Words &amp; Links</h3>
<p>VideoInput is very useful but I find it is poorly documented. Fortunately it is open source. You can see for example that the method setVideoSettingCamera(&#8230;) in VideoInput.h does not describe the properties nor the values you can use to set up the camera.<br />
By looking at the code, you will discover the function uses IAMCameraControl internally <a href="http://msdn.microsoft.com/en-us/library/dd389148(v=vs.85).aspx">which is well documented here</a>. That is how I discovered how to disable the autofocus of the camera (used in this example).</p>
<p><span style="text-decoration:underline;">PS : if you didn&#8217;t notice you can easily modify the code of main.cpp to use multiple cameras and multiple resolutions <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </span></p>
<p><a href="http://www.mediafire.com/file/wcu41ceeeuc3adr/VideoInput.zip"><strong>The project source files can be found here.</strong></a></p>
<p>Voilà. I hope this post will help you getting started using advanced features of your camera.<br />
Comments, remarks and questions are highly appreciated.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/475/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/475/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/475/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/475/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/475/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/475/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/475/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/475/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/475/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/475/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/475/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/475/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/475/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/475/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=475&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2011/03/02/capture-video-with-opencv-and-videoinput-windows-only/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/03/cmakevideoinput1.png" medium="image">
			<media:title type="html">CMakeVideoInput</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2011/03/importprojectvideoinput.png" medium="image">
			<media:title type="html">importProjectVideoInput</media:title>
		</media:content>
	</item>
		<item>
		<title>2010 in review</title>
		<link>http://redkiing.wordpress.com/2011/01/02/2010-in-review/</link>
		<comments>http://redkiing.wordpress.com/2011/01/02/2010-in-review/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 11:21:58 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=466</guid>
		<description><![CDATA[The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health: The Blog-Health-o-Meter™ reads Fresher than ever. Crunchy numbers A Boeing 747-400 passenger jet can hold &#8230; <a href="http://redkiing.wordpress.com/2011/01/02/2010-in-review/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=466&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health:</p>
<p><img style="border:1px solid #ddd;background:#f5f5f5;padding:20px;" src="http://s0.wp.com/i/annual-recap/meter-healthy3.gif" alt="Healthy blog!" width="250" height="183" /></p>
<p>The <em>Blog-Health-o-Meter™</em> reads Fresher than ever.</p>
<h2>Crunchy numbers</h2>
<p><a href="http://redkiing.files.wordpress.com/2010/10/vs2010opencvbuilt.jpg"><img style="max-height:230px;float:right;border:1px solid #ddd;background:#fff;margin:0 0 1em 1em;padding:6px;" src="http://redkiing.files.wordpress.com/2010/10/vs2010opencvbuilt.jpg?w=288" alt="Featured image" /></a></p>
<p>A Boeing 747-400 passenger jet can hold 416 passengers.  This blog was viewed about <strong>9,000</strong> times in 2010.  That&#8217;s about 22 full 747s.</p>
<p>In 2010, there were <strong>12</strong> new posts, growing the total archive of this blog to 33 posts. There were <strong>17</strong> pictures uploaded, taking up a total of 21mb. That&#8217;s about a picture per month.</p>
<p>The busiest day of the year was November 29th with <strong>69</strong> views. The most popular post that day was <a style="color:#08c;" href="http://redkiing.wordpress.com/2010/10/03/opencv-and-visual-studio-2010-with-cmake/">Start coding with OpenCV and VS2010 in no time</a>.</p>
<h2>Where did they come from?</h2>
<p>The top referring sites in 2010 were <strong>en.wordpress.com</strong>, <strong>sfml-dev.org</strong>, <strong>planete-sciences.org</strong>, <strong>facebook.com</strong>, and <strong>reddit.com</strong>.</p>
<p>Some visitors came searching, mostly for <strong>sfml tutorial</strong>, <strong>sfml game tutorial</strong>, <strong>sfml tutorials</strong>, <strong>sfml games</strong>, and <strong>sfml game</strong>.</p>
<h2>Attractions in 2010</h2>
<p>These are the posts and pages that got the most views in 2010.</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">1</div>
<p><a style="margin-right:10px;" href="http://redkiing.wordpress.com/2010/10/03/opencv-and-visual-studio-2010-with-cmake/">Start coding with OpenCV and VS2010 in no time</a> <span style="color:#999;font-size:8pt;">October 2010</span><br />
5 comments and 1 Like on WordPress.com,</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">2</div>
<p><a style="margin-right:10px;" href="http://redkiing.wordpress.com/2009/08/20/your-first-sfml-game-part-iii-the-main-loop/">Your first SFML game, Part IV: The main loop</a> <span style="color:#999;font-size:8pt;">August 2009</span><br />
2 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">3</div>
<p><a style="margin-right:10px;" href="http://redkiing.wordpress.com/2009/08/20/your-first-sfml-game-part-i-introduction/">Your first SFML game, Part I : Introduction</a> <span style="color:#999;font-size:8pt;">August 2009</span><br />
2 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">4</div>
<p><a style="margin-right:10px;" href="http://redkiing.wordpress.com/2009/08/20/your-first-sfml-game-part-ii-the-board/">Your first SFML game, Part II : The board</a> <span style="color:#999;font-size:8pt;">August 2009</span><br />
3 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">5</div>
<p><a style="margin-right:10px;" href="http://redkiing.wordpress.com/2009/08/20/your-first-sfml-game-part-iii-the-user-interface/">Your first SFML game, Part III: The User Interface</a> <span style="color:#999;font-size:8pt;">August 2009</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/466/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=466&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2011/01/02/2010-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/meter-healthy3.gif" medium="image">
			<media:title type="html">Healthy blog!</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2010/10/vs2010opencvbuilt.jpg?w=288" medium="image">
			<media:title type="html">Featured image</media:title>
		</media:content>
	</item>
		<item>
		<title>Brand new videos !</title>
		<link>http://redkiing.wordpress.com/2010/11/30/brand-new-videos/</link>
		<comments>http://redkiing.wordpress.com/2010/11/30/brand-new-videos/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 20:24:55 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[Eurobot]]></category>
		<category><![CDATA[Eurobot 2010]]></category>
		<category><![CDATA[Robotics]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=457</guid>
		<description><![CDATA[It&#8217;s a pleasure to announce the immediate availability of 2 new videos. The first one was originally made to recruit new members for the ClubElek&#8217;s team. It was later modified to be part of a CD we offer to our sponsors. I really think &#8230; <a href="http://redkiing.wordpress.com/2010/11/30/brand-new-videos/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=457&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a pleasure to announce the immediate availability of 2 new videos.</p>
<p>The first one was originally made to recruit new members for the ClubElek&#8217;s team. It was later modified to be part of a CD we offer to our sponsors. I really think the video made it&#8217;s purpose as there&#8217;s a troop of new people coming each week to our chamber of secrets ( also known as the ClubElek&#8217;s cave) <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The second video was made just for fun <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> . It&#8217;s an assemble of a recorded match made of three different angles.</p>
<p>Now go get some popcorn, take your favourite seat and enjoy ! (PS: Sorry if you don&#8217;t completely understand the first video because the text is in French).</p>
<span style="text-align:center; display: block;"><a href="http://redkiing.wordpress.com/2010/11/30/brand-new-videos/"><img src="http://img.youtube.com/vi/LD8sJJcubwc/2.jpg" alt="" /></a></span>
<span style="text-align:center; display: block;"><a href="http://redkiing.wordpress.com/2010/11/30/brand-new-videos/"><img src="http://img.youtube.com/vi/a7k0iuUrry8/2.jpg" alt="" /></a></span>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/457/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=457&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2010/11/30/brand-new-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>
	</item>
		<item>
		<title>Start coding with OpenCV and VS2010 in no time</title>
		<link>http://redkiing.wordpress.com/2010/10/03/opencv-and-visual-studio-2010-with-cmake/</link>
		<comments>http://redkiing.wordpress.com/2010/10/03/opencv-and-visual-studio-2010-with-cmake/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 16:30:03 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[OpenCv]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://redkiing.wordpress.com/?p=435</guid>
		<description><![CDATA[In this tutorial I'll try to explain how to get up and running in no time with OpenCV and Visual Studio 2010. <a href="http://redkiing.wordpress.com/2010/10/03/opencv-and-visual-studio-2010-with-cmake/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=435&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s usually very time-consuming to start a new project because you have to manually add the libs and include directories. And when there&#8217;s a lot of them. It&#8217;s a headache.</p>
<p>Fortunately <em>CMake</em> has made this a really easy step. You only create the CMakeLists.txt file where your project properties reside and CMake does the rest.</p>
<p><em>In this tutorial I&#8217;ll try to explain how to get up and running in no time with OpenCV and Visual Studio 2010.</em></p>
<p><span id="more-435"></span></p>
<p>First we&#8217;ll install OpenCV from the SVN repository and then we&#8217;ll create a Visual Studio project with the help of CMake.</p>
<p><strong>A &#8211; Installing TortoiseSVN</strong></p>
<p>If you&#8217;re unfamiliar with Version Control software you might not know that SVN helps you maintain revisions of your code. It&#8217;s like creating multiple backups of your project.</p>
<p>In windows, TortoiseSVN is the default utility for SVN. To install it :</p>
<ol>
<li>Go to <a href="http://tortoisesvn.net/downloads">TortoiseSVN downloads site</a> and choose the right version for you.</li>
<li>Follow the Installer instructions.</li>
</ol>
<p><strong>B &#8211; Installing CMake</strong></p>
<ol>
<li>Grab the <a href="http://www.cmake.org/cmake/resources/software.html">CMake Windows Installer</a>.</li>
<li>Follow the Installer instructions.</li>
</ol>
<p><strong>I &#8211; Grabbing the latest version of OpenCV from SVN<br />
</strong></p>
<p>A simple way of doing this, based on the <a href="http://opencv.willowgarage.com/wiki/InstallGuide">official Installation Guide</a> :</p>
<ol>
<li>Go to the Folder where you want to download the sources. i ex. &#8220;C:\Libs&#8221;.</li>
<li>Right click and choose &#8220;SVN checkout&#8221; from the Context Menu.</li>
<li>Fill in the URL : &#8220;https://code.ros.org/svn/opencv/trunk&#8221;.</li>
<li>Choose your checkout directory, for instance &#8220;C:\Libs\opencv&#8221;.</li>
<li style="text-align:left;">Click OK. It should start downloading the sources.<a href="http://redkiing.files.wordpress.com/2010/10/tortoisecheckout.jpg"><img class="size-full wp-image-436 aligncenter" title="tortoiseCheckout" src="http://redkiing.files.wordpress.com/2010/10/tortoisecheckout.jpg?w=593" alt="tortoiseCheckout"   /></a></li>
</ol>
<p><strong>II &#8211; Creating the config files with CMake</strong></p>
<p>CMake will create the necessary files to build the OpenCV sources with your favorite compiler. In our case, we&#8217;ll be using Visual Studio 2010 :</p>
<ol>
<li>Open CMake (cmake-gui).</li>
<li>Choose the source code path ( Where you downloaded OpenCV ). i. ex. &#8220;C:\Libs\opencv&#8221;</li>
<li>Choose the output directory ( Where to build the binaries ). i ex. &#8220;C:\Libs\opencv\vs2010&#8243;. Click Yes to create the directory if doesn&#8217;t exist.</li>
<li>Click on the Configure button.</li>
<li>Choose the compiler/IDE you want to use. In this case, choose Visual Studio 10. And leave the default native compiler active unless you have a reason not to.</li>
<li>Choose the options you want to use. Such as Build Examples, build doxygen docs, etc.</li>
<li>Click on the Configure button until all the conflicts are resolved ( all red lines change their color to white).</li>
<li>Click Generate.<br />
<a href="http://redkiing.files.wordpress.com/2010/10/cmakegui.jpg"><img class="size-full wp-image-438 aligncenter" title="CMakeGui" src="http://redkiing.files.wordpress.com/2010/10/cmakegui.jpg?w=593" alt="CMakeGui"   /></a></li>
</ol>
<p><strong>III &#8211; Building OpenCV</strong></p>
<p>We&#8217;ll now proceed to build openCV with Visual Studio 2010.</p>
<ol>
<li>Open the Solution file located in the binaries directory. i. ex. &#8220;C:\Libs\opencv\vs2010\OpenCV.sln&#8221;</li>
<li>Wait until all the files are completely loaded.</li>
<li>Press F7 to build the Solution.</li>
<li>That&#8217;s it <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .<br />
<a href="http://redkiing.files.wordpress.com/2010/10/vs2010opencvbuilt.jpg"><img class="aligncenter size-full wp-image-450" title="vs2010OpenCVBuilt" src="http://redkiing.files.wordpress.com/2010/10/vs2010opencvbuilt.jpg?w=593" alt="Building OpenCV"   /></a></li>
</ol>
<p><strong>IV &#8211; Creating a Project for Visual Studio</strong></p>
<p>The following instructions are based on <a href="http://opencv.willowgarage.com/wiki/Getting_started">the OpenCV page Getting Started</a>.</p>
<ol>
<li>Create a directory for your project. i. ex. &#8220;C:\Projects\myFirstOpenCvTest&#8221;</li>
<li>Add the following C++ file to the directory. Name it &#8220;main.cpp&#8221; :<br />
<pre class="brush: cpp;">
#include &lt;cv.h&gt;
#include &lt;highgui.h&gt;

int main ( int argc, char **argv )
{
// Create a window to show the image
cvNamedWindow( &quot;My Cool Window&quot; );
IplImage *img = cvCreateImage( cvSize( 300, 100 ), IPL_DEPTH_8U, 3 );

double hScale = 1.0;
double vScale = 1.0;
double shear  = 0.0;
int lineWidth = 2;

// Initialize the font
CvFont font;
cvInitFont( &amp;font, CV_FONT_HERSHEY_SCRIPT_COMPLEX, hScale, vScale, shear, lineWidth );

// Write on the image ...
CvScalar color = CV_RGB( 0, 51, 102 );
cvPutText( img, &quot;Hello World!&quot;, cvPoint( 60, 60 ), &amp;font, color );

// ... and show it to the world !
cvShowImage( &quot;My Cool Window&quot;, img );

// Wait until the user wants to exit
cvWaitKey();

return 0;
}
</pre></li>
<li>Create the &#8220;CMakeLists.txt&#8221; file, don&#8217;t forget to use the real name of your project :<br />
<pre class="brush: plain;">
SET( PROJECT_NAME project_name_goes_here )
PROJECT( ${PROJECT_NAME} )
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
FIND_PACKAGE( OpenCV REQUIRED )
ADD_EXECUTABLE( ${PROJECT_NAME} main.cpp )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${OpenCV_LIBS} )
</pre></li>
<li>And let the magic of CMake do its trick :
<ul>
<li>Open CMake and choose as the source directory the directory where you have the main.cpp and the CMakeLists.txt file.</li>
<li>Follow the same steps as in <em>II (Creating the config files with CMake).</em></li>
</ul>
</li>
</ol>
<p><strong>V &#8211; Testing your project</strong></p>
<ol>
<li>Open the Solution file of your project, located in the vs2010 directory.</li>
<li>Press F7 to build it.</li>
<li>In the Solution Explorer, right-click the name of your project/ Debug / Start new instance.<br />
You should see your Hello World text appear.<br />
<a href="http://redkiing.files.wordpress.com/2010/10/mycoolwindowopencv.jpg"><img class="size-full wp-image-447 aligncenter" title="myCoolWindowOpenCV" src="http://redkiing.files.wordpress.com/2010/10/mycoolwindowopencv.jpg?w=593" alt="myCoolWindowOpenCV"   /></a></li>
</ol>
<p>You now have a fully configured VS2010 &#8211; OpenCV project.</p>
<p><em>A piece of cake, wasn&#8217;t it ?</em></p>
<p>As a matter of fact. This procedure can easily be translated to almost any ide/compiler.</p>
<p>Questions and remarks are appreciated.</p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;overflow:hidden;">
<div class="icon"><img src="http://www.eclipse.org/downloads/images/cdt.png" alt="" width="32" /></div>
<p><span class="title"><a href="http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/heliossr1">Eclipse IDE for C/C++ Developers</a></span></p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redkiing.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redkiing.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redkiing.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redkiing.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redkiing.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redkiing.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redkiing.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redkiing.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redkiing.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redkiing.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redkiing.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redkiing.wordpress.com/435/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redkiing.wordpress.com/435/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redkiing.wordpress.com/435/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redkiing.wordpress.com&amp;blog=8839774&amp;post=435&amp;subd=redkiing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redkiing.wordpress.com/2010/10/03/opencv-and-visual-studio-2010-with-cmake/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/09a9db4b05b8f5beda1efe531651aba8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">redkiing</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2010/10/tortoisecheckout.jpg" medium="image">
			<media:title type="html">tortoiseCheckout</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2010/10/cmakegui.jpg" medium="image">
			<media:title type="html">CMakeGui</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2010/10/vs2010opencvbuilt.jpg" medium="image">
			<media:title type="html">vs2010OpenCVBuilt</media:title>
		</media:content>

		<media:content url="http://redkiing.files.wordpress.com/2010/10/mycoolwindowopencv.jpg" medium="image">
			<media:title type="html">myCoolWindowOpenCV</media:title>
		</media:content>

		<media:content url="http://www.eclipse.org/downloads/images/cdt.png" medium="image" />
	</item>
	</channel>
</rss>
