tag:blogger.com,1999:blog-80147275661078785062024-03-13T03:20:41.254-07:00Tech StuffNerdLandAnonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.comBlogger34125tag:blogger.com,1999:blog-8014727566107878506.post-34636970112012280122012-09-07T13:55:00.004-07:002012-09-07T13:56:48.956-07:00Downloading photos from flickr<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="p1">
I thought this might be helpful for people who want to download flickr images using api and can save them some time:</div>
<ol class="ol1">
<li class="li2"><span class="s1">Get an authentication key from flickr: <a href="http://www.flickr.com/services/api/misc.api_keys.html"><span class="s2">http://www.flickr.com/services/api/misc.api_keys.html</span></a></span></li>
<li class="li2"><span class="s1">Install flickrapi: <a href="http://pypi.python.org/pypi/flickrapi"><span class="s2">http://pypi.python.org/pypi/flickrapi</span></a> </span></li>
<ol class="ol1">
<li class="li3">The easiest way to do this is using pip: </li>
<ul class="ul1">
<li class="li3"><b>sudo port install py32-pip(mac only, sudo apt-get install pip for linux?)</b></li>
<li class="li3"><b>pip-3.2 install flickrapi ( depending on your pip version change the command.</b></li>
</ul>
</ol>
<li class="li3">Run the attached python script with three command line arguments:</li>
<ol class="ol1">
<li class="li3">Search query to retrieve photos of</li>
<li class="li3">Number of photos</li>
<li class="li3">Output directory to save to ( The sub-directory structure is similar to flickr's internal directory structure, You can modify the FlickrPhoto class to modify this behavior).</li>
</ol>
<li class="li3">This script uses the tag based search query. The code also has a way to use the search query instead of tag based query(commented out). All special arguments explained in the link for more information: <a href="http://www.flickr.com/services/api/flickr.photos.search.html"><span class="s3">http://www.flickr.com/services/api/flickr.photos.search.html</span></a></li>
</ol>
<div class="p3">
I copied/modified this code from a friend who in turn copied/modified it from an existing api tutorial. You do not have to cite either of us! :-)</div>
<div class="p3">
<br /></div>
<div class="p3">
<b>NOTE: THIS CODE WILL NOT WORK UNTIL YOU FILL THE TWO KEYS INSIDE THE CODE. (LINE 47 and 48)</b></div>
<div class="p3">
<br /></div>
<div class="p3">
Code: <a href="http://dl.dropbox.com/u/14073242/Blog/techtidings/flickr/DownloadTask.py">http://dl.dropbox.com/u/14073242/Blog/techtidings/flickr/DownloadTask.py</a></div>
</div>
Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-63139508527614038042012-04-27T21:23:00.000-07:002012-04-27T21:23:17.539-07:00OSAP - Optimal Seating Arrangement Problem<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Recently, I went with bunch of folks from my lab to Ormsby's. We were seated in a pretty big table(rectangular) that could host 16 people, we were 12. Each one of us sat arbitrarily(of course fighting for places with eye catching views(girls!)). We started chatting. I talked for a while with people sitting beside me. Then, I tried to talk to people on the opposite side and other folks. There was so much noise that it was very difficult to have any conversation. After shouting at the top of my voice for a while I got tired and just enjoyed my dinner. For the rest of the time I was thinking of this problem and tried to formalize it in my mind. I tried searching for the problem on Google but could not find anything. So, I named it Optimal Seating Arrangement Problem(OSAP). Below I provide the formal description. Anyone wants to propose an algorithm?</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: center;">
<b><span style="font-size: large;">OSAP - Optimal Seating Arrangement Problem</span></b></div>
<div style="text-align: center;">
<b><span style="font-size: large;"><br /></span></b></div>
<div style="text-align: justify;">
<b>Problem Statement</b>: Design an algorithm to find an optimal seating arrangement for a group of friends of size <i>n </i>on a round table. Each person in the group has a preference for every other person. The preference values lie between <i>0</i> and <i>1</i>. Also, the sum of the preference values for a person's friends should equal to <i>1.</i> The optimal arrangement is the arrangement with the highest score where the score of an arrangement is calculated by adding the score of individual person and the score of an individual person is sum of the preference values of his neighbors. A neighbor of a person is someone sitting either to the immediate left or immediate right of the person. <br />
<br />
<b>Input</b>: <i>n </i>followed by <i>n X n </i>matrix. Row <i>i</i> contains the preference values of person <i>i</i> for every other person in the group. <br />
<br />
<b>Example Inputs:</b><br />
<b>Input</b>: 3<br />
0 0.1 0.9<br />
0.5 0 0.5<br />
0.6 0.4 0<br />
<br />
<b>Output</b>:<br />
1 2 3 or 2 3 1 or 3 2 1or 1 3 2 or 2 1 3 or 3 1 2 ( All of them will have equal score in case of <i>n</i> = 3 )<br />
<br />
<b>Input</b>: 4<br />
0 0 0.1 0.9<br />
0 0 0.1 0.9<br />
0.5 0.5 0 0<br />
0.9 0.1 0 0<br />
<br />
<b>Output</b>:<br />
<br />
3 1 4 2 or any permutation ( 1 4 2 3, 4 2 3 1, 2 3 1 4 )<br />
<br />
<b>What is the complexity of the optimal algorithm?</b><br />
<br /></div>
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-83292660563082905802012-03-22T22:57:00.004-07:002012-03-22T23:01:06.444-07:00Joint(Cross) Bilateral Filter<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="text-align: justify;">
I have been meaning to write about this for a while but due to two conference deadlines I did not get time. Anyway it is one of the most interesting things I read and implemented recently which helped immensely in my project. Joint bilateral filter is also referred to as Cross bilateral filter. Both mean the same. Without any further ado let me motivate its necessity and then provide some explanation with results. I will make the matlab, c++ and java code available on my <a href="https://sites.google.com/site/balamanohar/resources" target="_blank">website</a> very soon.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
A basic course in image processing will teach you about low pass filtering. In layman's language smoothing. An image is fundamentally composed of two types of frequency components, low and high. Low frequency components signify smooth and constant regions where as high frequency components signify edges and corners. So, a low pass filter passes low frequency components untouched but smoothes the high frequency components. Typically smoothing is a process of convolving a kernel with the image at each pixel location. It is used to reduce noise. The typical kernel is a uniform or a Gaussian kernel. These kernels work very well in general but have issues near edges/boundaries. They induce artifacts because the resulting value after smoothing at the boundary pixel comes from two different regions. The edges are not preserved. Bilateral filter is a technique that can be used to perform edge preserving smoothing. There are variants to this namely anisotropic diffusion. I will not go into details of that in this post. So, in short bilateral filter modifies the kernel based on the local content so that edges are preserved.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Taking it a step further imagine you have two sources and you want to smooth one source based on the similarity of the other source. A typical example is if you have color image and depth image and you want to smooth the color image such that color does not bleed across depth boundaries. That is when you use the joint/cross bilateral filter. Here, the kernel is a combination of weights based on the color similarity and depth similarity. Thus the filter will only smooth values with similar color and depth and keep the rest untouched. This is a simple but elegant solution that has tremendous applications. The application I am interested in and where I used this in my research is to smooth the color image as a preprocessing step to perform over-segmentation.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Below I share three images, the input image, result obtained by smoothing the color image using a Gaussian filter alone and result obtained by using the joint bilateral filter. You can clearly see that the edges are preserved but the rest of the content is smoothed out. Keep in mind that along with the color image I have the corresponding(registered) depth data. Without an additional source of information you can only apply bilateral filter, not cross bilateral filter.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3OKOj1LNowXQlG5OlByqbKxCsQ0yEm_wsx_z0f-rjsBG2ePCbRU8F2vU_o_97OEsdesxsdBpttMyP2oixxYFUSQLXhRuMZXrusloAFgUfpILqqBEdUoH8ociPh1liAsAktZ7nRJlBpFma/s1600/input.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3OKOj1LNowXQlG5OlByqbKxCsQ0yEm_wsx_z0f-rjsBG2ePCbRU8F2vU_o_97OEsdesxsdBpttMyP2oixxYFUSQLXhRuMZXrusloAFgUfpILqqBEdUoH8ociPh1liAsAktZ7nRJlBpFma/s200/input.png" width="200" /></a><a href="http://3.bp.blogspot.com/-mdX5Vsl3wGM/T2wQTiZ2_vI/AAAAAAAAFcY/78Ipit19zmQ/s1600/depth.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="151" src="http://3.bp.blogspot.com/-mdX5Vsl3wGM/T2wQTiZ2_vI/AAAAAAAAFcY/78Ipit19zmQ/s200/depth.png" width="200" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzqIocEr0HYVwzMSxVv7lowInH-Fmg1n_kZnpZi0NVLMM6jydGluRYOxbRjobvpNmpFSrhxjuwOJeyYD00vBLEazoxO53BR9M782Rgk7uhPlBHizxMw3Vcu8rwAS3grJ0r1Ycp3pKI0k98/s1600/afterSmoothing_gaussian.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzqIocEr0HYVwzMSxVv7lowInH-Fmg1n_kZnpZi0NVLMM6jydGluRYOxbRjobvpNmpFSrhxjuwOJeyYD00vBLEazoxO53BR9M782Rgk7uhPlBHizxMw3Vcu8rwAS3grJ0r1Ycp3pKI0k98/s200/afterSmoothing_gaussian.png" width="200" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNNBxcSW-AfI8bvXFE95g7nXSQtsHkPU8dAlMp4uYaNWjOoe35TM49qm1-tTxFnoXXS6FYwJ-Wfq1jTXRgZdbcqeeH7nIJk-lMkeMIRJ6CaYceoUQ099qUl_z7IiDGgT077oMkgD6u2ti7/s1600/afterSmoothing_cbf.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNNBxcSW-AfI8bvXFE95g7nXSQtsHkPU8dAlMp4uYaNWjOoe35TM49qm1-tTxFnoXXS6FYwJ-Wfq1jTXRgZdbcqeeH7nIJk-lMkeMIRJ6CaYceoUQ099qUl_z7IiDGgT077oMkgD6u2ti7/s200/afterSmoothing_cbf.png" width="200" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: justify;">
I will discuss about the two papers that are relevant to this in my <a href="http://jiffypaper.blogspot.com/" target="_blank">JiffyPaper blog</a>.</div>
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com2tag:blogger.com,1999:blog-8014727566107878506.post-79613233711266335842012-02-29T20:35:00.000-08:002012-03-22T22:58:58.351-07:00Synchronizing(Syncing) Bookmarks, Passwords and even Open Tabs<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
I am amazed at the extensions and utilities available for browsers these days :-)</div>
<div style="text-align: justify;">
I work on three different machines on a given day: My Desktop, Lab laptop and home laptop. One of the many features I wanted was to be able to synchronize my browsers across these machines. They use different operating systems and I end up using either chrome, firefox and sometimes internet explorer. Firstly, I love Chrome because it syncs to my google account which has many uses but the main one being synchronizing bookmarks and extensions across machines.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Then, I added Lastpass another extension that is a password manager. I dont remember passwords to most of the websites as they are automatically generated using Lastpass! Its an amazing tool that will save you a lot of time.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Finally, I found Xmarks another extension that takes synchronization a step further. It synchronizes open tabs across machines! How cool is that? In the lab I can now open tabs that are open on my laptop at home. Its made the entire process of moving across machines so much easier.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I strongly suggest anyone who is looking to deal with synchronizing your work on the browsers across machines to use the following combination: <b>Chrome browser + Synchronize with Google account + Lastpass + Xmarks</b></div>
<div style="text-align: justify;">
<b><br /></b></div>
<div style="text-align: center;">
<div style="text-align: justify;">
<b>!!!The combination is uncanny!!!</b></div>
</div>
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-14304278301562469712012-02-15T14:24:00.001-08:002012-03-22T22:59:08.834-07:00Opencv knnSearch example<div dir="ltr" style="text-align: left;" trbidi="on">
After searching through the web and going through the <a href="http://www.cs.ubc.ca/~mariusm/index.php/FLANN/FLANN" target="_blank">FLANN</a> api I could not find a decent example that showcases the K nearest neighbor search capability. I found that OpenCV also has a wrapper written around flann so checked if there exists a simple example. To my dismay I could not find one. So, I spent couple of hours and put together the following code. Hope someone looking to use flann with opencv will find this example useful!<br />
<br />
The example generates data randomly centered around a mean and a variance of arbitrary dimensions(provided by user, default is 1) and generates query data with similar properties and invokes the single query and batch knnSearch function calls and prints out. Just to let you know its not a class, its just a simple example to help people use knnSearch function in openCV. Enjoy!<br />
<br />
code: <a href="http://dl.dropbox.com/u/14073242/Blog/techtidings/cvKnn/cvKnn.cpp" target="_blank">cvKnn.cpp</a><br />
Command to compile the code: <i><b>g++ cvKnn.cpp -L /usr/lib -lopencv_core -lopencv_flann -o cvKnn</b></i></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com10tag:blogger.com,1999:blog-8014727566107878506.post-37305986722719704542012-01-19T08:24:00.000-08:002012-03-22T22:59:58.369-07:00Demosaicing: Normal, edge aware and edge weighted!<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Bayer pattern is a common term you will come across while working with a digital camera. Wikipedia does a great job at explaining the Bayer pattern: <a href="http://en.wikipedia.org/wiki/Bayer_filter" target="_blank">wiki</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Bayer Pattern:</b></div>
<div style="text-align: justify;">
The most straightforward explanation is you have a CCD with three types of photo sensors(red, green and blue). Green are sensitive to luminance and red and blue are sensitive to chrominance(color). Apparently, human eyes are more sensitive to luminance so in a typical CCD you will have twice as many green sensors as the red and blue ones. These photo sensors are arranged in a specific pattern(RGBG, GRBG, RGGB). The raw output(also referred to bayer pattern image) will record only one of the three colors at each photo sensor. Each photo sensor has a corresponding pixel in the image. From the bayer pattern we only have the raw value at each pixel but we want to know the true color(r,g,b). This process of computing the color at each pixel is called demosaicing(or debayering?). A typical arrangement of photo sensors is shown in the image below ( linked from Wikipedia ).</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://upload.wikimedia.org/wikipedia/commons/thumb/3/37/Bayer_pattern_on_sensor.svg/350px-Bayer_pattern_on_sensor.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="208" src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/37/Bayer_pattern_on_sensor.svg/350px-Bayer_pattern_on_sensor.svg.png" width="320" /></a></div>
<br />
<br />
<b>Demoasicing:</b><br />
<div style="text-align: justify;">
There are number of methods out there that do demosaicing and a survey of all the techniques is out of scope of this post. I myself implemented three techniques which are intuitive, computationally less expensive and work reasonably well.</div>
<div style="text-align: justify;">
<br /></div>
<b>Normal:</b><br />
<div style="text-align: justify;">
This is the first thought that will come to anybody's mind:</div>
<div style="text-align: justify;">
For each pixel do bilinear interpolation. So depending on where you are in the pattern the bilinear interpolation will vary. For example in the above image if you are on the green with two reds on top and bottom, you will just take the average of the red value. But, if you are on the blue you will take average of all four neighboring reds etc. This approach works reasonably well but artifacts (aliasing, zippering, purple fringing etc.) show up on the edges. These are quite noticable.</div>
<div style="text-align: justify;">
<br /></div>
<b>Edge Aware:</b><br />
<div style="text-align: justify;">
Since most of the artifacts are on/near the edges, instead of blindly doing bilinear interpolation you do edge aware interpolation. For example below if you are trying to find the green value at position <b>B</b>, you will only take the average of the green values with smaller gradient. i.e. first you compute the difference of horizontal green values and vertical green values and pick the option with lower difference and take the average of those two green values. This change makes the demosaicing much better.</div>
<div style="text-align: justify;">
<b><br /></b></div>
<b></b><br />
<div style="text-align: center;">
<b>grgrg</b></div>
<div style="text-align: center;">
<b>bgBgb</b></div>
<div style="text-align: center;">
<b>grgrg</b></div>
<div style="text-align: center;">
<b><br /></b></div>
<br />
<b>Edge Aware Weighted:</b><br />
<div style="text-align: justify;">
Taking it a step further instead of blindly discarding the two green values with higher gradient we take a weigh the horizontal and vertical ones according to the gradient values. Lets define the following:</div>
<div style="text-align: center;">
<div style="text-align: justify;">
<br /></div>
</div>
<div style="text-align: center;">
<b>HDiff = LeftGreen - RightGreen</b></div>
<div style="text-align: center;">
<b>HSum = LeftGreen + RightGreen</b></div>
<div style="text-align: center;">
<b>VDiff = TopGreen - BottomGreen</b></div>
<div style="text-align: center;">
</div>
<div style="text-align: center;">
<b>VSum = TopGreen + BottomGreen</b></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<b>Final = 0.5 * (VSum * HDiff + HSum*VDiff ) / (HDiff + VDiff)</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: justify;">
I will leave it to your intuition why <b>0.5</b> is needed :-) This small extension is less prone to noise and also keeps strong edges intact.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
This drastically improves results. There might be even more fancier ways but for now I fixed my issue so I will research further in future! For comparison purposes I am including the sample images after using the normal(left) and edge aware weighted(right) . <b>Observe across the edges on the chair, board and any other place. </b>You can judge the difference yourself..</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-97TdbNrb_UA/TxhDdxotJqI/AAAAAAAAFJE/5WYWELkOnbg/s1600/openni.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="http://3.bp.blogspot.com/-97TdbNrb_UA/TxhDdxotJqI/AAAAAAAAFJE/5WYWELkOnbg/s200/openni.bmp" width="200" /></a><a href="http://3.bp.blogspot.com/-SCwTF0s-qyw/TxhDcxs-ebI/AAAAAAAAFI8/efz4lshwu8w/s1600/freenect.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="http://3.bp.blogspot.com/-SCwTF0s-qyw/TxhDcxs-ebI/AAAAAAAAFI8/efz4lshwu8w/s200/freenect.png" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br /></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com1tag:blogger.com,1999:blog-8014727566107878506.post-65570905960775287232012-01-16T16:27:00.000-08:002012-03-22T23:00:16.390-07:00Ubuntu 11.10 check battery status hang<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
I was facing this issue and had no clue how to resolve it. After playing around with grub and various lightdm settings and reading bunch of forums related to the problem I could not resolve it.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I thought it was a longshot but just tried to reinstall the nvidia-drivers and Voilla!! So, for people who faced similar issue, make sure you have the Nvidia driver in one of the folders and boot into text mode(check ubuntu forums on how to modify grub to boot into text mode ) and then reinstall the drivers.</div>
<div style="text-align: justify;">
Hope this solves your problem :-)</div>
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-17626511881552759682012-01-14T08:51:00.000-08:002012-01-14T08:51:46.379-08:00Problem with libGL.so on 64-bit Ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
I have an Nvidia card and as expected I installed Nvidia drivers for my ubuntu. But, whenever I compiled programs that used OpenGL ( libGL.so ) I ran into compile errors similar to:<br />
<br />
No rule to make target `/usr/lib/x86_64-linux-gnu/libGL.so'<br />
<br />
I was sure there was some problem with my libGL.so file so I ended up looking at it properties and found out that it was a broken link pointing to 'mesa/libGL.so' which in turn was pointing to 'libGL.so.1' which never existed.<br />
<br />
<b>bpaluri3@bpaluri3:~/libfreenect/build$ ls -l /usr/lib/x86_64-linux-gnu/libGL.so </b><br />
<b>lrwxrwxrwx 1 root root 13 2011-08-10 04:20 /usr/lib/x86_64-linux-gnu/libGL.so -> mesa/libGL.so</b><br />
<br />
<b>bpaluri3@bpaluri3:~/libfreenect/build$ ls -l /usr/lib/x86_64-linux-gnu/mesa/libGL.so </b><br />
<b>lrwxrwxrwx 1 root root 10 2011-08-10 04:20 /usr/lib/x86_64-linux-gnu/mesa/libGL.so -> libGL.so.1</b><br />
<div>
<br /></div>
<br />
Then I verified the libGL.so.1 in my /usr/lib directory and found out that it pointed to libGL.so.290.10 which is the file provided by the nvidia driver.<br />
<br />
<b>bpaluri3@bpaluri3:~/libfreenect/build$ ls -l /usr/lib/libGL.so.1 </b><br />
<b>lrwxrwxrwx 1 root root 15 2012-01-09 13:53 /usr/lib/libGL.so.1 -> libGL.so.290.10</b><br />
<br />
I just overwrote the symbolic link in `/usr/lib/x86_64-linux-gnu/libGL.so' with the nvidia openGL library i.e. `/usr/lib/libGL.so' ( I had to delete the old symbolic link before I do this ).<br />
<br />
<b>bpaluri3@bpaluri3:~/libfreenect/build$ sudo rm /usr/lib/x86_64-linux-gnu/libGL.so </b><br />
<b>bpaluri3@bpaluri3:~/libfreenect/build$ sudo ln -s /usr/lib/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so </b><br />
<br />
The final two statements are the fixes for the libGL error and I hope anyone who runs into a similar issue will find this information useful.<br />
<div>
<br /></div>
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com34tag:blogger.com,1999:blog-8014727566107878506.post-45179440504018456292012-01-11T00:19:00.000-08:002012-01-11T00:23:30.631-08:00C++: Accessing members of Templated base classes<div dir="ltr" style="text-align: left;" trbidi="on">
I spent a considerable time debugging the following error after compiling the c++ code I am writing:<br />
<b><br /></b><br />
<b>there are no arguments to <function<function>><function\> <function>that depend on a template parameter, so a declaration of </function></function\></function></b><b><function<function>></function></b><b><function\> </function\></b><b><function><function>must be available</function></function></b><br />
<b><br /></b><br />
To make the matters simple and to explain what is happening, lets use the following example. I have a base class which is templated, and a derived class that invokes a function from the base class but the function is not "dependent" ( dependent here means the function depends on the type of the template paramter ). In this case foo is not dependent on the template parameter T. The derived class has a function that invokes foo, this call is also not dependent on the template parameter ( there are no arguments that depend on T ).<br />
<br />
<br />
<b>template <typename t=""> class base{</typename></b><br />
<b>public:</b><br />
<b> void foo(int i) {</b><br />
<b> // do something with i </b><br />
<b> }</b><br />
<b>};</b><br />
<b><br /></b><br />
<b>template <typename t=""> class derived:public base<t>{</t></typename></b><br />
<b> int bar() {</b><br />
<b> foo();</b><br />
<b> }</b><br />
<b>};</b><br />
<b><br /></b><br />
<br />
<div class="p1">
Again, the call to <span class="s1">foo()</span> is not dependent on template arguments (there are no arguments that depend on the type <span class="s1">T</span>). This will work only if a global declaration of foo is available, since the one in the base class is not visible until instantiation time, you will get the following compiler error message:</div>
<div class="p1">
<br /></div>
<div class="p1">
</div>
<div class="p1">
<b>: In member function ‘int derived<t>::bar()’:</t></b></div>
<div class="p1">
<b>error: there are no arguments to ‘foo’ that depend on a template parameter, so a declaration of ‘foo’ must be available</b></div>
<div class="p1">
<b>error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)</b></div>
<div class="p1">
<b><br /></b></div>
<div class="p1">
<b>To solve the problem we have to either use this->foo() or base<t>::foo(). </t></b></div>
<div class="p1">
You can also compile with -fpermissive flag which allows the compiler to relax the diagnostics for nonconformant code errors to warnings. Its not a good idea though ( for various reasons that I understand but dont have time to explain for now! :-)</div>
<div class="p1">
<br /></div>
<div class="p1">
In conclusion, Name lookup is a bit tricky because of the two stage approach by the GCC compiler ( apparently since version 3.4 ). <span style="text-align: -webkit-auto;">The distinction between lookup of dependent and non-dependent names is called two-stage (or dependent) name lookup.</span><span style="text-align: -webkit-auto;"> Hope this helps someone who get simliar errors.</span></div>
<br />
<br /></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com2tag:blogger.com,1999:blog-8014727566107878506.post-11516807753389525072012-01-06T08:14:00.000-08:002012-01-06T08:15:13.588-08:00Windows XP, 7 install cds hangup<div dir="ltr" style="text-align: left;" trbidi="on">
I ran into a problem of corrupted partition table when I deleted one of the logical drives on my laptop. I tried to install windows XP and Windows 7 but both cds just froze in the initial setup itself. Having had no clue I tried searching around and found a solution hidden in midst of lot of information. Here is a thing you could do although this will screw up the partition table and in my case I was okay reinstalling stuff without worrying about the data. If that is not the case with you have to find a better way.<br />
<br />
<span style="background-color: #fcfcfc;"><span style="color: #111111; font-family: vera-sans-1, vera-sans-2, Helvetica, Arial, sans-serif;"><span style="font-size: 14px; line-height: 21px;">I had linux partitions and I just inserted the Linux live cd and formatted the MBR with the following command and voila! </span></span></span><br />
<span style="background-color: #fcfcfc; color: #111111; font-family: vera-sans-1, vera-sans-2, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px;"><b>dd if=/dev/zero of=/dev/sda bs=512 count=1 </b></span></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-54929063187389219062012-01-03T16:09:00.000-08:002012-01-06T08:15:37.495-08:00Clustering - Silhouette, K-means & K-medoids<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
One of my friend sent out an email asking for suggestion on an algorithm to cluster data given a similarity matrix. And that led to a discussion and another friend forwarded a link to k-medoids algorithm and suggested using it instead of k-means because its more robust to noise etc. But I was still wondering how to find the right k and even if I find the right k is k-medoids better than k-means. I was going to leave it to my friend to figure it out but was too impatient to wait that long.<br />
<br />
So, I decided to investigate more and kept reading the wikipedia pages and research papers pertitnent to the topic. Instead of just reading this time I wanted to challenge myself. So, I kept a But, instead of just reading it I wanted to challenge myself. So,<b> I set a 5 hour deadline, to understand, formalize, implement, test, create a video, upload and finally write this blog post on it. I started a timer and boy I was in for a surprise... It took me 6 hours to get everything done :(</b><br />
<br />
There are three advantages I found in doing this.<br />
1) I learnt about the <b>two methods and related work in a quick time, good enough to implement them and know their limitations</b>.<br />
2) A timer countdown <b>helps you focus and ignore everything else</b> instead of just saying I will do this today!<br />
3) Most important, I wanted to see <b>how fast I could transition from basic knowledge to the point of having a running code and beautiful outputs with a good report and finally a blog entry</b> that will stay forever(or till blogspot's existence)<br />
<br />
I started on a whiteboard with todo list(image below) and time estimates and within 4 hours got the code working after which I had to spend time on making the video, writing the report, uploading, creating the blog entry etc..<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-aINJU5ZgEN4/TwOVp8-eMHI/AAAAAAAAFHQ/8CrORiwUvc4/s1600/Photo+Jan+03%252C+3+59+18+PM+%2528HDR%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-aINJU5ZgEN4/TwOVp8-eMHI/AAAAAAAAFHQ/8CrORiwUvc4/s320/Photo+Jan+03%252C+3+59+18+PM+%2528HDR%2529.jpg" width="237" /></a></div>
<br />
<br />
<div style="text-align: center;">
<b><span style="font-size: large;">The youtube video of the final output</span></b></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/4F0f9vmbp-g?feature=player_embedded' frameborder='0'></iframe></div>
<br />
<br />
<div style="text-align: center;">
<span style="font-size: large;">Report: <a href="https://docs.google.com/open?id=0B-mKP9AVXZV2YTMyZmNjZDktOGIxYS00ZTEzLWIyYzMtZWJiZjc5ZjgwMWYy" target="_blank">pdf</a></span></div>
<div style="text-align: center;">
<span style="font-size: large;">Matlab code: </span><span style="text-align: left;"><span style="font-size: large;"><a href="https://docs.google.com/open?id=0B-mKP9AVXZV2NmZlZTIwYTItNjE4Yy00Y2VmLWE4OWYtZjdjMGIyNDA1Mzhh" target="_blank">code</a></span></span></div>
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com1tag:blogger.com,1999:blog-8014727566107878506.post-90011532965157873482011-11-02T19:08:00.000-07:002011-11-02T19:08:34.294-07:00gitk on MAC<div dir="ltr" style="text-align: left;" trbidi="on">
I had trouble getting gitk to work on my mac. It did not do anything and did not throw an error as well. After reading through some forums I found that the PATH variable is the culprit. In my .profile ( or in .bashrc), wherever you set PATH variable I had set it the following way:<br />
<br />
export PATH=/opt/local/bin:/opt/local/sbin:$PATH<br />
<br />
I modified it to the following:<br />
<br />
<br />
export PATH=$PATH:/opt/local/bin:/opt/local/sbin<br />
<br />
and everything works fine now. Hopefully someone with similar issues will land up on this page.<br />
<div>
<br /></div>
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-47822446250857146652011-07-28T12:19:00.000-07:002011-07-28T12:19:54.490-07:00Debian changing root password<div dir="ltr" style="text-align: left;" trbidi="on">Follow these instructions to boot into single user mode and change the password of root on Debian.<br />
<br />
1) When GRUB loads press <b>'e'</b><br />
2) Find the line with initrd and goto the end and add <b>init=/bin/sh</b><br />
3) Press Ctrl + x to boot<br />
4) You will get a prompt with <b>#</b><br />
5) You need to remount the root filesystem in read write mode by using the command <b>mount -o remount rw /</b><br />
6)<b> </b>use the command <b>passwd</b> to set the new password.<br />
<br />
Done!</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-61655681574957687732011-07-09T01:38:00.000-07:002011-07-18T08:28:37.342-07:00Statistics is FUN!This summer I am taking a basic statistics course and auditing an advanced one. If the basic one is increasing my knowledge and giving me the confidence the advanced one is killing me!(in a very very good way!) After a very long time have I have had to spend nights understanding things from various textbooks and the joy in doing it is awesome! I am writing this post to share few thoughts and resources related to the topic.<br />
<br />
1) In the past many of my friends have asked me for soft copies of ebooks. I download most of them from the following site: <a href="http://library.nu/">http://library.nu</a><br />
I found almost 90% of the textbooks & novels I searched for from this website. I am using the following four statistics books to keep myself busy! Each book uses a different notation which gets to me more often than not but as of now the patience is paying off.<br />
a) Probability & Statistics by Athanasios Paupoulis<br />
b) Probability & Statistics in Engineering by Hines et. al.<br />
c) Theory and problems of probability & statistics by Schaum series<br />
d) All of statistics by Weisserman<br />
<br />
2) I hate calculating expecation, covariance and correlation and all that crap for discrete distributions. Firstly, the calculations are cumbersome and secondly I hate Algebra! So, I put together the following script that calculates these. Just update the pdf and x, y vectors and you will get all the answers you need.<br />
<br />
<blockquote><blockquote>pdf=[11/50, 4/50, 2/50, 1/50, 1/50, 1/50;</blockquote><blockquote>8/50, 3/50, 2/50, 1/50, 1/50, 0;</blockquote><blockquote>4/50, 3/50, 2/50, 1/50, 0, 0;</blockquote><blockquote>3/50, 1/50, 0, 0, 0, 0;</blockquote><blockquote>1/50, 0, 0, 0, 0, 0;]</blockquote><blockquote>x = [0:5]</blockquote><blockquote>y = [0:4]</blockquote><blockquote><br />
</blockquote><blockquote>fx = sum(pdf)</blockquote><blockquote>fy = sum(pdf,2)'</blockquote><blockquote>ex = sum(x.*fx)</blockquote><blockquote>ex2 = sum(x.*x.*fx)</blockquote><blockquote>varx = ex2 - ex*ex</blockquote><blockquote>ey = sum(y.*fy)</blockquote><blockquote>ey2 = sum(y.*y.*fy)</blockquote><blockquote>vary = ey2 - ey*ey</blockquote><blockquote>[xgrid ygrid] = meshgrid(x,y)</blockquote><blockquote>exy = sum(sum(xgrid.*ygrid.*pdf))</blockquote><blockquote>covxy = exy - ex*ey</blockquote><blockquote>corr = covxy/(sqrt(varx)*sqrt(vary))</blockquote><div><br />
</div></blockquote>3) Proofs have always intrigued me. Although there is lot of fun in using a formula to get the answer and feel satisfied, I always found real satisfaction in deriving the formula. Being a computer science major has deprived me of such opportunities. But thanks to the stats course I get to sit and prove stuff again :-)<br />
I am sharing two of the proofs for which I did not find straightforward solutions online. I hope it helps others who are trying to understand the proofs.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-ITtWcIynh4Y/ThgTZLOTc3I/AAAAAAAAFBk/GHXfRC4S8eI/s1600/Photo+Jul+09%252C+4+15+31+AM.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-ITtWcIynh4Y/ThgTZLOTc3I/AAAAAAAAFBk/GHXfRC4S8eI/s320/Photo+Jul+09%252C+4+15+31+AM.jpeg" width="239" /></a></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com1tag:blogger.com,1999:blog-8014727566107878506.post-44284542640325594162011-06-26T09:41:00.000-07:002011-06-26T09:41:46.403-07:00Probability Distributions<div dir="ltr" style="text-align: left;" trbidi="on">I am playing around with various discrete and continuous distributions for a statistics course assignment. So, I thought of spending few extra minutes and make a matlab script that would plot all of these. Below is the simple matlab script that plots Uniform, Exponential, Normal distributions. The Normal distribution can be generated using inverse transform, box-muller method and the most famous theorem in statistics: The Central Limit theorem.<br />
<br />
I want to extend the script to take various parameters and plot more distributions like weibull, poisson etc. but I dont have time right now!<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-aThRBWxrUWM/Tgdg0W0ELYI/AAAAAAAAE8Q/mVfRlEI2CgE/s1600/1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://1.bp.blogspot.com/-aThRBWxrUWM/Tgdg0W0ELYI/AAAAAAAAE8Q/mVfRlEI2CgE/s400/1.bmp" width="400" /></a><a href="http://3.bp.blogspot.com/-Vlj5IQ-MLQA/Tgdgz2RRfDI/AAAAAAAAE8M/SH66f8jKuc8/s1600/3.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://3.bp.blogspot.com/-Vlj5IQ-MLQA/Tgdgz2RRfDI/AAAAAAAAE8M/SH66f8jKuc8/s400/3.bmp" width="400" /></a></div><br />
Code:<br />
<blockquote><blockquote><br />
</blockquote><blockquote>%% Uniform distribution using 100 instances</blockquote><blockquote>u1 = rand(1,100);</blockquote><blockquote><br />
</blockquote><blockquote><br />
</blockquote><blockquote>%% Uniform distribution using 1000 instances</blockquote><blockquote>u2 = rand(1,1000);</blockquote><blockquote><br />
</blockquote><blockquote>%% Exponential distribution using 100 instances</blockquote><blockquote>e1 = -log(u1);</blockquote><blockquote><br />
</blockquote><blockquote>%% Exponential distribution using 1000 instances</blockquote><blockquote>e2 = -log(u2);</blockquote><blockquote><br />
</blockquote><blockquote>%% Normal distribution using inverse transform method</blockquote><blockquote>n1 = norminv(u2,0,1);</blockquote><blockquote><br />
</blockquote><blockquote>%% Normal distribution using box-muller method</blockquote><blockquote>n2 = sqrt(-2*log(rand(1,1000))).*cos(2*pi*rand(1,1000));</blockquote><blockquote><br />
</blockquote><blockquote>%% PLOT1 ( Uniform, Exponential, Normal distributions )</blockquote><blockquote>figure(1),subplot(3,2,1),hist(u1,10),title('Uniform using 100 instances');</blockquote><blockquote>figure(1),subplot(3,2,2),hist(u2,10),title('Uniform using 1000 instances');</blockquote><blockquote>figure(1),subplot(3,2,3),hist(e1,10),title('Exponential using 100 instances');</blockquote><blockquote>figure(1),subplot(3,2,4),hist(e2,10),title('Exponential using 1000 instances');</blockquote><blockquote>figure(1),subplot(3,2,5),hist(n1,10),title('Normal using inverse transform method');</blockquote><blockquote>figure(1),subplot(3,2,6),hist(n2,10),title('Normal using Box-Muller method');</blockquote><blockquote><br />
</blockquote><blockquote>%% Triangular distribution</blockquote><blockquote>t1 = rand(1,1000);</blockquote><blockquote>t2 = rand(1,1000);</blockquote><blockquote>t3 = t1 + t2;</blockquote><blockquote><br />
</blockquote><blockquote>%% Central Limit Theorem</blockquote><blockquote>n = 12;</blockquote><blockquote>for i = 1:n</blockquote><blockquote> t(i,:) = rand(1,1000);</blockquote><blockquote>end</blockquote><blockquote>n3 = sum(t);</blockquote><blockquote><br />
</blockquote><blockquote>%% PLOT2 ( Trinagular and Normal distributions )</blockquote><blockquote>figure(2),subplot(1,2,1),hist(t3),title('Traingular distribution');</blockquote><blockquote>figure(2),subplot(1,2,2),hist(n3),title('Normal using central limit theorem');</blockquote><blockquote><br />
</blockquote><blockquote>%% Save to eps files</blockquote><blockquote>figure(1),print('-deps','1.eps');</blockquote><blockquote>figure(2),print('-deps','2.eps');</blockquote><div><br />
</div></blockquote></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-820764667506700402011-04-28T18:41:00.000-07:002011-04-28T18:41:25.443-07:00Easiest & Fastest way to save Kinect depth and image data<div dir="ltr" style="text-align: left;" trbidi="on">After searching a lot to quickly get range and intensity data I thought of documenting the best way so that other people save their precious time! <div><br />
</div><div>I ended up using Mobile Robotics Programming Toolkit(MRPT). Please goto this page for installation instructions: <a href="http://www.mrpt.org/Kinect_and_MRPT">http://www.mrpt.org/Kinect_and_MRPT</a></div><div>I used the option of <b>"installation from the repositories"</b> instead of compiling from source. Its fast and easy this way.</div><div><br />
</div><div>Once that is done,</div><div>Download the code from here: <a href="https://docs.google.com/leaf?id=0B-mKP9AVXZV2YjJkNWZiZDMtOTUzNy00NTdiLTg3MWMtOGEwYTNkNWNkNzYw&hl=en">Code</a></div><div>Download the cmake file from here: <a href="https://docs.google.com/document/d/1m2KBuGTp144Wr3Fodjknm3wtT3Yn1M_Sa3awqp-qlRw/edit?hl=en">CMakeFile</a></div><div><br />
</div><div><b>Commands:</b></div><div>cmake .</div><div>make</div><div>sudo ./kinect_view</div></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-47297457838829618872011-03-05T05:18:00.000-08:002011-03-05T05:19:22.652-08:00Cannot find the library `/usr/lib/libgdk_pixbuf-2.0.la`<div dir="ltr" style="text-align: left;" trbidi="on"><div>I got this error while compiling Peekabot from source. If you get this error for the same reason or for any other reason: Installing pixbuf from source package is the workaround for now.</div><div><br />
</div><div><b>apt-get source libgdk-pixbuf2.0-0</b></div><div><b>cd gdk-pixbuf-2.22.0/</b></div><div><b>./configure --prefix=/usr</b></div><div><b>make</b></div><div><b>make install</b></div><div><br />
</div><div>If you install from the repos you get the shared library but not the static which peekabot seems to require!! </div><div><br />
</div><div>Good luck!</div></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-17924117729211999212011-02-11T02:08:00.000-08:002011-02-11T02:10:03.341-08:00Theory cheat sheet<div dir="ltr" style="text-align: left;" trbidi="on">For the theory course(CS6505- Computability, Algorithms, and Complexity) at Gatech I along with couple of my friends prepared a cheat sheet covering the topics of NFA, Turning Machines, Turing Reducibility, Data structures( Fibonacci Heaps ), Algorithms ( Dynamic programming, Divide and Conquer, Matching algorithms etc. I am sharing the .tex and pdf file in case its useful for someone. Please feel free to download and modify for your use.<br />
<br />
<a href="https://docs.google.com/leaf?id=0B-mKP9AVXZV2YjFiMGVmMmQtOTVjZC00OTc0LWI5ODQtOGE0NjFlZTcxYjM2&hl=en&authkey=CIPjk6wH">TEX</a> & <a href="https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B-mKP9AVXZV2Y2JjMjdhYzUtODdlMC00NTViLTgxYWEtNWI3ODUyZTE1Zjcx&hl=en&authkey=CMXV4JsO">PDF</a></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-90779263227580947712011-01-18T23:05:00.000-08:002011-01-27T14:57:10.673-08:00.glc to .avi conversion script<div dir="ltr" style="text-align: left;" trbidi="on"><b><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span></b><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;">Thanks to Jon Rogers for this script!</span><br />
<b><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span></b><br />
<b><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;">#!/bin/bash</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;">FILES="*.glc"</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;">for f in $FILES</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;">do</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"> echo "Processing $f file..."</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"> # take action on each file. $f store current file name</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"> glc-play $f -y 1 -o - | mencoder -demuxer y4m - -ovc lavc -lavcopts vcodec=mpeg4 -o ${f%.*}.avi</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><br />
</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"> # This previous line takes in the glc file at $f and changes the extension to .avi for saving it as mpeg4</span></b><br />
<b><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"></span></b><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"><b>done</b></span></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-6836148033006618672011-01-15T22:39:00.000-08:002011-01-15T22:40:17.092-08:00Combining two laser scans into one coordinate systemFor my current Boeing project I have to use two laser scanners to get 360 degree fov. I need to extract walls from the room and localize based on the walls. I decided to combine the laser scans from both lasers into one coordiante system and then extract walls. I wrote few matlab scripts to combine the scans and extract lines etc. After being satisfied with the results I moved to implement the same in C++ specifically in ROS. When I reimplemented I got very weird results when I combined both laser scans into one coordinate system.<br />
<br />
After debugging for almost a day and taking help from a friend I found the BUG! I wish it was a programming bug, sadly it was a mistake in my understanding. I tried to put as much as possible in the image below. Once we knew the problem the formulas were elementary math but realizing that we needed to do this took time. I partially blame my matlab implementation which was also wrong but the error was never noticeable in the plots! At the end of the day though, things are looking great and I am glad one bridge is crossed :-)<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_bh_wx9lZ3zU/TTKSYY-p-3I/AAAAAAAAEz8/vJDSiHXzqwk/s1600/photo+%25283%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://3.bp.blogspot.com/_bh_wx9lZ3zU/TTKSYY-p-3I/AAAAAAAAEz8/vJDSiHXzqwk/s400/photo+%25283%2529.JPG" width="297" /></a></div><br />
<br />
After implementing it, the program started crashing arbitrarily giving segmentation fault! And that lead us to another "double precision" issue!! The calculation involves taking inverse sin by using asin. asin gives a HUGE number for any input greater than 1. In case of asin(a/b) for a=b due to double precision problems the function returned a crappy number. So, I had to make a minor modification so that a is always less than b :-) A productive day involving lot of debugging and learning!Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-65925826723070153072010-12-25T01:03:00.000-08:002011-01-30T03:10:37.538-08:002010 year recap code!<div dir="ltr" style="text-align: left;" trbidi="on">I wanted to recollect all the memories of 2010 before I closed the laptop for the year! I was wondering how best to do and wrote the following code in 30 mins that generates an image of predefined size with thumbnails of all the pics that I transferred from my Iphone. This definitely is not a true representation of things for the year but its very close!! Below is an output of the sample run! (I need to refine the code to remove repetitions but I do not care, the purpose is served)<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_bh_wx9lZ3zU/TRWyT1z69aI/AAAAAAAAEy8/mB3E0NCa7Ns/s1600/out2_poor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://2.bp.blogspot.com/_bh_wx9lZ3zU/TRWyT1z69aI/AAAAAAAAEy8/mB3E0NCa7Ns/s320/out2_poor.jpg" width="320" /></a></div><br />
<br />
The code takes a text file that contains paths to all the images in a directory(absolute paths). You can generate this file using "dir /B *.JPG" on windows and "ls -1 *.jpg" in Linux. Pass this to the code as a command line argument and it should save "year.jpg" in the working directory which will be the image that contains the thumbnail. I am pretty sure some softwares do this but instead of wasting time to find out I thought I will keep myself busy for 30 mins! I love the final image .. I can so recollect that specific occasions I took the particular picture! :-) <b>The thumbnail captures many of my friends and the happy times I had with them..</b><br />
<b><br />
</b><br />
<br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><b>You can download the visual studio project from :: </b><a href="https://sites.google.com/site/balamanohar/createCollage.zip">https://sites.google.com/site/balamanohar/createCollage.zip</a><br />
<br />
<b><br />
</b></div></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-88723008723703353932010-12-24T02:13:00.000-08:002010-12-24T02:13:03.815-08:00Linear Algebra - MIT OCW contd..Lecture 7-<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijDblNO61iH6F1hSbSjRcR9xMI0xigFfyFjLsW6XZxklzhhT6UaFBbLHtlScCA5VYuCjsfoGFh5cNvsn7WPZI1oLCW74OXvBkpSGbgX4z9LcssOhyphenhyphenelmaABorAqKKDCu9n4dWYclJfNDL1/s1600/photo+%25281%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijDblNO61iH6F1hSbSjRcR9xMI0xigFfyFjLsW6XZxklzhhT6UaFBbLHtlScCA5VYuCjsfoGFh5cNvsn7WPZI1oLCW74OXvBkpSGbgX4z9LcssOhyphenhyphenelmaABorAqKKDCu9n4dWYclJfNDL1/s320/photo+%25281%2529.JPG" width="239" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;">Lecture 8-</div><div><br />
</div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_bh_wx9lZ3zU/TRRyH9GAMeI/AAAAAAAAEyY/I0Uj8f46NUw/s1600/photo+%25282%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/_bh_wx9lZ3zU/TRRyH9GAMeI/AAAAAAAAEyY/I0Uj8f46NUw/s320/photo+%25282%2529.JPG" width="239" /></a></div><div class="separator" style="clear: both; text-align: left;"><br />
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-50105345534790708512010-12-23T14:28:00.000-08:002010-12-23T14:31:48.204-08:00Linear Algebra - MIT OCW contd..Lecture5-<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_bh_wx9lZ3zU/TRPMvgcNaNI/AAAAAAAAEyM/qkXzLbB5whM/s1600/photo+%25281%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/_bh_wx9lZ3zU/TRPMvgcNaNI/AAAAAAAAEyM/qkXzLbB5whM/s320/photo+%25281%2529.JPG" width="239" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Lecture6-</div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_bh_wx9lZ3zU/TRPNylxs-_I/AAAAAAAAEyQ/6S4r45WbcAk/s1600/photo+%25282%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/_bh_wx9lZ3zU/TRPNylxs-_I/AAAAAAAAEyQ/6S4r45WbcAk/s320/photo+%25282%2529.JPG" width="239" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><br />
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0tag:blogger.com,1999:blog-8014727566107878506.post-15987428613853868442010-12-22T21:29:00.000-08:002010-12-22T21:31:49.117-08:00Linear Algebra - MIT OCWStarted revising Linear algebra from the online lectures available on ocw site from mit. For people who do not know this is the link: <a href="http://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/video-lectures/">http://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/video-lectures/</a><br />
<br />
Its very basic Lin Alg stuff but explained really well. I had a good start and finished 4 lectures and wrote down the gist of whatever I learnt in the best possible handwriting :-) I am pretty sure to lose the notes at some point of time so took some pictures and will be posting them on the blog. My hope is to recollect most of what I got out of the video lectures by glancing at these notes probably a few months or even years from now. My present goal is to finish the 34 lectures in a week. Will see if I can keep it going for the next 7 days.<br />
<br />
Lecture1 -<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_bh_wx9lZ3zU/TRLdqqNjyAI/AAAAAAAAEx4/6jPdqQDH794/s1600/photo+%25281%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/_bh_wx9lZ3zU/TRLdqqNjyAI/AAAAAAAAEx4/6jPdqQDH794/s320/photo+%25281%2529.JPG" width="239" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Lecture2 -</div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_bh_wx9lZ3zU/TRLdrFiG-vI/AAAAAAAAEx8/UhCxOTGbf20/s1600/photo+%25282%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/_bh_wx9lZ3zU/TRLdrFiG-vI/AAAAAAAAEx8/UhCxOTGbf20/s320/photo+%25282%2529.JPG" width="238" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Lecture3-</div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_bh_wx9lZ3zU/TRLdr_sWHbI/AAAAAAAAEyA/AAwttTpCzwk/s1600/photo+%25283%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/_bh_wx9lZ3zU/TRLdr_sWHbI/AAAAAAAAEyA/AAwttTpCzwk/s320/photo+%25283%2529.JPG" width="239" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Lecture4 -</div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_bh_wx9lZ3zU/TRLdskKqUrI/AAAAAAAAEyE/hiTIaDy-RQI/s1600/photo+%25284%2529.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/_bh_wx9lZ3zU/TRLdskKqUrI/AAAAAAAAEyE/hiTIaDy-RQI/s320/photo+%25284%2529.JPG" width="239" /></a></div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com1tag:blogger.com,1999:blog-8014727566107878506.post-37975104397818360452010-10-26T16:33:00.000-07:002010-11-16T20:32:56.729-08:00Horner scheme - Evaluating a polynomial in O(n) complexity#include <iostream><iostream></iostream></iostream><br />
using namespace std;<br />
<br />
double evaluate( double *coeffs, int n, double x )<br />
{<br />
double val = coeffs[n]*x;<br />
for( int i = n-1 ; i > 0 ; i-- )<br />
val = (val + coeffs[i])*x;<br />
val += coeffs[0];<br />
return val;<br />
}<br />
<br />
int main()<br />
{<br />
int n;<br />
cout << "Enter the degree::";<br />
cin >> n;<br />
double *coeffs = new double[n+1];<br />
for( int i = 0 ; i <= n ; i ++ )<br />
{<br />
cout << "Enter the coefficient of "<< i <<"th degree term::";<br />
cin >> coeffs[i];<br />
}<br />
<br />
double prev, x;<br />
cout << "Enter the value at which polynomial needs to be evaluated::";<br />
cin >> x;<br />
do<br />
{<br />
cout << evaluate( coeffs, n, x ) << endl;<br />
prev = x;<br />
cout << "Enter the value at which polynomial needs to be evaluated::";<br />
cin >> x;<br />
}while(prev!=x);<br />
<br />
delete [] coeffs;<br />
}<br />
<div><br />
</div>Anonymoushttp://www.blogger.com/profile/12555542384292146876noreply@blogger.com0