Tuesday, August 16, 2011

How 3D works?

Now a days every consumer electronic company talks about 3D, the highest grossing movies going forward will be 3D movies, these all are indications of where the technology is headed, and what direction the electronic industry is going. 


Our ability to feel the world around us in three dimensions is based on the fact that we have two eyes, and they are placed next to each other. This distance causes the images captured by the eyes to have a little shift relative to each other e.g. if you are looking at a pole that is in front of a second pole, the right eye will see the 1st pole a little-more to the right than the left eye. With 3D movies and photos, the photographer uses two cameras that are placed adjacent to each other, similar to how our eyes are. The end product is actually two films .... one for the right eye, and one for the left.


The hard part is replaying back these images or movies. The idea is to deliver the left picture or film to the left eye, and the right to the right eye. The most popular way, initially, was to use the funny red-blue glasses. This technique is based on coloring the left and right images and then imposing both on top of each other. Then, the glasses use the color filter to filter-out for each eye the image destined for the other. This way, the brain gets a shifted-image from each eye, and it analyses and builds and thus  gives us the feeling of 3D.


Another method, based on polarizer glasses. This technique is based on the fact that light can have a polarity. Normal light is a mix of waves that are both horizontal and vertical, as well as other angels, but using a special filter, one can block the waves. This is called a polarizer filter, and when you look at things through it, only light at a very specific angle comes through.

With 3D movies, this filter is applied at two angles to the two films, and then superimpose them on top of each other. This still looks fuzzy to the naked eye, but, we put special glasses with matching filters on our face. The light for the left image comes at some angle and the light for the right eye comes at another angle. Both angles arrive at both eyes, but the filter on the left eye only lets the light at the 1st angle through, while the right filter lets only light at the 2nd angle through. The result is similar i.e. each eye sees only the image that is meant for it. The filters are gray, so there’s no color distortion, thus this is better than funky red-blue glasses.


A 3rd technique, involves synchronized active glasses. This technique is based on the fact that the image on the TV is refreshed at a high rate. A movie is a series of images that are played in a series  rapidly, giving the illusion of movement (like a flip-book). With 3D, the image sequence is alternating – one image for the left eye, and then one for the right, and back to left. The viewer wears electronic glasses that are designed to block the lens in sync with the TV. During the showing of the left image, the right eye is blocked, and vice versa. This is fast enough so that most people don’t feel the blanking at all, although some people have an adverse reaction to this in the form of headaches or dizziness. Another disadvantage is that the active glasses are bulky and expensive.

The 4th technique is based on putting a special lens on the TV screen itself, which splits the screen into many vertical bars. Same as the 3D images we can often find in printed advertisements. Each of the two images is split into thin strips, and the lens shows the “left” stripes to the left eye, and the vice-versa. The result is sweet, because no glasses are needed, but the problem is that the field-of-view is limited. Move a little to the right or left, and the illusion breaks, and might even cause dizziness from the bending of the light.








Tuesday, August 9, 2011

Editor for mercurial

Last evening one of  my co-worker was sitting beside me, as I was pushing in some changes into the  project repository. And as I hit the "hg commit" command my "gvim" editor popes up for writing the commit message, and this buddy of mine sitting besides me asks me how did do you do that, howcome your gvim pops up whereas on my computer the same command opens a vi editor in the same terminal. I was like its easy,  I set the editor up in the Mercurial config file the famous ".hgrc" file.
Then he goes no, thats not the case because I have copied over your ".hgrc" file long back and if it was that file, then it would have been happening for me as well. I was like hmm let me see what I did. Then I realized that I have the UBUNTU environment variable EDITOR set for me to "/usr/bin/gvim  -f" ......that explains everything.


For making proper sense out of what I mean by above incidence, read the following explanation :

Mercurial tries to pick which program to call to edit a commit message by trying the following (in order):
  1. HGEDITOR environment variable
  2. editor configuration option in [ui] section (in hgrc or passed with --config ui.editor command-line option).
  3. VISUAL environment variable
  4. EDITOR environment variable
  5. vi, if none of the above is set

    So the above explanation suggests that I was actually using option 4 above, but I thought I was using option 2 while I explained to the co-worker 
    and on the hind side now its clear that my co-worker was using was option 5.