Nov 20, 2010

Ubuntu notes

Install GVIM: sudo apt-get install gnome-vim
Install boost: sudo apt-get install libboost*

Link a boost library: g++ -lboost_filesystem
Location of boost header: /usr/include
Location of boost lib: /usr/lib

Modify "autoexec.bat": sudo vim /etc/profile
Modify environment variable: export RCSSBASEDIR=/home/username/rcss

Remove resource limitation: ulimit -s unlimited

Aug 5, 2010

Draw confusion matrix in Matlab

Generate confusion matrix in Matlab:
data = rand(10, 10)
imagesc(data)
colormap(gray)
colorbar

Result:

Jun 25, 2010

My neocomplcache setting

As requested, here is my .vimrc setting for neocomplcache.
Beware that the following setting works only for "ver.5" branch.
You have to check it out from github.

"------------------------------neocomplcache---------------------------------------

" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1

let g:neocomplcache_auto_completion_start_length = 3
let g:neocomplcache_manual_completion_start_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'

" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
    let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

" snippets expand key
imap  <silent><expr><TAB>  neocomplcache#plugin#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : (pumvisible() ? "\<C-e>" : "\<TAB>")
"imap  <silent><expr><TAB>  neocomplcache#plugin#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : "\<C-e>"
smap  <TAB>  <RIGHT><Plug>(neocomplcache_snippets_jump)
inoremap <expr><C-e>     neocomplcache#complete_common_string()

Jun 17, 2010

SuperTab complete for neocomplcache

As I said in my previous post, neocomplcache is a very powerful vim plugin.
It incoporates the funtionality of SnipMate and  AutoComplPop while providing efficient search
for potential completion items.

However, SuperTab does not support neocomplcache. It is very bad since I like to tab complete
everything, including snippets. Here is the solution -- put the following in you .vimrc:

imap  <silent><expr><tab>  neocomplcache#sources#snippets_complete#expandable() ? "\<plug>(neocomplcache_snippets_expand)" : (pumvisible() ? "\<c-e>" : "\<tab>")
smap  <tab>  <right><plug>(neocomplcache_snippets_jump) 
inoremap <expr><c-e>     neocomplcache#complete_common_string()

The above setting allows you to trigger a snippet with "tab" key when possible. If not, it will simply trigger omni completion. I set it to complete the longest common string. It is just a personal taste. You can set it to other type of completion as well.

*Update 2010/12/11 for necomplcache V5.2 compatiblity
*Update 2012/04/24 for necomplcache V7 compatiblity

May 20, 2010

Access Windows XP files from Windows 7

I spent 4 hours today to figure out how to enable the file sharing of Windows XP.
The key difficulty is that there are too many possible reasons to make the file sharing stop working.
Microsoft should make it easier for such a common task.

Basically, all you need is to follow the instruction from
http://www.crn.com/white-box/59200376


1. To enable the network Guest account on XP Home and Pro, click Start, click Run, type: net user guest /active:yes, and hit Enter.
2. Ensure there is no password for the Guest account: click Start, click Run, type: control userpasswords2, and hit Enter. Click once on Guest, click Reset Password, and then click OK without entering a new password.
3. Be aware that Windows XP, when installed on an NTFS disk partition and using simple file sharing, blocks network access to the Program Files and Windows directories as well as users folders within the Documents and Settings directory. This behavior is by design.
4. There are two registry keys to check on XP that have the potential to cause network headaches. The first is: HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control/Lsa
5. Ensure that restrictanonymous is set to 0. Ignore the restrictanonymoussam entry that looks similar and may also appear.
6. Older versions of Norton Anti-Virus set a value for IRPStacksize in the registry that is too low for XP. In fact, XP doesn't even need this registry key. If you have it in your registry, thank Symantec (NSDQ:SYMC) and then delete it. If you determine that the XP registry has this unneeded entry, check this registry location:
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Lanmanserver/Parameters. You can read more about this issue from Symantec and Microsoft.


Basically, all you need is to follow the instruction from
But it is not enough. You also need to turn "simple file sharing" on.

from http://support.microsoft.com/?scid=kb;en-us;304040&x=5&y=10
To turn Simple File Sharing on or off in Windows XP Professional, follow these steps:

  1. Double-click My Computer on the desktop.
  2. On the Tools menu, click Folder Options.
  3. Click the View tab, and then select the Use Simple File Sharing (Recommended)check box to turn on Simple File Sharing. (Clear this check box to turn off this feature.)

Mar 14, 2010

Why does nobody understand my work?


Mar 7, 2010

Academic vs Real world

The Ideas I got

token ring vs ethernet
z buffer
setero

anymore?

Try to prioritize your work based on what people's need.
In academic world, researchers admire the feature-rich methods.
For example: Token Ring vs Ethernet. (todo)

It's clear that Token ring is the winner. However, in reality, it's Ethernet whichs dominates
the world. The researchers seem to forget what they have learned in software engineering.
Some features are nice-to-have, while some others are must-have. In the token ring example,
bandwidth reserve is a nice-to-have, but easy-to-implement is a must have, since it direclty reflects the production cost of a hardware.

Don't forget that we don't research just for research. The purpose of research is to satisfy people's needs. Try to prioritize your objective, or your work will end up nothing but a pile of papers in the archive of a library.

next:胰島素vs tracking(survey on human) Enough is enough( what innovation's dilemma tells us)


Mar 6, 2010

Open current folder from command line

 Put the following into ex.bat and place it in C:\windows
and then you can type "ex ." to open the current folder from command line.

@echo off
start explorer %1
echo on 

open files in new tabs of GVIM from command line

Name the following file gvim.bat
and put it into C:\Windows

@echo off
start gvim.exe -p --remote-tab-silent "%1"
echo on

Mar 5, 2010

Token Ring VS Ethernet

Which method is more elegant?
Which method solves the problem?
Which method contributes more to the world?

to be continue...

Mar 2, 2010

UBC is an old school

 As a graduate student with a few years working experience, I felt like I am the oldest student in UBC. After staying here for two months, I gradually found that many students in UBC show extraordinary maturity, which is impossible for early-twenty young people to have. In the beginning, there are two first-year students told me they were software engineers before. Later, I found that many first year graduate students have almost  the same age as myself. Today, I was shocked by the fact that the three "young" girls in my class are  all above 27, and one of them is even above 30.  Why are there so many old students in UBC? They don't have to work!?

 

Machine Learning Summary

A grand tool box for vision people

chap 2
Linear Regression with Maximum likelihood estimation
Normal distribution
Student T distribution : SGD(Stochastic Gradient Descent), EM(with Gaussian Scale Mixture)
Lapalce distribution: Linear Programming, EM(with Gaussian Scale Mixture), or Huber Loss function

Censor regression (Kevin: not a big deal, since it only move the line a slightly up, why there are hundreds paper on it?)

chap 3
Logistic Regression
Objective: convex
Parameter Estimation: no close form solution
1. Newton method(IRLS)
2. minfunc in Matlab

always get optimal solution

Multidim Regression: no big deal
Probit Regression: convex objective, use Gradient Descent(minfunc) or EM(slow) to fit it.

chap 4
Model Selection
1. Baysian Approach: P(D|M). Average the all possible theta to protect from overfitting. (need concrete example)
2. BIC approximation. dof(M) can be estimated by minimum encoding of the model( information theory). Good if there are many models and there are some ways to get dof(m) from anther model dof(m')
3. cross validation: not suitable when there are many candidate models, takes too much time

L2 regularization:
QR
SVD
Gradient

L1 regularization(Lasso):
Problem: Laplace is not differentiable at origin
Sol: soft threshold to the point near origin
problem of sol: not a unbiased estimator anymore
sol of above: reestimate the nonzero w with Least Square( a unbiased estimator)

Linear Programming(not editor of choice)
LARS
SCAD( not editor of choice): just a adhoc approach. cannot be put into baysian framework
NEG: best but slow

chap5
Neural networks
Non-convex
Cascade linear and non-linear model( it has to be, or the different layer will collapse and become single linear layer)
Use gradient descent to do estimation( back propagation algorithm)


chap 12
Generative model
PI->Yi->Xi

Discriminant Analysis
p(x,y) pic here

Discriminative method(logistic regression)
p(x|y) pic here

chap 13
Feature selection:
Forward Feature Selection:
Greedy put one feature in( editor of choice, simple and better than stochastic approach like genetic algorithm, simulated annealing, ...)

More prior:
Normal Gamma: more spiky at origin, and flatter tail than Laplace

chap 14
Mixture Model
PI->Zi->Xi
Different from chap 12, since Zi is hidden(need to be inferred from EM), but Yi is given.


Feb 17, 2010

Hacking SuperTab.vim

I have been unhappy about the longest common text of auto-complete provided by VIM for a long long time.
I try to find a good solution on the Internet, but all I got is
Put
completeopt += menuone,longest
in your .vimrc
It does provide a longest common text of auto-complete FOR THE FIRST TIME. After I type one more character and press <tab>, it just starts to move on the popup menu. No more longest common text of all matches anymore.
To work around this, I hacked the SuperTab to provide longest common text.
Here is how:

  1. open supertab.vim in your /plugin directory
  2. find function! s:SuperTab(command)
  3. change the code
    " handle 'context' completion.
    if b:complType == 'context'
      let complType = s:ContextCompletion()
      if complType == ''
        exec "let complType = \"" .
          \ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
      endif
        return complType . key
    endif

to
    " handle 'context' completion.
    if b:complType == 'context'
      let complType = s:ContextCompletion()
      if complType == ''
        exec "let complType = \"" .
          \ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
      endif
         if pumvisible()
             return "\<ESC>a" . complType . key
         else
            return complType . key
        endif

    endif

The idea is simple. Just close the popup menu each time users press <tab>, since VIM will do longest common text before the popup menu appears.

Feb 16, 2010

Change Firefox Default Search Engine

1. Type about:config in Firefox address bar
2. Search for keyword.URL
3. Change the URL to any search engine you want
like the following
data:text/plain,keyword.URL=http://www.google.com/search?hl=zh-TW&source=hp&q=

Feb 15, 2010

The plugin list of VIM

It's time to organize my VIM plugins

My VIM Plugin Lists

  1. SnipMate – provide TextMate like snippet. Use neocomplcache instead
  2. SuperTab – use tab to complete words or sentence  Use neocomplcache instead    Can be configured to use tab key to trigger the snippet and word complete at the same time. Very cool~~~
  3. FuzzyFinder – find files and functions in an instant 
  4. L9 – required for new version of FuzzyFinder
  5. EnhancedCommentify– comment and uncomment a piece of codes with single keystroke
  6. DoxygenToolkit – generate function comment
  7. a.vim – switch between .cpp and .h files
  8. visual_studio.vim – compile VS files in VIM Not compatible with VS2010, 
  9. omnicppcomplete – complete c++ files Use neocomplcache instead
  10. surround.vim – make hello_world to "hello_world" with few key strokes
  11. repeat.vim – make "surround" operation repeatable(with ".")
  12. vim-latex – latex syntax support
  13. matlab_run.vim – run matlab script in vim
  14. matlab plugin for vim – provide syntax highlighting and indention of matlab
  15. tlib – provides utilities for viki Use AsciiDoc instead
  16. viki – support viki ( a kind of wiki language ) Use AsciiDoc instead
  17. neocomplcache – it has been actively developed during recent months. It's mature enough.   It's interesting to see the author reply every blog which has questions about this plugin. It seems that the author really cares about his work.
  18. neocomplcache-snippets-complete – since neocomplcache V7, the snippets have been separated from neocomplcache. You need to download it individually. 
  19. delimitMate – parenthesis completion, very handy
  20. cscope_map – provide keyboard mapping for cscope

Required Software:

  1. Deplate – convert viki to html
  2. Python 2.4.4 – required by Visual_Studio.vim
  3. Ruby 1.86 – required by Deplate
  4. ctags – required for omni-complete 
  5. cscope 15.7 – a better ctags for python. The zip file contains windows binary.
  6. Python for Windows Extension – required by Visual_Studio.vim

Abandoned plugins:

  1. taglist – use FuzzyFinder instead
  2. project – use FuzzyFinder instead
  3. RltvNmbr – too slow included in VIM 7.3
  4. snippetsEmu – too old, use SnipMate instead
  5. neocomplcache – too new. It is a combination of omnicppcomplete, SnipMate, AutoComplPop and SuperTab. It doesn't not work properly if you set the same trigger key to complete and snippet. However, it supports nested snippet and longest common string complete. Very promising.

Plugins needs modified:

  1. visual_studio.vim
    1. needs to update error message format for visual studio 2008 to work (I set it to set errorformat= %#%f(%l) : %#%t%[A-z]%# %m )
    2. needs to change key binding to avoid conflicts with viki.vim ( I changed them from vc to ic)
  2. SnipMate.vim
    1. needs to update snippets (of course) 
*Update 2010/12/11 for Vim 7.3
*Update 2011/03/10 for delimitMate  
*Update 2011/07/11 for cscope 
*Update 2012/04/24 for neocomplcache 

Add VIM to the right-click menu

The default VIM 7.2 right-click menu will open the new file in the current buffer.
It's quite annoying because I want to open the new file in a new tab most of the time.

To solve the problem, just import the following setting to the windows registery


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Edit with &Vim\command]
@="\"c:\\Program Files\\Vim\\vim72\\gvim.exe\" -p --remote-tab-silent \"%1\""

Feb 12, 2010

SkyMall -- the pleasure of Delta Airline

One of the enjoyful part when I took Delta airline is to browse the skymall shopping magazine.
Theere are always some crazy stuff there.

Like R2D2

And Programmable Gaming Robot

Its pets' solutions

Want to shut your dog up?
Get this

Bark Free Dog Barking Controls

Feb 7, 2010

Recent Fun

I recently spent some time playing an old RPG game I got from 2005

Lost Labyrinth!!! 
 
It always gives me a lot of fun to play it.
It is a simple game, but hard enough to be beaten by computers all the time.

Feb 3, 2010

Good research demands good data

"Good research demands good data" is what Dr. Su told me when I was a research assistant in Academia Sinica. In the beginning , I thought his word was sarcastic to the computer vision research, since many computer vision papers only work on the data set provided by the authors. Therefore, to be a good research assistant, I tried to make my result work on every video. Then I gave up. I realized that computer vision has its own limitation. Some techniques demand high quality video to make them work.

Recently, on David Lowe's course, he explained how to reduce specular reflection which serious affects the result of stereo matching. He said that there are some papers which propose novel algorithms to detect and reduce the specular reflection effect in images, but the most effective way is to add polarizing filter to your camera. The polarizing filter can reduce specular reflection effect to 0. Instead of producing good vision algorithms, we can put our efforts on obtaining good data. Why not?

Feb 1, 2010

Computer Vision: State Of the Art

1. Key point detector
SIFT
ASIFT
SURF

David Lowe reported that SURF is more rebust than SIFT in affine transformation, but SIFT is more robust to 3D rotation.

2. Background subtraction
No state of the art. Though I prefer Mixture of Gaussian personally.

See this
http://www.andrewsenior.com/technical/surveillanceclass/02_MovingObjectDetection_part1.pdf

3. Salient motion detection

see this
http://www.andrewsenior.com/technical/surveillanceclass/03_AdvancedMovingObjectDetection.PDF

4. Stereo

see this
http://vision.middlebury.edu/stereo/eval/

5. Robust estimation

RANSAC -Good if there are many inliers. If not, it needs lost iterations to find a good match
Hough Transform -Use this when RANSAC runs too slow
semi-local constraints -Check the consistency with nearby keypoints

The difference of RANSAC and Hough Transform lies in computation time. Try both to see which one runs faster.

Todo: expand the list, provide all implementations
Reminder: don't spend too much time on paper crawling, do some real stuff

6. Source of training data
ImageNet: A Stanford project to label image by volunteers
http://www.image-net.org/
 Caltech 256
http://www.vision.caltech.edu/Image_Datasets/Caltech256/

Surveillance data: (have ground truth??)
http://pets2006.net/
http://www.elec.qmul.ac.uk/staffinfo/andrea/avss2007_d.html
http://www.nada.kth.se/~hedvig/data.html
http://scienceandresearch.homeoffice.gov.uk/hosdb/cctv-imaging-technology/i-lids/pricing.html

7. Human Attention
A lab of USC doing this. By Prof. Laurent Itti and Prof. Christof Koch
http://ilab.usc.edu/bu/

Jan 28, 2010

VIM useful commands

gw exchange two words
CTRL-X CTRL-L complete line
CTRL-X CTRL-F complete file
CTRL-X CTRL-P complete word, useful when you use snippet and still want to have omni-complete
tab complete word
\s substitude the current word
\S substitude with question
ALT-O open file with the same name
\F find in all files
\g find file
\f find tag
,r run matlab script
,o open matlab
:make check matlab syntax

\ll compile latex
\lv view latex

 
TEMPLATE HACKS AND TWEAKS BY [ METAMUSE ] BLACKCAT 1.1
/scripts/shBrushJScript.js'/>