<?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>Md. Iftekhar Tanveer</title>
	<atom:link href="http://www.itanveer.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.itanveer.com</link>
	<description>Chasing the Illusive Muse</description>
	<lastBuildDate>Fri, 18 May 2012 15:01:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Linear Algebra in OpenCV: Post 2</title>
		<link>http://www.itanveer.com/2012/linear-algebra-in-opencv-post2/</link>
		<comments>http://www.itanveer.com/2012/linear-algebra-in-opencv-post2/#comments</comments>
		<pubDate>Fri, 18 May 2012 14:45:05 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[Linear Algebra in OpenCV]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming & Technology]]></category>
		<category><![CDATA[Novice]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=671</guid>
		<description><![CDATA[In the last post, we saw the basic methods to load and display matrices. Let us see some more aspects of an OpenCV matrix. Matrix Assignment and Cloning In opencv, the assignment (&#8220;=&#8221;) operator does not copy a matrix. It &#8230; <a href="http://www.itanveer.com/2012/linear-algebra-in-opencv-post2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">In the last post, we saw the basic methods to load and display matrices. Let us see some more aspects of an OpenCV matrix.</p>
<h2 style="text-align: justify;">Matrix Assignment and Cloning</h2>
<p style="text-align: justify;">In opencv, the assignment (&#8220;=&#8221;) operator does not copy a matrix. It only attaches a new label or alias to a matrix. In c/c++ when we write A = B, we expect A and B to be two different variables with same value. However, in OpenCV, such an assignment operation will actually say that A and B are invariably the same matrix. This will be illustrated in the following opencv snippet.<span id="more-671"></span></p>
<table border="0">
<tbody>
<tr>
<td>Program Code</td>
<td>Program Output</td>
</tr>
<tr>
<td>
<pre class="brush: cpp; title: ; notranslate">
cv::Mat MyMat = cv::Mat::eye(3,3,CV_64FC1);
cv::Mat AnotherMat = MyMat;
AnotherMat.at(1,2) = 5.5;
std::cout&lt;&lt;MyMat;
</pre>
</td>
<td><img src='http://s.wordpress.com/latex.php?latex=%5Cbegin%7Barray%7D%7Bccc%7D%20%5B1%2C%20%26%200%2C%20%26%200%3B%5C%5C%200%2C%20%26%201%2C%20%26%205.5%3B%5C%5C%200%2C%20%26%200%2C%20%26%201%3B%5D%20%5Cend%7Barray%7D%20&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\begin{array}{ccc} [1, &amp; 0, &amp; 0;\\ 0, &amp; 1, &amp; 5.5;\\ 0, &amp; 0, &amp; 1;] \end{array} ' title='\begin{array}{ccc} [1, &amp; 0, &amp; 0;\\ 0, &amp; 1, &amp; 5.5;\\ 0, &amp; 0, &amp; 1;] \end{array} ' class='latex' /></td>
</tr>
</tbody>
</table>
<div style="text-align: justify;">Notice that although we have changed &#8220;AnotherMat&#8221;, &#8220;MyMat&#8221; has been changed. This is because, both names actually point to the same matrix. If we want to create a new matrix, we need to use</div>
<p style="text-align: justify;">the clone() method. For example, if we change the 2nd line of this code by the following line, then &#8220;MyMat&#8221; will not be changed anymore when we&#8217;ll change the &#8221;AnotherMat&#8221; matrix.</p>
<pre class="brush: cpp; title: ; notranslate">cv::Mat AnotherMat = MyMat.clone();</pre>
<p style="text-align: justify;">When we use the clone method, a deep copy of all the elements take place. So, for big matrices, the clone operation may take considerably longer time than the assignment operation. According to the language of OpenCV documentation, the matrix data is copied in clone operation whereas only the matrix header is copied in simple assignments. Header actually means some basic information about a matrix such as, the number of rows, columns, number of channels, data type etc. Sometimes, we might need to change the header. To do that, we can use the create() method. The following code will clarify its use.</p>
<pre class="brush: cpp; title: ; notranslate">
cv::Mat MyMat = cv::Mat::eye(3,3,CV_64FC1);
MyMat.create(2,2,CV_64FC1);
MyMat.setTo(5);
std::cout&lt;&lt;MyMat;
</pre>
<p style="text-align: justify;">The MyMat was a 3&#215;3 double type single channel matrix. However, the create() method in line 2 has changed the header into a 2&#215;2 double type single channel matrix. The setTo() method in line 3 is used to set all the elements of the matrix equal to to 5.0.</p>
<h2 style="text-align: justify;">Accessing Sub-parts of Matrices</h2>
<p style="text-align: justify;">While working with matrices in OpenCV, we often need to access into a matrix partially. For instance, we sometimes need to access the rows, columns, or diagonal elements of a matrix. We often also need to concatenate two matrices (or vectors) horizontally or vertically. There is a set of functions in OpenCV (row, col, diag, operator(), rowrange, colrange, hconcat, vconcat, copyto) to support these operations. The following code illustrates the use of these functions.</p>
<table border="0">
<tbody>
<tr>
<td>Program Code</td>
<td>Program Output</td>
</tr>
<tr>
<td>
<pre class="brush: cpp; title: ; notranslate">
cv::Mat MyMat = cv::Mat::eye(3,3,CV_64FC1);
std::cout&lt;&lt;MyMat&lt;&lt;std::endl;
cv::Mat oneRow = MyMat.row(1);
std::cout&lt;&lt;oneRow&lt;&lt;std::endl;
// Also play with col

oneRow.setTo(5.0);
std::cout&lt;&lt;oneRow&lt;&lt;std::endl;
std::cout&lt;&lt;MyMat&lt;&lt;std::endl;
cv::Mat twoRows = MyMat.rowRange(1,3).clone();
// Notice that it is not (1,2)
std::cout&lt;&lt;twoRows&lt;&lt;std::endl;
twoRows.copyTo(MyMat.rowRange(0,2));
std::cout&lt;&lt;MyMat&lt;&lt;std::endl;
std::cout&lt;&lt;oneRow&lt;&lt;std::endl;
// Also play with colRange

MyMat(cv::Range(1,3),cv::Range(0,2)).setTo(1.5);
std::cout&lt;&lt;MyMat&lt;&lt;std::endl;
std::cout&lt;&lt;MyMat.diag()&lt;&lt;std::endl;
MyMat.diag().setTo(3.33);
std::cout&lt;&lt;MyMat&lt;&lt;std::endl;
</pre>
</td>
<td>
<pre class="brush: cpp; title: ; notranslate">
[1,0,0;
0,1,0;
0,0,1]
[0,1,0]
[5,5,5]
[1,0,0;
5,5,5;
0,0,1]
[5,5,5;
0,0,1]
[5,5,5;
0,0,1;
0,0,1]
[0,0,1]
[5,5,5;
1.5,1.5,1;
1.5,1.5,1]
[5;1.5;1]
[3.33,5,5;
1.5,3.33,1;
1.5,1.5,3.33]
</pre>
</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">We need to analyze this code very carefully. In lines 1 and 2, a 3&#215;3 identity matrix has been created and displayed. In line 3, the matrix &#8220;oneRow&#8221; is defined for pointing to the second row of &#8220;MyMat&#8221;. Unlike MATLAB, the row method uses a 0-based indexing. In fact, 0-based indexing is consistently used in all the functions of OpenCV. Notice in line 3 that, the assignment operator is used without any cloning operation. As a result, if we change oneRow, this will be reflected in MyMat. This is shown in line 7-9 of the code. When we use the setTo command to set all the elements of oneRow to become 5.0, it also changes the 2nd row of MyMat (look at lines 6-8 of program output). This kind of operation should be handled very carefully because this behavior often cause confusions while working with OpenCV. Similar operations can also be done with col method, where the columns will be manipulated.</p>
<p style="text-align: justify;">In line 10 of the program code, rows second and third rows are copied in twoRows matrix. Notice the indexing convension. It is a zero-based index, so the index of first, second and third rows are zero, one and two. However, in the rowRange function, it takes rows from the first argument (1) to one less than the second argument. Since we want the rows one and two to be copied; so we&#8217;ve given the values (1,3). We have copied this two rows in the first two rows MyMat by the copyTo method using the range argument (0,2). We need to remember one point here. copyTo function CAN NOT refer to itself. That is, you can not combine line 10 and 13 as follows.</p>
<pre class="brush: cpp; title: ; notranslate">
MyMat.rowRange(1,3).clone().copyTo(MyMat.rowRange(0,2));
// Does Not Work!!
</pre>
<p style="text-align: justify;">In Line 18, a block of the matrix is selected and set to 1.5. Output of this code is in line 15 of the program output. The program also shows the use of the diag method. It gives the diagonal entries of a matrix as a column vector. diag can take a integer as its argument. If its value is zero, it refers to the main diagonal. On the other hand, positive integers indicate the diagonals upper than the main one, and negatives indicate lower diagonals.</p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2012%2Flinear-algebra-in-opencv-post2%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2012%2Flinear-algebra-in-opencv-post2%2F&amp;text=Linear+Algebra+in+OpenCV%3A+Post+2" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2012/linear-algebra-in-opencv-post2/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2012/linear-algebra-in-opencv-post2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linear algebra in OpenCV: Post 1</title>
		<link>http://www.itanveer.com/2012/linear-algebra-in-opencv/</link>
		<comments>http://www.itanveer.com/2012/linear-algebra-in-opencv/#comments</comments>
		<pubDate>Wed, 09 May 2012 06:08:02 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[Linear Algebra in OpenCV]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming & Technology]]></category>
		<category><![CDATA[Novice]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=511</guid>
		<description><![CDATA[I know many people will look at me in frowning eyes after reading the title. Yes, OpenCV is an image processing and computer vision library. But believe me, the most rudimentary works you need to do in these fields are essentially &#8220;Linear &#8230; <a href="http://www.itanveer.com/2012/linear-algebra-in-opencv/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I know many people will look at me in frowning eyes after reading the title. Yes, OpenCV is an image processing and computer vision library. But believe me, the most rudimentary works you need to do in these fields are essentially &#8220;Linear Algebra&#8221;. Think about an image &#8212; it is a matrix; and most of the time you&#8217;ll work on matrices. Even other data structures like vectors and points &#8212; all are some kind of matrices. Necessity of doing linear algebra is one of the main reasons for burgeoning MATLAB (which is an acronym for MATrix LABoratory) libraries for image processing. In fact, the power of linear algebra libraries enabled MATLAB to incorporate so many different toolboxes ranging from image processing, statistics, bioinformatics, neural network to so many more.  So, let us do some kind of matrix processing in OpenCV. We&#8217;ll use the C++ interface.<span id="more-511"></span></p>
<p style="text-align: justify;">First thing that you need to do to work with opencv is to install it. If you are using Windows and Microsoft Visual Studio, <a href="http://www.itanveer.com/2011/installing-opencv-231/">I have a set of instructions to install it</a>. However, if you are using <a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.0/">Linux, Mac</a>, <a href="https://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.0/">Android</a> or any other OS, you need to look for the instructions in <a href="http://opencv.willowgarage.com/wiki/InstallGuide">OpenCV Wiki</a>. Once you&#8217;ve successfully installed it, let&#8217;s jump into the coding part.</p>
<p style="text-align: justify;">From OpenCV 2, it is possible to use the C++ coding style in OpenCV. It has different modules focused on different kinds of works. For example, &#8220;core&#8221; is mainly devote to the core processing like forming the matrix, doing some linear algebra etc. The &#8220;highgui&#8221; module deals with GUI related works such as creating windows etc. &#8220;ml&#8221; works with machine learning procedures. If you work with computer vision, you will eventually see that  it is heavily dependent on the machine learning field. Anyway, the header files for different components of OpenCV are located in &lt;OpenCV&gt;\include\opencv2\&lt;ModuleName&gt; folder. If you don&#8217;t want to bother to know which function belongs to which module, you can include only one header &#8220;opencv.hpp&#8221; which includes all the other header files. So, all the parts of OpenCV is added in your project.</p>
<p style="text-align: justify;">Lets first see some basic input-output of a matrix. Write the following code in your MSVC project which you should configure according to the instructions specified <a href="http://www.itanveer.com/2011/installing-opencv-231/">here</a>.</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;opencv2/opencv.hpp&gt;;
#include &lt;iostream&gt;;
int main(int argx, char** argv){
 float trainingData[3][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
 cv::Mat MyFirstMat(3, 3, CV_32FC1, trainingData);
 std::cout&lt;&lt;MyFirstMat;
 std::cout&lt;&lt;&quot;\nPress Enter to exit\n&quot;;
 std::cin.get();
}
</pre>
<p style="text-align: justify;">When you&#8217;ll run this small program, you&#8217;ll see a matrix in the output screen. The entries in each row are separated by a comma. After every row, there is a semicolon. Actually, this is a way of writing matrices in many other languages including MATLAB. Look at lines 4 and 5 very carefully. In 4, you are defining a 3&#215;3 array where you&#8217;re loading the entries of the matrix. Line number 5 is the main OpenCV command where you are creating an OpenCV matrix named &#8220;MyFirstMat&#8221;. Look at the constructor arguments carefully. The first two arguments indicate that the matrix contains 3 rows and 3 columns. The third argument refers to the type of the matrix. There is an OpenCV standard for specification of the types of OpenCV matrices. After the first common &#8220;CV&#8221; part, the number 32 means it is a 32 bit number (i.e. each entry in the matrix will be constituted with 32 bits). The &#8220;F&#8221; means it is a &#8220;float&#8221; type (i.e. contains decimal point). Some other common type specifiers are &#8220;64F&#8221;, &#8220;32S&#8221;, and &#8220;8U&#8221; representing &#8220;double&#8221;, &#8220;int&#8221;, and &#8220;uchar&#8221; respectively. In the last part, C1 means it has only one channel. In other words, you can write only one number in each entry. If it would be C3 then you could write 3 numbers. For example, in an RGB image, for each pixel you need to write 3 numbers for red, green and blue channel. In the last argument, we just fed the 2D array into the matrix. Notice that we specifically mentioned the scope using a scope resolution operator &#8220;:&#8221;. This is because, many functions in OpenCV matches with the functions of standard library &#8220;std&#8221;. So, it is a good practice to specify the scopes in every case.</p>
<p style="text-align: justify;">Now let us do an experiment. Replace line number 4 by this line:</p>
<pre class="brush: cpp; title: ; notranslate">float trainingData[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9}</pre>
<p>It is giving the same result, right? This is because, when the data is store into a matrix, it is stored as just by writing the bits one after another. It is the responsibility of the first three arguments (number of rows, number of columns and the datatype) to interpret the bit sequence as a human understandable form. Unlike MATLAB, OpenCV vectorizes a matrix row-wise first.</p>
<p>Now let us see some other examples of matrix input. The following code will also do the same as previous example:</p>
<pre class="brush: cpp; title: ; notranslate">
Mat cameraMatrix = (Mat&lt;double&gt;(3,3) &lt;&lt; 1000, 0, 320, 0,
 1000, 240 , 0, 0, 1);
</pre>
<p>Sometimes, it is necessary to dynamically input the data after initializing the headers. This can be done as below.</p>
<pre class="brush: cpp; title: ; notranslate">

int main(int argx, char** argv){
 cv::Mat MyMat = cv::Mat::zeros(3,3,CV_64FC1);
 for(int i=0;i&lt;3;i++)
  for (int j = 0;j&lt;3;j++)
   MyMat.at&lt;double&gt;(i,j)=j+i*3+1;
 std::cout&lt;&lt;MyMat;
 std::cout&lt;&lt;&quot;\nPress Enter to exit&quot;;
 std::cin.get();
}
</pre>
<p>It gives the same output as earlier example. But the difference is, this time you don&#8217;t need to specify all the values in coding time. The matrix entries gets assigned in run-time (i.e. dynamically) by evaluating a mathematical function. Notice, in this code, the matrix is initialized with zeros using a static function named &#8220;zeros&#8221; (all elements will be zero). You can also initialize it with the &#8220;ones&#8221; (all elements will be one), or the &#8220;eye&#8221; (identity matrix). No matter how the initialization is done, the two for loops are actually replacing each element with the value of j+i*3+1. The &#8220;at&#8221; in line 5 is a template for accessing  the elements of the matrix. Since it is a template, you need to specify the data type. This method can be used to both input and output of a matrix element. You need to be careful in deciding whether you are putting (i,j) or (j,i) as the arguments of the &#8220;at&#8221; function. Since OpenCV assigns the values of a row first, the &#8220;for&#8221; loop defining the column variable (j in this case) should immediately precede the line of at function. But don&#8217;t worry much, if you get the matrix in wrong orientation, you can always transpose it using the t() function. You can test it by inserting the following line in between lines # and # in the previous code .</p>
<pre class="brush: cpp; title: ; notranslate"> MyMat.t();</pre>
<p>You can use the following code to load a matrix from a csv file.</p>
<pre class="brush: cpp; title: ; notranslate">

 CvMLData Data;
 Data.read_csv(&quot;test.csv&quot;);
 csvContent = Data.get_values();
</pre>
<p>Any OpenCV structure can be saved in xml/yml file. If you are interested to do so, you can <a href="http://opencv.itseez.com/modules/core/doc/xml_yaml_persistence.html">see here</a>. I&#8217;ll not discuss it here.</p>
<p>Now, you know the basic methods to load a matrix and show it in screen. You can also do element by element operation since you can access matrix elements. However, there are several convenience function. For example, a matrix can be displayed in an output stream (or file-stream) using the &lt;&lt; operator. In next post, we&#8217;ll see some basic operations in opencv. We&#8217;ll also see some linear algebra operations.</p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2012%2Flinear-algebra-in-opencv%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2012%2Flinear-algebra-in-opencv%2F&amp;text=Linear+algebra+in+OpenCV%3A+Post+1" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2012/linear-algebra-in-opencv/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2012/linear-algebra-in-opencv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Picture of the Biggest Moon</title>
		<link>http://www.itanveer.com/2012/picture-of-biggest-moon/</link>
		<comments>http://www.itanveer.com/2012/picture-of-biggest-moon/#comments</comments>
		<pubDate>Mon, 07 May 2012 05:33:37 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[My idle thoughts]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=492</guid>
		<description><![CDATA[Last night was a night of biggest moon for this year. I tried to capture some pictures of the moon using my Canon EOS Rebel T3. At first, it was getting overexposed. The picture was looking like a bowl of &#8230; <a href="http://www.itanveer.com/2012/picture-of-biggest-moon/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last night was a night of biggest moon for this year. I tried to capture some pictures of the moon using my Canon EOS Rebel T3. At first, it was getting overexposed. The picture was looking like a bowl of white milk. Then I started reducing the exposure by increasing the shutter speed while keeping the ISO fixed to 100. Then I got a shot. How is it?</p>
<p><img class="aligncenter" src="https://lh4.googleusercontent.com/-xoJMUWqCMJE/T6debdQnV5I/AAAAAAAADMc/CAVcvSXLp1c/s720/Big-Moon.jpg" alt="" width="720" height="484" /></p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2012%2Fpicture-of-biggest-moon%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2012%2Fpicture-of-biggest-moon%2F&amp;text=Picture+of+the+Biggest+Moon" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2012/picture-of-biggest-moon/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2012/picture-of-biggest-moon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read, Display and Write video/images/camera frames</title>
		<link>http://www.itanveer.com/2011/read-display-write-opencv/</link>
		<comments>http://www.itanveer.com/2011/read-display-write-opencv/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 01:15:34 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming & Technology]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=469</guid>
		<description><![CDATA[The new OpenCV C++ interface has made the process of image loading and display much easier. If you are a bit familiar with MATLAB then it is even more easier for you. Because in many cases, the MATLAB function names are directly &#8230; <a href="http://www.itanveer.com/2011/read-display-write-opencv/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The new OpenCV C++ interface has made the process of image loading and display much easier. If you are a bit familiar with MATLAB then it is even more easier for you. Because in many cases, the MATLAB function names are directly used in OpenCV.</p>
<p><span id="more-469"></span></p>
<p>For example, you can read, show and write images using the imread, imshow and imwrite commands respectively.</p>
<pre class="brush: cpp; title: ; notranslate">

#include &lt;stdio.h&gt;
#include &lt;opencv2\opencv.hpp&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

using namespace std;

int main(int argc, char* argv[])
{
	// ============= Read, Show, Write Image ===================
	// CAUTION!!! This statement requires a jpg file
        //in the current directory
	cv::Mat img = cv::imread(&quot;test.jpg&quot;);

	if(img.data!=NULL){
	   cv::Mat scaledimg(img.rows/img.cols*640,640,img.type());
		cv::resize(img,scaledimg,scaledimg.size());

		cv::namedWindow(&quot;Image&quot;);

		cv::imshow(&quot;Image&quot;,scaledimg);
// See what happens if you don't use this
		cv::waitKey();
		cv::imwrite(&quot;test_scaled.jpg&quot;,scaledimg);
	}
	return 0;
}
</pre>
<p>When the question of video comes, OpenCV has a one stop solution named VideoCapture. It can capture video frames from both a video or a webcam.</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;stdio.h&gt;
#include &lt;opencv2\opencv.hpp&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

using namespace std;

int main(int argc, char* argv[])
{
	// ============== Capture Camera Frame ====================
	cv::Mat frame;
	// Capturing data from camera
        // Caution: It requires webcam to be attached
	cv::VideoCapture cap(0);
        // you can also use
        // cv::VideoCapture cap(&quot;video filename&quot;);
        // to capture the frame from a video instead of webcam
	if(!cap.isOpened())
	  printf(&quot;No Camera Detected&quot;);
	else{
		cv::namedWindow(&quot;Webcam Video&quot;);
		for(;;){
			cap &gt;&gt; frame; // get a new frame from camera
			cv::imshow(&quot;Webcam Video&quot;,frame);
			if(cv::waitKey(30) &gt;= 0) break;
		}
	}
	return 0;
}
</pre>
<p>Note: This post assumes you have OpenCV 2.3 installed. If not, please check the following post<br />
<a href="http://www.itanveer.com/2011/installing-opencv-231/">http://www.itanveer.com/2011/installing-opencv-231/</a></p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fread-display-write-opencv%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fread-display-write-opencv%2F&amp;text=Read%2C+Display+and+Write+video%2Fimages%2Fcamera+frames" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2011/read-display-write-opencv/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2011/read-display-write-opencv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An OpenCV example</title>
		<link>http://www.itanveer.com/2011/an_opencv_example/</link>
		<comments>http://www.itanveer.com/2011/an_opencv_example/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 07:32:16 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[Linear Algebra in OpenCV]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming & Technology]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=442</guid>
		<description><![CDATA[A snippet in OpenCV for some useful mathematical operations. It mostly focuses on the old opencv style matrix to new opencv style matrix conversion (and vice-versa) and some elementary mathematical operations. It also includes a trivial matrix display function. I&#8217;ll &#8230; <a href="http://www.itanveer.com/2011/an_opencv_example/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A snippet in OpenCV for some useful mathematical operations. It mostly focuses on the old opencv style matrix to new opencv style matrix conversion (and vice-versa) and some elementary mathematical operations. It also includes a trivial matrix display function. I&#8217;ll give a more robust matrix display function in future.<span id="more-442"></span></p>
<pre class="brush: cpp; title: ; notranslate">
// OpenCV_Test.cpp : Defines the entry point for the console application.
//

#include &lt;stdio.h&gt;
#include &lt;opencv2\opencv.hpp&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

using namespace std;

// I wrote this method to display matrix contents. It is only for
// double (64 bit) data type. I shall write a more general version
// in near future
void dispMat(CvMat *N, string varName){
    double *data = N-&gt;data.db;
    int rowNum = N-&gt;rows;
    int colNum = N-&gt;cols;

    printf(&quot;\n========= Matrix Display System ==============\n&quot;);
    printf(&quot;(%d,%d) %s \n&quot;,rowNum,colNum,varName.c_str());
    for(int i=0;i&lt;rowNum;i++){
        if(colNum&gt;10)
            printf(&quot;Row No=%d\n&quot;,i+1);
        for(int j=0;j&lt;colNum;j++)
            printf(&quot;%0.2f\t&quot;,data[i*colNum+j]);
        printf(&quot;\n&quot;);
    }
    printf (&quot;=================================================&quot;);
    printf(&quot;\n&quot;);
}

int main(int argc, char* argv[])
{
    int a=0;

    double c[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
    double d[] = {2,1,6,-4,0.5,4,9,1,9,-1,-0.3,0.7,3,2,1,1.5};

    // Declaring Matrix as a Pointer and initialization
// This is the old style of OpenCV Matrices
    CvMat* M = cvCreateMat(4,4,CV_64FC1);
    cvInitMatHeader(M,4,4,CV_64FC1,d);
    dispMat(M,&quot;M = &quot;);

    // Declaring Matrix as variable and initialization
    CvMat N = cvMat(4,4,CV_64FC1,c);
    dispMat(&amp;N,&quot;N = &quot;);

    // Declaring Matrix as pointer without initialization
    CvMat* M2;

    //Cloning a Matrix
    M2 = cvCloneMat(M);
    dispMat(M2,&quot;M2 = &quot;);

    //indirect access to matrix element
    //get
    printf(&quot;\n(2,3)th element in M2 = %0.2f\n&quot;,cvmGet(M2,2,3));
    //set
    cvmSet(M2,2,3,90);
    printf(&quot;(2,3)th element is now set to = %0.2f\n&quot;,
	cvmGet(M2,2,3));

    cout&lt;&lt;&quot;\nPress Enter to continue\n&quot;;cin.get();
    // ================================================

    //Set zero
    cvSetZero(M2);
    dispMat(M2,&quot;\nM2 (cvSetZero)\n&quot;);

    //Set Identity
    cvSetIdentity(M2);
    dispMat(M2,&quot;\nM2 (cvSetIdentity)\n&quot;);

	cout&lt;&lt;&quot;\nPress Enter to continue\n&quot;;cin.get();

    // ============ OpenCV 2 Test =====================
    cv::Mat A = cv::Mat(M,true);
    cv::Mat J = cv::Mat(4,1,CV_64FC1,cv::Scalar(1));

    cv::Mat B = (J.t())*(A);

    CvMat AA = A;
    dispMat(&amp;AA,&quot;OpenCV 2 Variable: A&quot;);

    AA = J;
    dispMat(&amp;AA,&quot;OpenCV 2 Variable: J&quot;);

	// Try this: B  = (J.t()*A).t();
    B  = (J.t()*A);
	B = B.t();
	AA = B;		// Also try this: AA = B.t();
    dispMat(&amp;AA,&quot;OpenCV 2 Variable:(J'*A)'&quot;);

    cout&lt;&lt;&quot;\nPress Enter to continue\n&quot;;cin.get();
    // =========== Predefined openCV 2 Matrices ========
    A = cv::Mat::zeros(5,2,CV_64FC1);
    AA = A;
    dispMat(&amp;AA,&quot;Predefined matrices: zeros(5,2,cv_64fc1)&quot;);

    A = cv::Mat::ones(5,2,CV_64FC1);
    AA = A;
    dispMat(&amp;AA,&quot;Predefined matrices: ones(5,2,cv_64fc1)&quot;);

    A = cv::Mat::eye(5,5,CV_64FC1);
    AA = A;
    dispMat(&amp;AA,&quot;Predefined matrices: eye(5,5,cv_64fc1)&quot;);

    cout&lt;&lt;&quot;\nPress Enter to continue\n&quot;;cin.get();
    // =========== Predefined openCV 2 Matrices ========
    printf(&quot;\n\n Element (1,2) = %f&quot;,A.at&lt;double&gt;(2,1));

    // === Writing opencv Matrix (M2) to and from Filestream =====

    ofstream ofs(&quot;d:\\test.dat&quot;,ios::out|ios::binary);

    dispMat(M2,&quot;Matrix before writing to file&quot;);

    double p =5;int s=3;
    double* m2Dat = M2-&gt;data.db;

    ofs&lt;&lt;p&lt;&lt;endl&lt;&lt;s;
    ofs.write((char *) m2Dat,M2-&gt;cols*M2-&gt;rows*sizeof(double));

    ofs.close();

    p=0;s=0;
    m2Dat[0]=-1;
    m2Dat[1]=-1;
    m2Dat[2]=-1;
    m2Dat[3]=-1;
    m2Dat[4]=-1;
    m2Dat[5]=-1;
    m2Dat[6]=-1;
    m2Dat[7]=-1;
    m2Dat[8]=-1;
    m2Dat[9]=-1;
    m2Dat[10]=-1;
    m2Dat[11]=-1;
    m2Dat[12]=-1;
    m2Dat[13]=-1;
    m2Dat[14]=-1;
    m2Dat[15]=-1;

    dispMat(M2,&quot;Matrix after changing data&quot;);

    ifstream ifs(&quot;d:\\test.dat&quot;,ios::in|ios::binary);

    ifs&gt;&gt;p&gt;&gt;s;
    printf(&quot;%0.3f\n&quot;,p);
    printf(&quot;%d\n&quot;,s);
    ifs.read((char *)m2Dat,M2-&gt;cols*M2-&gt;rows*sizeof(double));

    dispMat(M2,&quot;Matrix after Loading again&quot;);

    CvMat* M3 = cvCreateMat(4,4,CV_64FC1);
    cvInitMatHeader(M3,4,4,CV_64FC1,m2Dat);
    dispMat(M3,&quot;Matrix reading from file&quot;);

    ifs.close();

    // Releasing Matrix Handle
    cvReleaseData(M);
    cvReleaseData(M2);
    cvReleaseData(M3);

    return 0;
}
</pre>
<p>Note: This post assumes you have OpenCV 2.3 installed. If not, please check the following post<br />
<a href="http://www.itanveer.com/2011/installing-opencv-231/">http://www.itanveer.com/2011/installing-opencv-231/</a></p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fan_opencv_example%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fan_opencv_example%2F&amp;text=An+OpenCV+example" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2011/an_opencv_example/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2011/an_opencv_example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing OpenCV 2.3.1 in Windows</title>
		<link>http://www.itanveer.com/2011/installing-opencv-231/</link>
		<comments>http://www.itanveer.com/2011/installing-opencv-231/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 01:04:20 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[Linear Algebra in OpenCV]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Programming & Technology]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=402</guid>
		<description><![CDATA[This tutorial guides you through the process of installing OpenCV 2.3.1 in windows using Visual Studio 10. OpenCV changes its installation process from version to version and sometimes make it too confusing to work properly. In this tutorial I&#8217;ll try &#8230; <a href="http://www.itanveer.com/2011/installing-opencv-231/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This tutorial guides you through the process of installing OpenCV 2.3.1 in windows using Visual Studio 10. OpenCV changes its installation process from version to version and sometimes make it too confusing to work properly. In this tutorial I&#8217;ll try to mention as much details as possible in the installation process of OpenCV.<span id="more-402"></span></p>
<p><strong>Preparation Step:</strong> Install Visual Studio 10.</p>
<p><strong>Stage One: Installing OpenCV</strong></p>
<ol>
<li>Download OpenCV 2.3.1 Superpack from the following link: <a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/">http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/</a>.</li>
<li>Run the exe file and extract the contents in C:\OpenCV231. If the contents (i.e. the folders named 3rdparty, android etc) are copied in a folder named &#8220;opencv&#8221; inside C:\OpenCV231 then copy all of them to C:\OpenCV231. (I&#8217;ll describe all the later steps assuming that the files has been extracted here. If not, please modify the instruction accordingly.)
<div class="wp-caption alignright" style="width: 306px"><img title="cmake GUI Dialog" src="https://lh4.googleusercontent.com/-g9DQBxMrOAk/TqRgL5o0UQI/AAAAAAAADGI/jXGF-lc_SVY/s494/1.png" alt="" width="296" height="230" /><p class="wp-caption-text">Figure 1: Selecting the Generator</p></div>
<p><div class="wp-caption alignright" style="width: 306px"><img class=" " src="https://lh3.googleusercontent.com/-_RaSlMBYe-k/TqRh-jWwmWI/AAAAAAAADGQ/AmA64aoY5sY/s694/2.png" alt="" width="296" height="230" /><p class="wp-caption-text">Figure 2: cmake window</p></div></li>
<li>Download and install cmake from <a href="http://www.cmake.org/">http://www.cmake.org/</a></li>
<li>Run the Graphical User Interface of Cmake (cmake-gui).</li>
<li>In the field named &#8220;Where is the source code:&#8221; white c:\opencv231. In the field named &#8220;Where to build the binaries&#8221; specify C:\OpenCV231\msvc. Now click &#8220;configure&#8221;.</li>
<li>A dialog box will appear (Figure 1) asking you to specify the generator for the project. Select Visual Studio 10 from the dropdown list. Select &#8220;Use default native compiler&#8221;. Now click &#8220;Finish&#8221;. It may ask for your permission to create a new folder named msvc. Just allow to do it. It</li>
<li>Now the cmake window will look something like Figure 2. In this dialog, check the box named &#8220;install_c_examples&#8221;. Click the &#8220;Generate&#8221; button. This will make Visual Studio solutions in the C:\OpenCV231\msvc folder.</li>
<li>Open OpenCV.sln. Select &#8220;Debug&#8221; in the solution configuration listbox. Now press F7 to build the solution. If all the projects are successfully built (3 projects may be skipped, don&#8217;t worry about that) it will show such message. Now do the same by selecting &#8220;release&#8221; in the solution configuration listbox.</li>
<li>Copy the &#8220;lib&#8221; and &#8220;bin&#8221; folders from C:\OpenCV231\msvc to C:\OpenCV231. Also copy the contents of &#8220;include&#8221; folder from C:\OpenCV231\build to C:\OpenCV231\include</li>
<li>Now we need to add the following 2 folders in environment variables:<br />
C:\OpenCV231\bin\Release<br />
C:\OpenCV231\bin\Debug<br />
To do this, go to Control Panel &gt; System &gt; Advanced System Settings &gt; Environment Variables and append these two folders into the &#8220;path&#8221; variable. Remember to separate the entries by semicolon. Click ok.</li>
</ol>
<div><strong>Stage Two: Configuring Visual Studio Project with OpenCV</strong></div>
<div>
<ol>
<li>Create a new Win32 console application.</li>
<li>In solution explorer, right click on the project and click properties. Go to VC++ Directories. in Include Directories, add the following 2 folders:<br />
C:\OpenCV231\include<br />
C:\OpenCV231\include\opencv</li>
<li>Add the following folder in Library Directories while you are in Debug configuration:<br />
C:\OpenCV231\lib\Debug<br />
Add the following while in Release configuration:<br />
C:\OpenCV231\lib\Release</li>
<li>Go to Linker &gt; Input. Add the following in the &#8220;Additional Dependencies&#8221; field while in debug configuration:<br />
opencv_calib3d231d.lib<br />
opencv_contrib231d.lib<br />
opencv_core231d.lib<br />
opencv_features2d231d.lib<br />
opencv_flann231d.lib<br />
opencv_gpu231d.lib<br />
opencv_haartraining_engined.lib<br />
opencv_highgui231d.lib<br />
opencv_imgproc231d.lib<br />
opencv_legacy231d.lib<br />
opencv_ml231d.lib<br />
opencv_objdetect231d.lib<br />
opencv_ts231d.lib<br />
opencv_video231d.lib<br />
Add the following while in release configuration:<br />
opencv_calib3d231.lib<br />
opencv_contrib231.lib<br />
opencv_core231.lib<br />
opencv_features2d231.lib<br />
opencv_flann231.lib<br />
opencv_gpu231.lib<br />
opencv_haartraining_engine.lib<br />
opencv_highgui231.lib<br />
opencv_imgproc231.lib<br />
opencv_legacy231.lib<br />
opencv_ml231.lib<br />
opencv_objdetect231.lib<br />
opencv_ts231.lib<br />
opencv_video231.lib</li>
<li>In earlier versions, OpenCV used to be included by the following line:<br />
#include &lt;cv.h&gt;<br />
From OpenCV 2.2, it is included by either the following:<br />
#include &lt;opencv2/opencv.hpp&gt;<br />
Or, by individually including each module located in different folders inside C:\OpenCV231\lib\Debug</li>
</ol>
</div>
<p><strong>Compatibility Issue:</strong></p>
<p>I have found the following backward compatibility issue while moving from opencv 2.1 to 2.3.1</p>
<p>If M be a cv::Mat then if you have a command M.inv(CV_SVD_SYM) then you have to change it to M.inv(cv::DECOMP_SVD)</p>
<p>Update: OpenCV 2.4.0 is released. It has very similar installation process except the lib filenames. Release filenames:</p>
<p>opencv_calib3d240.lib<br />
opencv_contrib240.lib<br />
opencv_core240.lib<br />
opencv_features2d240.lib<br />
opencv_flann240.lib<br />
opencv_gpu240.lib<br />
opencv_haartraining_engine.lib<br />
opencv_highgui240.lib<br />
opencv_imgproc240.lib<br />
opencv_legacy240.lib<br />
opencv_ml240.lib<br />
opencv_nonfree240.lib<br />
opencv_objdetect240.lib<br />
opencv_photo240.lib<br />
opencv_stitching240.lib<br />
opencv_ts240.lib<br />
opencv_video240.lib<br />
opencv_videostab240.lib</p>
<p><strong>And Debug Filenames</strong></p>
<p>opencv_calib3d240d.lib<br />
opencv_contrib240d.lib<br />
opencv_core240d.lib<br />
opencv_features2d240d.lib<br />
opencv_flann240d.lib<br />
opencv_gpu240d.lib<br />
opencv_haartraining_engined.lib<br />
opencv_highgui240d.lib<br />
opencv_imgproc240d.lib<br />
opencv_legacy240d.lib<br />
opencv_ml240d.lib<br />
opencv_nonfree240d.lib<br />
opencv_objdetect240d.lib<br />
opencv_photo240d.lib<br />
opencv_stitching240d.lib<br />
opencv_ts240d.lib<br />
opencv_video240d.lib<br />
opencv_videostab240d.lib</p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2011%2Finstalling-opencv-231%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2011%2Finstalling-opencv-231%2F&amp;text=Installing+OpenCV+2.3.1+in+Windows" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2011/installing-opencv-231/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2011/installing-opencv-231/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>My experience in ACII 2011</title>
		<link>http://www.itanveer.com/2011/acii-2011/</link>
		<comments>http://www.itanveer.com/2011/acii-2011/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 18:13:53 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[My idle thoughts]]></category>
		<category><![CDATA[Science or Scientasy]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=390</guid>
		<description><![CDATA[I have attended several sessions of the conference, Affective Computing and Intelligent Interaction (ACII) 2011 and an associated workshop named Machine Learning and Affective Computing (MLAC). It was held from 9th to 12th of Oct. It was a great experience &#8230; <a href="http://www.itanveer.com/2011/acii-2011/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have attended several sessions of the conference, Affective Computing and Intelligent Interaction (ACII) 2011 and an associated workshop named Machine Learning and Affective Computing (MLAC). It was held from 9<sup>th</sup> to 12<sup>th</sup> of Oct. It was a great experience to attend a conference directly related to my working area. Several important points in current research trends came up in the sessions which worth some thoughtful discussions.<span id="more-390"></span></p>
<p><strong>The Use of Active Appearance Models</strong></p>
<div id="attachment_391" class="wp-caption alignright" style="width: 394px"><a href="http://www.itanveer.com/wp-content/uploads/2011/10/IMG_1795_small.jpg"><img class="size-full wp-image-391 " title="IMG_1795_small" src="http://www.itanveer.com/wp-content/uploads/2011/10/IMG_1795_small.jpg" alt="" width="384" height="288" /></a><p class="wp-caption-text">With Professor Jeffrey Cohn</p></div>
<p>Renowned researcher of psychology Professor Dr. Jeffrey Cohn, in his presentation “<em>Machine Learning for Affective Computing: Findings and Issue</em>” showed how Active Appearance Model has paved the way for some of the experiments which were not possible to conduct earlier. For example, the capability of Active Appearance Models to accurately model and tack a person’s head movement and facial expressions is utilized to generate almost real time (~0.5 sec delay) avatars. These avatars are used in interaction between two people in several psychological experiments. For example, it was shown that, people can interact as easily with an avatar as a normal human being. However, these interactions can be manipulated by reducing the amount of expressions (which can be done by computationally reducing the expressions expressed by the avatars) or by immobilizing the head movement or by changing the gender of the avatar (A male showing a female avatar and vice versa) etc. In those cases, people do not identify such interactions as spontaneous human-human interactions. Prof Cohn also showed the effect of smile dynamics of faces i.e. how the “spontaneity” in smile is related with the temporal evolution. In a later presentation named “<em>FAST-FACS: A Computer-Assisted System to Increase Speed and Reliability of Manual FACS Coding</em>” Jeff Cohn also showed how the manual landmark annotation effort can by reduced by 40% through the use of some semi-automatic annotation process.</p>
<p><strong>Human centric Machine Learning</strong></p>
<p>Some exciting achievements are possible to make by incorporating humans in different aspects of machine learning. This point is underscored by the invited speaker from Microsoft research, Ashish Kapoor, in his presentation “<em>Human-Centric Machine Learning</em>”. He mentioned that, it is possible to use human interactions more than just data labeling. He showed several of his works on how it is possible to use human interactions to rectify the decision boundaries of classifiers, incorporate experience and use in many other exciting ways.</p>
<p><strong>More on Smile Dynamics</strong></p>
<p>More research on the types of smile has been shown in the paper “<em>Are You Friendly or just Polite? – Analysis of smiles in spontaneous face-to-face interactions</em>” presented by Mohammed Hoque, Louis-Philippe Morency and Rosaline Picard. It has been shown that most of the spontaneity information lies on what time it takes for a smile to rise to the peak from the onset and decay to the offset from the peak. Mohammed Hoque mentioned that MIT media lab will release the dataset that has been used in this work. I believe it will give us a rare opportunity to access some spontaneous dataset just for free.</p>
<p><strong>Interactions and Socialization</strong></p>
<div id="attachment_392" class="wp-caption alignleft" style="width: 394px"><a href="http://www.itanveer.com/wp-content/uploads/2011/10/IMG_1799_small.jpg"><img class="size-full wp-image-392 " title="IMG_1799_small" src="http://www.itanveer.com/wp-content/uploads/2011/10/IMG_1799_small.jpg" alt="" width="384" height="288" /></a><p class="wp-caption-text">With Professor Rosaline Picard, the founder of Affective Computing</p></div>
<p>This conference gave me a wonderful opportunity to see and discuss with the leading researchers in affective computing. I talked personally with Jeffry Cohn, Rosaline Picard, Peter Robinson, Louis-Philippe Morency and asked few questions regarding current trends of research in affective computing. In a conversation with Prof Cohn on the channels of emotion, he mentioned that he is a bit skeptical on how far it is possible to infer emotion appropriately from physiological channels. He mentioned two reasons for that. Firstly, physiological responses are relatively slower than the response showed in facial expressions. Secondly, sensors required to measure physiological signals can alter the emotions to some extent.</p>
<p>Professor Rosaline Picard highly appreciated the project concept of <em>blind emotion</em>. She mentioned that it is possible to help blind people in great extent to perceive others emotion. MIT Media lab did some preliminary investigations on these issues. She specifically pointed that it will not be a good idea to convey the facial expressions (like smile, frown etc.) to the people who are congenitally blind. Rather, it is better to convey some inferred information which makes more sense to them. For example, whether other people are interested on what a blind person is speaking etc. Prof Picard also pointed on a possible difficulty that their lab faced. She mentioned that it becomes very difficult to track and analyze a person’s face with the inherent head movement of the wearer. She also welcomed any help and collaboration that may be asked from our side.</p>
<p>Dr. Louis-Philippe Morency showed an extra ordinary enthusiasm to our effort on analyzing</p>
<div id="attachment_393" class="wp-caption alignright" style="width: 394px"><a href="http://www.itanveer.com/wp-content/uploads/2011/10/IMG_1800_small.jpg"><img class="size-full wp-image-393 " title="IMG_1800_small" src="http://www.itanveer.com/wp-content/uploads/2011/10/IMG_1800_small.jpg" alt="" width="384" height="288" /></a><p class="wp-caption-text">With Professor Peter Robinson</p></div>
<p>facial expressions and works with active appearance model. He mentioned that he is going to release a more robust version of Constrained Local Model (CLM) based face tracker. This tracker will be released in public domain. He also expressed his ideology on how research related data and tool should be disseminated for public use. He also gave word to entertain our request for this face tracker as much as possible.</p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2011%2Facii-2011%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2011%2Facii-2011%2F&amp;text=My+experience+in+ACII+2011" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2011/acii-2011/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2011/acii-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paper review: Neural Reorganization Following Sensory Loss: The Opportunity of Change</title>
		<link>http://www.itanveer.com/2011/neural-reorganization/</link>
		<comments>http://www.itanveer.com/2011/neural-reorganization/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 14:56:06 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[Science or Scientasy]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=387</guid>
		<description><![CDATA[Merabet, L. B. &#38; Pascual-Leone A. Neural Reorganization Following Sensory Loss: The Opportunity of Change, Nature Reviews Neuroscience, vol 11, pp 44-52, 2009 It is apparent from a long growing mass of evidences that the part of a brain responsible for processing &#8230; <a href="http://www.itanveer.com/2011/neural-reorganization/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Merabet, L. B. &amp; Pascual-Leone A. <strong>Neural Reorganization Following Sensory Loss: The Opportunity of Change,</strong><em> Nature Reviews Neuroscience</em>, vol 11, pp 44-52, 2009</p>
<p>It is apparent from a long growing mass of evidences that the part of a brain responsible for processing information from a particular sensory channel gets recruited for other activities after loss of that particular channel. This phenomenon is referred to as “neuroplastic” behavior of brain. When it contributes to the improvement of other sensory channels, it is called “crossmodal neuroplasticity”. This paper refers to a considerable amount of reported evidences on crossmodal neuroplasticity following sensory deprivation and came to some conclusions based on those observations.<span id="more-387"></span></p>
<p>It particularly discussed about the following aspects of neuroplasticity. Firstly, it refers to a significant amount of reported experiments and their results on the effect of loss of vision and auditory capabilities. Analyzing these experiments, a conclusion was made that the loss of a sensory channel translates into an improved or at least an equal performance in behavioral and sensory tasks. Experimental proofs have been referred in this paper where it is reported that blind individuals showed equal or superior performance in tactile-discrimination thresholds, auditory-pitch discrimination, spatial sound localization, speech discrimination, verbal recall etc. In addition, it has been discussed that electroencephalographic and neuro-imaging technologies provide strong evidence on an altered association of brain areas for proficient utilization of other sensory channels. Similar works have also been showed for deafness and loss of multiple sensory channels.</p>
<p>Other than collecting evidences of crossmodal neuroplasticity, this paper also discussed on reported experiments which can explain the potential causes and mechanisms under this phenomenon. A potentially viable cause of recruitment of cortical areas followed by a sensory loss is thought to be the direct connection of the neurons to the intact sensory area. This paper also discussed on the endeavors made for determining the critical age for crossmodal plasticity. The recent experiments showed that neuroplasticity can occur in a much later age than that were presumed earlier.</p>
<p>Lastly, the paper discussed that in spite of the compensatory behavioral gain, the neuroplasticity cannot be viewed as universally adaptive. It may also have unintended consequences. Following the rehabilitative training, the neuroplastic changes can undermine the ability of the cortex to return back to its primary function.</p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fneural-reorganization%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fneural-reorganization%2F&amp;text=Paper+review%3A+Neural+Reorganization+Following+Sensory+Loss%3A+The+Opportunity+of+Change" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2011/neural-reorganization/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2011/neural-reorganization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Interesting Paper</title>
		<link>http://www.itanveer.com/2011/an-interesting-paper/</link>
		<comments>http://www.itanveer.com/2011/an-interesting-paper/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 06:25:49 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[Science or Scientasy]]></category>

		<guid isPermaLink="false">http://www.itanveer.com/?p=377</guid>
		<description><![CDATA[Shape conveyed by visual-to-auditory sensory substitution activates the lateral occipital complex Amir Amedi 1,2, William Stern 1, Joan A. Camprodon 1, Felix Bermpohl 1,3, Lotfi Merabet 1, Stephen Rotman 1, Christopher Hemond 1, Peter Meijer 4 and Alvaro Pascual-Leone This &#8230; <a href="http://www.itanveer.com/2011/an-interesting-paper/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2 style="text-align: justify;"><strong><a href="http://brain.huji.ac.il/publications/Amedi_at_al_vOICe_Nature_Neuroscience07.pdf">Shape conveyed by visual-to-auditory sensory substitution activates the lateral occipital complex</a></strong></h2>
<p style="text-align: justify;"><strong>Amir Amedi 1,2, William Stern 1, Joan A. Camprodon 1, Felix Bermpohl 1,3, Lotfi Merabet 1, Stephen Rotman 1, Christopher Hemond 1, Peter Meijer 4 and Alvaro Pascual-Leone</strong></p>
<p style="text-align: justify;">This paper reports some functional characteristics of a part of brain known as the lateral-occipital tactile-visual (LOtv) area. Traditionally, this part is known to be activated when a person observes the shape of an object through vision or touch. In this paper, it is claimed that this part of brain is responsible for analyzing shape of an object regardless of the modality of the incoming signal. This assertion has been made based on an experiment where the authors analyzed the functional characteristics of the LOtv area in response to sensory substitution soundscape.<span id="more-377"></span></p>
<p style="text-align: justify;">VOICE is a computer program that converts the raw pixel intensities of a picture into a soundscape. There are some blind and sighted expert users who can perceive the shapes of objects by listening to the soundscapes. Neural images of these people’s brain reveal that when they try to perceive the shape of an object from the soundscape, their LOtv area activates. Moreover, this happened only to the people who were trained to interpret the soundscape and can extract shape information from it. People, who associate a particular soundscape to a particular shape of an object, do not display any activity in this area.</p>
<p style="text-align: justify;">The authors have proposed a hypothesis based on this observation. They claimed that, the LOtv processes the shape information regardless the modality of sensory signal.</p>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fan-interesting-paper%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fan-interesting-paper%2F&amp;text=An+Interesting+Paper" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2011/an-interesting-paper/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2011/an-interesting-paper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mighty Mind : Phantom Limb</title>
		<link>http://www.itanveer.com/2011/mighty-mind-2/</link>
		<comments>http://www.itanveer.com/2011/mighty-mind-2/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 21:39:06 +0000</pubDate>
		<dc:creator>Tanveer</dc:creator>
				<category><![CDATA[Science or Scientasy]]></category>
		<category><![CDATA[neuroscience]]></category>

		<guid isPermaLink="false">http://itanveer.com/?p=293</guid>
		<description><![CDATA[Few weeks back I watched a DVD borrowing from Netflix named "The Secrets of Mind". It is an interesting documentary delving into the deep of human mind, nature and consciousness. It features some work of famous neuroscientist Dr. Vilayanur Ramachandran. This post is mainly a summary of that documentary in my own language. <a href="http://www.itanveer.com/2011/mighty-mind-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><em>[Few weeks back I watched a DVD borrowing from Netflix named "The Secrets of Mind". It is an interesting documentary delving into the deep of human mind, nature and consciousness. It features some work of famous neuroscientist <a href="http://cbc.ucsd.edu/ramabio.html">Dr. Vilayanur Ramachandran</a>. This post is mainly a summary of that documentary in my own language]</em></p>
<p style="text-align: justify;">After the Iraq war, veterans who lost there limbs, sometimes felt unnatural sensations in their lost limbs. How would you explain such phenomenon? For a long time, it was considered as a hoax. Neuroscientists could not accept this as a true sensation because for every sensation there should have some neurons carrying small electric signals to the brain. In the case of phantom limb, this is not possible. Then what?<span id="more-297"></span></p>
<p style="text-align: justify;">Dr. Ramachandran made a pioneering work in explaining phantom limb syndrome while providing treatment to one of his patients named Derick Sting. Derick used to feel vivid presence of his left arm in a strange way. When he used to go for a shave, he felt sensation in the left arm which actually does not exist. It was found in some simple experiment that when Derick&#8217;s left cheek is touched, he feels that sensation both in his cheek and in the left arm. Dr. Ramachandran got very interested. He knew that different parts of our body are mapped to some part of our brain. For example, the entire left part of the body is mapped to a strip on the right part of the brain known as <a href="http://en.wikipedia.org/wiki/Somatosensory_system">somatosensory cortex</a>. So he hypothesized that, when a limb gets amputated it looses its connection from brain and that part of the brain does not receive any signal anymore. Now, without any signal, this part becomes thirsty for some sensory signal and gets more and more sensitive to any kind of electric impulses. When some electronic impulses come to the nearby region, it actually catches that signal and gives a false signal to brain regarding a sensation on the person&#8217;s lost limb. Therefore, the postulation was the brain undergoes a <strong>massive rewiring</strong> after the amputation. Dr. Ramachandran got some scornful comments regarding his hypothesis. One strong argument was based on the dogma that the brains wiring is permanent and does not change once it is developed in the fetus. However, Ramachandran&#8217;s hypothesis got support when neural images provided support on his side.</p>
<p style="text-align: justify;">Amputation can alter brain&#8217;s work not only in receiving signal but also transmitting. A patient used to feel extreme pain like clinching his right hand too much. But there is no right hand in his body. Ramachandran explained this phenomenon like this: When we clinch our hand, it actually sends some feedback to the brain which damps brains signal to clinch. But if the limb is amputated, it does not give any feedback to the brain and as a result brain sends more and more signal which eventually leads to extreme pain.</p>
<p style="text-align: justify;">This problem was solved by the use of a technique named as &#8220;<a href="http://mirrorboxtherapy.com/">mirror-box</a>&#8220;. A mirror box is a kind of apparatus where you see the image of your one hand in place of your another hand. Using this box, if a person moves his left hand, he gets an illusion that his right hand is moving. The patient was advised to put both his hands into the mirror-box and move both hands. Through this, he got a visual clue that his hand his moving. This visual information also acted as a feedback to the brain and the pain started to subside. This proved Ramachandrans theory and a very intriguing assertion that even a pain can be a construct of mind.</p>
<p style="text-align: justify;"><strong>Interesting Follow Ups</strong></p>
<ol>
<li>Ramachandran, V. S., Brang, David and McGeoch, Paul D.(2009) &#8220;<a href="http://cbc.ucsd.edu/pdf/shrinking_phantom.pdf">Size reduction using Mirror Visual Feedback (MVF) reduces phantom pain</a>&#8220;, Neurocase, 99999:1 DOI 10.1080/13554790903081767</li>
<li>Ramachandran, VS &amp; Hirstein, W (1998). <a href="http://cbc.ucsd.edu/pdf/Percpt_Phantom_Limbs_Brain.pdf">The perception of phantom limbs</a>: The D. O. Hebb lecture. <em>Brain</em>, 121, 1603-1630.</li>
</ol>

				<div class="mr_social_sharing_wrapper">
				<!-- Social Sharing Toolkit v2.0.8 | http://www.active-bits.nl/support/social-sharing-toolkit/ --><span class="mr_social_sharing"><iframe src="https://www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fmighty-mind-2%2F&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe></span><span class="mr_social_sharing"><a href="https://twitter.com/share?url=http%3A%2F%2Fwww.itanveer.com%2F2011%2Fmighty-mind-2%2F&amp;text=Mighty+Mind+%3A+Phantom+Limb" target="_blank" class="mr_social_sharing_popup_link"><img src="http://www.itanveer.com/wp-content/plugins/social-sharing-toolkit/images/buttons/twitter.png" alt="Share on Twitter" title="Share on Twitter"/></a></span><span class="mr_social_sharing"><g:plusone size="medium" href="http://www.itanveer.com/2011/mighty-mind-2/"></g:plusone></span></div>]]></content:encoded>
			<wfw:commentRss>http://www.itanveer.com/2011/mighty-mind-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

