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

<channel>
	<title>Damiles</title>
	<atom:link href="http://blog.damiles.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.damiles.com</link>
	<description>Blender, OpenCV, OpenCV, Tutorials and more...</description>
	<lastBuildDate>Tue, 27 Jul 2010 12:59:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CvFileStorage. How to save our custom structures with OpenCV functions</title>
		<link>http://blog.damiles.com/?p=262</link>
		<comments>http://blog.damiles.com/?p=262#comments</comments>
		<pubDate>Wed, 10 Feb 2010 14:29:54 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=262</guid>
		<description><![CDATA[In this tutorial we go to show how to save our custom structures with opencv functions.
We go to imagine we have this structure in our program.
typedef struct
{
	float var1;
	unsigned char var2[255];
}MyStructure;
Opencv can save data in two formats: XML or YAML. This formats are markup languages.
For write or read a file, we go to use cvOpenFileStorage function, [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial we go to show how to save our custom structures with opencv functions.</p>
<p>We go to imagine we have this structure in our program.<span id="more-262"></span></p>
<pre class="brush: cpp;">typedef struct
{
	float var1;
	unsigned char var2[255];
}MyStructure;</pre>
<p>Opencv can save data in two formats: XML or YAML. This formats are markup languages.</p>
<p>For write or read a file, we go to use cvOpenFileStorage function, the functions returns  a CvFileStorage structure pointer. This pointer we use to read or write values into.</p>
<p>We can open a file in two ways: for read or write. The function to open file is <a title="cvOpenFileStorage - OpenCV Wiki" href="http://opencv.willowgarage.com/documentation/xml/yaml_persistence.html?highlight=cvopenfilestorage#cvOpenFileStorage" target="_blank">cvOpenFileStorage</a></p>
<pre class="brush: cpp;">CvFileStorage* storage = cvOpenFileStorage( file, 0, CV_STORAGE_WRITE_TEXT );</pre>
<p>One time we have our CvFileStorage initialized then we can save our data. To save the data we need create Nodes. XML and YAML are markup languages, and they are defined with nodes.</p>
<p>First we go to create one node that contains all structure data. And inside of this node we need create one node for each variable.</p>
<p>For create a node we need open and close this node, as we do with xml, then we use <a href="http://opencv.willowgarage.com/documentation/xml/yaml_persistence.html#startwritestruct" target="_blank">cvStartWriteStruct</a> and <a href="http://opencv.willowgarage.com/documentation/xml/yaml_persistence.html#endwritestruct" target="_blank">cvEndWriteStruct</a>.</p>
<pre class="brush: cpp;">cvStartWriteStruct(storage, &quot;MyStructure&quot;, CV_NODE_MAP, NULL, cvAttrList(0,0));
...
cvEndWriteStruct(storage);</pre>
<p>Between the start and end node we go to insert each new node with asigned variable. The variable we must save as some of this types: int, raw (array), real or string with this functions:</p>
<ul>
<li><a href="http://opencv.willowgarage.com/documentation/xml/yaml_persistence.html#writeint" target="_blank"><tt>cvWriteInt</tt></a></li>
<li><a href="http://opencv.willowgarage.com/documentation/xml/yaml_persistence.html#writerawdata" target="_blank"><tt>cvWriteRawData</tt></a></li>
<li><a href="http://opencv.willowgarage.com/documentation/xml/yaml_persistence.html#writereal" target="_blank"><tt>cvWriteReal</tt></a></li>
<li><a href="http://opencv.willowgarage.com/documentation/xml/yaml_persistence.html#writestring" target="_blank"><tt>cvWriteString</tt></a></li>
</ul>
<p>Then for save our structure we go to create this code:</p>
<pre class="brush: cpp;">
//Open file
CvFileStorage* storage = cvOpenFileStorage( file, 0, CV_STORAGE_WRITE_TEXT );
//Create our node for structure
cvStartWriteStruct(storage, &quot;MyStructure&quot;, CV_NODE_MAP, NULL, cvAttrList(0,0));
//Write our float
cvWriteReal( storage, &quot;var1&quot;, MyStructure-&gt;var1 );

//Write our array
cvStartWriteStruct(storage, &quot;var2&quot;, CV_NODE_SEQ, NULL, cvAttrList(0,0));
cvWriteRawData(storage, MyStructure-&gt;var2,255,&quot;u&quot;);
cvEndWriteStruct(storage);

//End node structure
cvEndWriteStruct(storage);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=262</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Pseudocolor implementation with OpenCV.</title>
		<link>http://blog.damiles.com/?p=244</link>
		<comments>http://blog.damiles.com/?p=244#comments</comments>
		<pubDate>Thu, 28 Jan 2010 21:19:56 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cvFileNode]]></category>
		<category><![CDATA[cvWriteRawData]]></category>
		<category><![CDATA[HighGui]]></category>
		<category><![CDATA[Pseudocolor]]></category>
		<category><![CDATA[Save]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=244</guid>
		<description><![CDATA[In Computer Vision works in a lot of cases with gray images because there are a lot of motives. But human vision don&#8217;t perceives the gray levels so well as color levels.
Then if we need show a image to a person, we can color it. But, how is the best way to coloring gray image?
There [...]]]></description>
			<content:encoded><![CDATA[<p>In Computer Vision works in a lot of cases with gray images because there are a lot of motives. But human vision don&#8217;t perceives the gray levels so well as color levels.</p>
<p>Then if we need show a image to a person, we can color it. But, how is the best way to coloring gray image?</p>
<p>There are 3 ways to do it: Manually, automatically and colored by ranges.</p>
<p>In this tutorial, i go to develop the way most common automatic for gray image coloring.</p>
<p>To do it we need know we go to receive a gray level and we need return 3 values, one for red, one for blue and other for green.</p>
<p>We go to use this function:</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%20s%28x%2Cy%29%3D%5Cvert%20sin%28r%28x%2Cy%29%2Ap%2API%20%2B%20%5CTheta%2API%29%5Cvert%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{ s(x,y)=\vert sin(r(x,y)*p*PI + \Theta*PI)\vert}' title='\displaystyle{ s(x,y)=\vert sin(r(x,y)*p*PI + \Theta*PI)\vert}' class='latex' /></p>
<p>And r(x,y) is the gray level and p is the number of repetitions and <img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%20%5CTheta%20%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{ \Theta }' title='\displaystyle{ \Theta }' class='latex' /> is the displacement.</p>
<p>Then we only need define the p and <img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%20%5CTheta%20%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{ \Theta }' title='\displaystyle{ \Theta }' class='latex' /> for each channel.</p>
<p>If we create a plot with this function with this parameters for red, green and blue ((2,0),(2,-0.1),(2,-0.3)) we get:</p>
<div id="attachment_253" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.damiles.com/wp-content/uploads//2010/01/graph.gif"><img class="size-medium wp-image-253 " title="graph" src="http://blog.damiles.com/wp-content/uploads//2010/01/graph-300x218.gif" alt="Pseudocolor Graph" width="300" height="218" /></a><p class="wp-caption-text">Pseudocolor Graph with red(p=2,theta=0) green(2,-0.1) and blue(2,-0.3)</p></div>
<p>Then we only need set the gray level in range 0 to 1 and the sine returns values from 0 to 1 we interpret as float image values or we set in range 0 to 255.</p>
<p>To finish this is the result:</p>
<div id="attachment_255" class="wp-caption aligncenter" style="width: 397px"><a href="http://blog.damiles.com/wp-content/uploads//2010/01/pseudocolor.jpg"><img class="size-medium wp-image-255" title="pseudocolor" src="http://blog.damiles.com/wp-content/uploads//2010/01/pseudocolor-300x238.jpg" alt="Pseudocolor Result" width="387" height="308" /></a><p class="wp-caption-text">Pseudocolor Result</p></div>
<p><a title="Code" href="http://www.damiles.com/resource.jsp?f=14" target="_blank">Download the code.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=244</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Neuroph, Java/Netbeans tutorial.</title>
		<link>http://blog.damiles.com/?p=242</link>
		<comments>http://blog.damiles.com/?p=242#comments</comments>
		<pubDate>Thu, 21 Jan 2010 08:23:49 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[clasification]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[neuroph]]></category>
		<category><![CDATA[recognition]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=242</guid>
		<description><![CDATA[Neuroph is a Neural network for image recognition in java. In netbeans dzone are a netbeans/java tutorial for image recognition with neuroph library.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://neuroph.sourceforge.net/" target="_blank">Neuroph</a> is a Neural network for image recognition in java. In <a href="http://netbeans.dzone.com/articles/neuroph-smart-java-apps-neural-1" target="_blank">netbeans dzone</a> are a netbeans/java tutorial for image recognition with neuroph library.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=242</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Chamilo. The new e-learning platform</title>
		<link>http://blog.damiles.com/?p=241</link>
		<comments>http://blog.damiles.com/?p=241#comments</comments>
		<pubDate>Tue, 19 Jan 2010 10:32:02 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[e-learning]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=241</guid>
		<description><![CDATA[Today is born the new e-learning platform. Chamilo!
Chamilo is a new project that opts for open source in a radical way. It aims at bringing you the best e-learning and collaboration platform in the open source world.
]]></description>
			<content:encoded><![CDATA[<p>Today is born the new e-learning platform. <a href="http://www.chamilo.org/" target="_blank">Chamilo!</a></p>
<p>Chamilo is a new project that opts for open source in a radical way. It aims at bringing you the best e-learning and collaboration platform in the open source world.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=241</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Segmentation &amp; object detection by color.</title>
		<link>http://blog.damiles.com/?p=205</link>
		<comments>http://blog.damiles.com/?p=205#comments</comments>
		<pubDate>Sat, 16 Jan 2010 20:40:09 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[cvDrawContours]]></category>
		<category><![CDATA[cvFindContours]]></category>
		<category><![CDATA[cvMorphologyEx]]></category>
		<category><![CDATA[pixel]]></category>
		<category><![CDATA[segmentation]]></category>
		<category><![CDATA[threshold]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=205</guid>
		<description><![CDATA[In this tutorial i go to explain how to image segmentation or detect objects byred color, in this case by red color.
This task is simple, but there are some things we must known.
Now i go to explain and get a demo code for segmentation, how to determine if each image pixel is red or no, [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial i go to explain how to image segmentation or detect objects byred color, in this case by red color.</p>
<p>This task is simple, but there are some things we must known.</p>
<p>Now i go to explain and get a demo code for segmentation, how to determine if each image pixel is red or no, and then, i go to explain how we  can detect object, it&#8217;s similar but with diferent concept.<span id="more-205"></span></p>
<p>In first moment, we can decide get the red channel of image  and get the values, if it&#8217;s a higher value then we have a red pixel otherwise no.</p>
<p>This is incorrect. Why?, imagine we have a pixel and in his red channel have a 255 value, this is the higher value, then we decide this is a red pixel, but if in green and blue channel have 255 value too then we have a white pixel instead a red pixel. Then how we determine if a pixel is red or no?</p>
<p>Ok, we go to get some color values and determine how we decide if is red or no.</p>
<p><a href="http://blog.damiles.com/wp-content/uploads//2010/01/colors.jpg"><img class="aligncenter size-full wp-image-206" title="colors" src="http://blog.damiles.com/wp-content/uploads//2010/01/colors.jpg" alt="" width="440" height="138" /></a></p>
<p>Then we can decide that higher red value, and  lower values of blue and green can be defined as red color. Moreover the green and blue values don&#8217;t have a higher difference between his values.</p>
<p>We go to construct simple graph with some values to see better.</p>
<p><a href="http://blog.damiles.com/wp-content/uploads//2010/01/histo_colors.jpg"><img class="aligncenter size-full wp-image-207" title="histo_colors" src="http://blog.damiles.com/wp-content/uploads//2010/01/histo_colors.jpg" alt="" width="300" height="325" /></a></p>
<p>We see in this graph that the red value is higher than a max value and there are a min value for green and blue.</p>
<p>The min and max we go to name as blue green threshold and red threshold (bg_threshold, r_threshold).</p>
<p>This code compute for each pixel if it&#8217;s red or no, and create a black/white image, this is our segmentation image, and with this image we can use to label each object, we use a cvFindContours to retreive the contours of each object detected on our image.</p>
<pre class="brush: cpp;">
 for(y=0;yheight; y++)
 {
 red=((uchar*)(img-&gt;imageData + img-&gt;widthStep*y))[x*3+2];
 green=((uchar*)(img-&gt;imageData + img-&gt;widthStep*y))[x*3+1];
 blue=((uchar*)(img-&gt;imageData + img-&gt;widthStep*y))[x*3];
 uchar* temp_ptr=&amp;((uchar*)(img_result_threshold-&gt;imageData + img_result_threshold-&gt;widthStep*y))[x];

 if((red&gt;threshold)&amp;&amp;(green &lt; BG_threshold) &amp;&amp; (blue &lt; BG_threshold) &amp;&amp; (abs(green-blue)&lt; BG_diff)){
 temp_ptr[0]=255;//White to greater of threshold
 }else{
 temp_ptr[0]=0;//Black other
 }
 }
 }

 cvMorphologyEx(img_result_threshold, img_morph, img_temp, NULL, CV_MOP_CLOSE, 6);

 cvNamedWindow( &quot;Threshold&quot;, 1 );
 cvShowImage( &quot;Threshold&quot;, img_morph );

 cvFindContours( img_morph, storage, &amp;contour, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) );

 for( ; contour != 0; contour = contour-&gt;h_next )
 {
 CvScalar color = CV_RGB( rand()&amp;255, rand()&amp;255, rand()&amp;255 );
 cvDrawContours( img, contour, color, color, -1, 3, 8, cvPoint(0,0) );
 }
</pre>
<p>And this is the result, whe can see in the image a color border with detected red objects, the system detect two objects. The notebook and the notebook corner</p>
<p><a href="http://blog.damiles.com/wp-content/uploads//2010/01/captura.jpg"><img class="aligncenter size-medium wp-image-217" title="captura" src="http://blog.damiles.com/wp-content/uploads//2010/01/captura-300x156.jpg" alt="" width="300" height="156" /></a><a href="http://www.damiles.com/resource.jsp?f=13" target="_blank">Demo Source</a></p>
<p>This is perfect to image segmentation by color, but imagine we have objects ofone image, and we want get each object and know if this object have a predominant red color or no.</p>
<p>The theory is same but applied to the object histogram, and use the median to determine the thresholds</p>
<p><a href="http://blog.damiles.com/wp-content/uploads//2010/01/histo_1.jpg"><img class="aligncenter size-full wp-image-218" title="histo_1" src="http://blog.damiles.com/wp-content/uploads//2010/01/histo_1.jpg" alt="" width="400" height="143" /></a></p>
<p>But with this we don&#8217;t have enough, because we can get a gray image as we can see in the second histogram, then we need use another parameter more, the dispersion of each channel.</p>
<p><a href="http://blog.damiles.com/wp-content/uploads//2010/01/histo_2.jpg"><img class="aligncenter size-full wp-image-219" title="histo_2" src="http://blog.damiles.com/wp-content/uploads//2010/01/histo_2.jpg" alt="" width="400" height="185" /></a></p>
<p>We can see that in this first histogram we can ensure this object have a predominant red, and in the second histogram no.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=205</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>VIM how to remove ^M at the end of lines</title>
		<link>http://blog.damiles.com/?p=189</link>
		<comments>http://blog.damiles.com/?p=189#comments</comments>
		<pubDate>Tue, 12 Jan 2010 08:37:17 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=189</guid>
		<description><![CDATA[In unix the end of line is different than other systems. More times we edit windows files and when open in VI/VIM we see the ^M character at end of lines.
We can remove this characters with a simply search and replace of vim with this command:
:%s/^M//g
The ^M character is not valid write first ^ character [...]]]></description>
			<content:encoded><![CDATA[<p>In unix the end of line is different than other systems. More times we edit windows files and when open in VI/VIM we see the ^M character at end of lines.</p>
<p>We can remove this characters with a simply search and replace of vim with this command:</p>
<blockquote><p><code>:%s/^M//g</code></p></blockquote>
<p>The ^M character is not valid write first ^ character and then M it&#8217;s not the valid character. To write correctly this we must push <strong>Control+v </strong>and<strong> Contro+M</strong> keys, then appear our ^M Character.</p>
<p>Take care with this.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=189</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile Opencv with Mac os Snow Leopard 10.6</title>
		<link>http://blog.damiles.com/?p=181</link>
		<comments>http://blog.damiles.com/?p=181#comments</comments>
		<pubDate>Tue, 08 Sep 2009 13:47:41 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=181</guid>
		<description><![CDATA[Today i try install OpenCv in my MacOs Snow Leopard 10.6 and have this error:
 error: CPU you selected does not support x86-64 instruction set
The searching in google have the solution
go to opencv folder and edit configure file, searchi prescott and replace the line
DEFAULT_CXXFLAGS=&#8221;-g -march=prescott -ffast-math -fomit-frame-pointer $DEFAULT_CXXFLAGS&#8221;
with this:
DEFAULT_CXXFLAGS=&#8221;-g -march=i686 -m32 -ffast-math -fomit-frame-pointer $DEFAULT_CXXFLAGS&#8221;
But when [...]]]></description>
			<content:encoded><![CDATA[<p>Today i try install OpenCv in my MacOs Snow Leopard 10.6 and have this error:</p>
<p><span> <span class="highlight">error</span>: <span class="highlight">CPU</span> <span class="highlight">you</span> <span class="highlight">selected</span> <span class="highlight">does</span> <span class="highlight">not</span> <span class="highlight">support</span> <span class="highlight">x86</span>-<span class="highlight">64</span> <span class="highlight">instruction</span> <span class="highlight">set</span></span></p>
<p>The searching in google have the solution</p>
<p>go to opencv folder and edit configure file, searchi prescott and replace the line</p>
<p>DEFAULT_CXXFLAGS=&#8221;-g -march=prescott -ffast-math -fomit-frame-pointer $DEFAULT_CXXFLAGS&#8221;</p>
<p>with this:</p>
<p>DEFAULT_CXXFLAGS=&#8221;-g -march=i686 -m32 -ffast-math -fomit-frame-pointer $DEFAULT_CXXFLAGS&#8221;</p>
<p>But when i try to compile i have other error i now looking for how to resolve it</p>
<p><strong>Now i can install opencv lib with macport!!!<span id="more-181"></span><br />
</strong></p>
<p>1.- i have old macport then first i need clean and delete it.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">port installed <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> myports.<span style="color: #202020;">txt</span>
&nbsp;
sudo port clean installed
&nbsp;
sudo port <span style="color: #339933;">-</span>f uninstall installed</pre></div></div>

<p>2.- Install ports you need you can see myports.txt to know the old ports you have installed before clean.</p>
<p>3.- Patch the opencv port: see http://trac.macports.org/ticket/21014 and download the patch <a title="View attachment" href="http://trac.macports.org/raw-attachment/ticket/21014/Portfile-sl_64bit_21014.diff">Portfile-sl_64bit_21014.diff</a></p>
<p>4.- Follow the instruction in post of patch</p>
<blockquote><p>Check where you installed <span class="searchword0">macport</span>s, that is usually /opt/local/ Locate the Portfile for <span class="searchword1">OpenCV</span>, for me that is at</p>
<p>/opt/local/var/<span class="searchword0">macport</span>s/sources/rsync.macports.org/release/ports/graphics/<span class="searchword1">opencv</span></p>
<p>now apply the third patch (Portfile-sl_64bit_21014.diff) by executing</p>
<p>sudo patch Portfile -i ~/Downloads/Portfile-sl_64bit_21014.diff</p>
<p>in the above directory (adjust the last path accordingly to your download location)</p>
<p>When you execute port variants <span class="searchword1">opencv</span> you should see the sl_64bit_21014 variant. Now install opencv with</p>
<p>sudo port install <span class="searchword1">opencv</span> +sl_64bit_21014</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=181</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Exuberant CTags and OpenCV with Vim. Thanks Piponazo!!</title>
		<link>http://blog.damiles.com/?p=179</link>
		<comments>http://blog.damiles.com/?p=179#comments</comments>
		<pubDate>Thu, 16 Jul 2009 10:02:44 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[other]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=179</guid>
		<description><![CDATA[Piponazo have a wonderful spanish tutorial explianing how use Exuberant CTags in vim with a opencv as example and some tips for correct import ctags of opencv.
Exuberant Ctags tutorial. &#8220;La plaga Tux&#8221;

Thanks Piponazo.
]]></description>
			<content:encoded><![CDATA[<p>Piponazo have a wonderful spanish tutorial explianing how use Exuberant CTags in vim with a opencv as example and some tips for correct import ctags of opencv.</p>
<p><a title="La plaga tux" href="http://plagatux.es/2009/02/generar-etiquetas-con-ctags-y-usarlas-en-vim/comment-page-1/#comment-1716" target="_blank">Exuberant Ctags tutorial. &#8220;La plaga Tux&#8221;<br />
</a></p>
<p>Thanks Piponazo.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=179</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The basics of background substraction</title>
		<link>http://blog.damiles.com/?p=127</link>
		<comments>http://blog.damiles.com/?p=127#comments</comments>
		<pubDate>Wed, 25 Mar 2009 14:20:02 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Works]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=127</guid>
		<description><![CDATA[This tutorial explain the basics of background substraction. First of all we need define what is a background and what is a foreground.
We consider a background the pixels of image without motion. And a foreground the pixels with motion. Then the simplest background model assume each background pixel his brightness varies independently with normal distribution. [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial explain the basics of background substraction. First of all we need define what is a background and what is a foreground.</p>
<p>We consider a background the pixels of image without motion. And a foreground the pixels with motion. Then the simplest background model assume each background pixel his brightness varies independently with normal distribution. Then we can calculate our statistical model of background by accumulating several dozens of frames and his squares, this is:</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7BS%28x%2Cy%29%3D%5Csum_%7Bf%3D1%7D%5EN%20p%28x%2Cy%29%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{S(x,y)=\sum_{f=1}^N p(x,y)}' title='\displaystyle{S(x,y)=\sum_{f=1}^N p(x,y)}' class='latex' /><br />
<img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7BSq%28x%2Cy%29%3D%5Csum_%7Bf%3D1%7D%5EN%20p%28x%2Cy%29%5E2%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{Sq(x,y)=\sum_{f=1}^N p(x,y)^2}' title='\displaystyle{Sq(x,y)=\sum_{f=1}^N p(x,y)^2}' class='latex' /></p>
<p><span id="more-127"></span>Where:</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7Bf%3Dframe%3B%20N%3D%20total%20frames%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{f=frame; N= total frames}' title='\displaystyle{f=frame; N= total frames}' class='latex' /></p>
<p>Then the average is:</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7BM%28x%2Cy%29%3D%5Cfrac%7BS%28x%2Cy%29%7D%7BN%7D%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{M(x,y)=\frac{S(x,y)}{N}}' title='\displaystyle{M(x,y)=\frac{S(x,y)}{N}}' class='latex' /></p>
<div id="attachment_160" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.damiles.com/wp-content/uploads//2009/03/mean.jpg"><img class="size-medium wp-image-160" title="mean" src="http://blog.damiles.com/wp-content/uploads//2009/03/mean-300x210.jpg" alt="BG substraction mean pixel" width="300" height="210" /></a><p class="wp-caption-text">BG substraction mean pixel</p></div>
<p>And need the standar derivation for our statistical model:</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%5Csigma%28x%2Cy%29%3D%5Csqrt%7B%20%5Cfrac%7BSq%28x%2Cy%29%7D%7BN%7D%20-%20M%28x%2Cy%29%5E2%20%7D%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{\sigma(x,y)=\sqrt{ \frac{Sq(x,y)}{N} - M(x,y)^2 }}' title='\displaystyle{\sigma(x,y)=\sqrt{ \frac{Sq(x,y)}{N} - M(x,y)^2 }}' class='latex' /></p>
<p>Then, when we have our statistical background model, we can give a image and divide it in background and foreground, the pixels that are in foreground are the P(x,y) that met this condition:</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%20%7C%20M%28x%2Cy%29%20-%20P%28x%2Cy%29%20%7C%20%5Cge%20%5Clambda%20%5Csigma%28x%2Cy%29%20%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{ | M(x,y) - P(x,y) | \ge \lambda \sigma(x,y) }' title='\displaystyle{ | M(x,y) - P(x,y) | \ge \lambda \sigma(x,y) }' class='latex' /></p>
<p>For optimize a litle the operations we can use this for evaluate the condition:</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%20%7B%7C%20M%28x%2Cy%29%20-%20P%28x%2Cy%29%20%7C%7D%5E2%20%5Cge%20%7B%28%5Clambda%20%5Csigma%28x%2Cy%29%29%7D%5E2%20%20%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{ {| M(x,y) - P(x,y) |}^2 \ge {(\lambda \sigma(x,y))}^2  }' title='\displaystyle{ {| M(x,y) - P(x,y) |}^2 \ge {(\lambda \sigma(x,y))}^2  }' class='latex' /></p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%20%7B%7C%20M%28x%2Cy%29%20-%20P%28x%2Cy%29%20%7C%7D%5E2%20%5Cge%20%5Clambda%5E2%20%5Csigma%28x%2Cy%29%5E2%20%20%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{ {| M(x,y) - P(x,y) |}^2 \ge \lambda^2 \sigma(x,y)^2  }' title='\displaystyle{ {| M(x,y) - P(x,y) |}^2 \ge \lambda^2 \sigma(x,y)^2  }' class='latex' /></p>
<p>Where <img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%20sigma%28x%2Cy%29%5E2%20%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{ sigma(x,y)^2 }' title='\displaystyle{ sigma(x,y)^2 }' class='latex' /> is</p>
<p><img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%5Csigma%28x%2Cy%29%5E2%20%3D%20%5Cfrac%7BSq%28x%2Cy%29%7D%7BN%7D%20-%20M%28x%2Cy%29%5E2%20%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{\sigma(x,y)^2 = \frac{Sq(x,y)}{N} - M(x,y)^2 }' title='\displaystyle{\sigma(x,y)^2 = \frac{Sq(x,y)}{N} - M(x,y)^2 }' class='latex' /></p>
<p>And <img src='http://s.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%20%5Clambda%20%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\displaystyle{ \lambda }' title='\displaystyle{ \lambda }' class='latex' /> is a constant or variable and we can set it to 3, it is the well-known &#8220;three sigmas&#8221; rule.</p>
<div id="attachment_161" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.damiles.com/wp-content/uploads//2009/03/sig.jpg"><img class="size-medium wp-image-161" title="sig" src="http://blog.damiles.com/wp-content/uploads//2009/03/sig-300x210.jpg" alt="BG substraction Standar derivation compare" width="300" height="210" /></a><p class="wp-caption-text">BG substraction Standar derivation compare</p></div>
<p>Ok, then we now have the theory, then, we go to implement it.</p>
<p>To develop it opencv give us some functions, cvAcc and cvSquareAcc</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">cvAcc<span style="color: #009900;">&#40;</span>frame<span style="color: #339933;">,</span>acc<span style="color: #339933;">,</span>NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cvSquareAcc<span style="color: #009900;">&#40;</span>frame<span style="color: #339933;">,</span> sqacc<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
N<span style="color: #339933;">++;</span>
cvConvertScale<span style="color: #009900;">&#40;</span>acc<span style="color: #339933;">,</span> M<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0</span><span style="color: #339933;">/</span>N<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cvConvertScale<span style="color: #009900;">&#40;</span>sqacc<span style="color: #339933;">,</span> sqaccM<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color:#800080;">1.0</span><span style="color: #339933;">/</span>N<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cvMul<span style="color: #009900;">&#40;</span> M<span style="color: #339933;">,</span> M<span style="color: #339933;">,</span> M2<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cvSub<span style="color: #009900;">&#40;</span> sqaccM<span style="color: #339933;">,</span> M2<span style="color: #339933;">,</span> sig2<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//The sig is sig2</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//For detect FG Condition</span>
cvConvertScale<span style="color: #009900;">&#40;</span>sig2<span style="color: #339933;">,</span> lambda_sig2<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #009900;">&#41;</span><span style="color: #0000dd;">9</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cvSub<span style="color: #009900;">&#40;</span>M<span style="color: #339933;">,</span> frame<span style="color: #339933;">,</span> leftCondition<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cvMul<span style="color: #009900;">&#40;</span>leftCond<span style="color: #339933;">,</span> leftCond<span style="color: #339933;">,</span> leftCond2<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Compare leftCondition &amp;gt; lambda_sig2</span>
<span style="color: #666666; font-style: italic;">//to detect foreground.</span></pre></div></div>

<p>Results:</p>
<p><a href="http://blog.damiles.com/wp-content/uploads//2009/03/captura1.jpg"><img class="aligncenter size-medium wp-image-159" title="BG substraction capture" src="http://blog.damiles.com/wp-content/uploads//2009/03/captura1-300x121.jpg" alt="" width="300" height="121" /></a></p>
<p>Note:<br />
This code is an example and it&#8217;s no completed.<br />
In next tutorial a more advanced background substranction.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=127</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>BlenderOcv, &#8220;blender&#8221; can be good and powerful tool for computer vision with OpenCV</title>
		<link>http://blog.damiles.com/?p=116</link>
		<comments>http://blog.damiles.com/?p=116#comments</comments>
		<pubDate>Sun, 21 Dec 2008 19:57:47 +0000</pubDate>
		<dc:creator>damiles</dc:creator>
				<category><![CDATA[Blender]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Works]]></category>
		<category><![CDATA[blenderocv]]></category>

		<guid isPermaLink="false">http://blog.damiles.com/?p=116</guid>
		<description><![CDATA[This is the question: can be Blender a powerful tool for computer vision with OpenCv.
Blender is now a powerful suite of 3d content creation, where have a various characteristich as animation, composit, shade, model, texture, interactive &#8230; And OpenCV is ga powerful realtime library for computer Vision.
Then my goal is provide a new and powerfull [...]]]></description>
			<content:encoded><![CDATA[<p>This is the question: can be Blender a powerful tool for computer vision with OpenCv.</p>
<p>Blender is now a powerful suite of 3d content creation, where have a various characteristich as animation, composit, shade, model, texture, interactive &#8230; And OpenCV is ga powerful realtime library for computer Vision.</p>
<p>Then my goal is provide a new and powerfull tool based on Blender for Computer Vision Tasks with OpenCV Library.</p>
<p>How?, with a particular characteristic of Blender, the compositor node.</p>
<p>Nodes are a good tool that provide a user interactive, each node is a box with inputs and outputs that implement a function. Each node have interactive parameters that user can be set.</p>
<p><span id="more-116"></span></p>
<p>Each node can be linked with others nodes linking outputs to inputs</p>
<p>In this <a rel="nofollow" href="http://www.blender.org/development/release-logs/blender-242/blender-composite-nodes/">page</a> we can see more about node compositor</p>
<p>With this properties we can create a workflow of a computer vision tasks.</p>
<p>For example here are the basic edge detection with blenderocv, this example implement the basic opencv sample &#8220;edge.c&#8221;</p>
<div id="attachment_117" class="wp-caption alignright" style="width: 310px"><a href="http://blog.damiles.com/wp-content/uploads/2008/12/screenshot.jpg"><img class="size-medium wp-image-117 " title="edge_blenderocv" src="http://blog.damiles.com/wp-content/uploads/2008/12/screenshot-300x177.jpg" alt="Blenderocv - edge (canny)" width="300" height="177" /></a><p class="wp-caption-text">Blenderocv - edge (canny)</p></div>
<p>Now there are a demo with some few functions.</p>
<p>I have to implement a lot of functions as nodes, and now there are a lot of work to do, and sure i make important decisions in development. If anybody want colaborate with this project, please send me mail (david at artresnet dot com) or send me a comment.</p>
<p>There are more info and progress about this project in <a title="blenderocv" href="http://code.google.com/p/blenderocv/" target="_blank">http://code.google.com/p/blenderocv/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.damiles.com/?feed=rss2&amp;p=116</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
