Monthly Archives: April 2007

Vision的project

vision的最后一个project做的是marc pollefyes的polar rectification. 做的时候比一开始想象的要稍微复杂一些,花了挺长时间的,但效果还是挺好的。

Advertisement

float与double的精度

发现float与double的精度是依赖于平台的,与具体的硬件有关。在laptop算一个float数是34.xx,在workstation上就只是0.02xxx,正确的值应该是0。看来转成double还是保险些,不过郁闷的是输入数据都是float型的。

float:         4字节         6-7位有效数字         -3.4E-38     到     3.4E38    
double:     8字节         15~16位有效数字     -1.7E-308   到     1.7E308

LEGO® MINDSTORMS® NXT

http://shop.lego.com/product/?p=8527&LangId=2057&ShipTo=US

以前见到过Lego这个名字,但没有在意过。今天神奇的发现别人做的vision的作业是在lego robot上做得。他们自己搭了个lego robot,然后在这个robot装载了两个web camera。然后自己写code,通过stereo image来计算depth map提供给这个robot做导航信息,效果还是很神奇的。这一个vision的project应该是融合了AI、Vision等学科,很有意思。所以说,老美也不只是会玩,玩也能玩出奇特的东西。

GNU Emacs Reference Card

http://www.physics.ucsb.edu/~pcs/apps/editors/emacs-quick-1.8.html

(for version 18)

STARTING EMACS
To enter Emacs, type emacs

LEAVING EMACS
suspend Emacs (the usual way of leaving it)          C-z
exit Emacs permanently                               C-x    C-c

FILES
read a file into Emacs                               C-x    C-f
save a file back to disk                             C-x    C-s
insert content of another file into this buffer      C-x    i
replace this file with the file you really want      C-x    C-v
write buffer to a specified file                     C-x    C-w
run Dired, the directory editor                      C-x    d

GETTING HELP
The Help system is simple. Type C-h and follow the directions. If
you are a first-time user, type C-h t for a tutorial.

get rid of Help Window                               C-x    1
scroll Help Windows                                  ESC    C-v
apropos: show commands matching a string             C-h    a
show the function a key runs                         C-h    c
describe a function                                  C-h    f
get mode-specific information                        C-h    m

ERROR RECOVERY
about partially typed or executing command           C-g
recover a file lost by a system crash          M-x recover-file
undo an unwanted change                              C-x  u or C-_
restore a buffer to its original contents      M-x revert-buffer
redraw garbaged screen                               C-l    

INCREMENTAL SEARCH
search forward                                       C-s
search backward                                      C-r
regular expression search                            C-M-s

Use C-s or C-r again to repeat the search in either direction

exit incremental search                              ESC
undo effect of last character                        DEL
abort current search                                 C-g

If Emacs is still searching, C-g will cancel the part of the search
not done, otherwise it aborts the entire search.


MOTION
Cursor Motion:
   entity to move over             backward       forward
   -------------------------------------------------------
   character                       C-b            C-f
   word                            M-b            M-f
   line                            C-p            C-n
   go to line beginning (or end)   C-a            C-e
   sentence                        M-a            M-e
   paragraph                       M-[            M-]
   page                            C-x [          C-x ]
   sexp                            C-M-b          C-M-f
   function                        C-M-a          C-M-e
   go to buffer beginning (or end) M-<            M->

Screen Motion:
   scroll to next screen           C-v
   scroll to previous screen       M-v
   scroll left                     C-x <
   scroll right                    C-x >

KILLING AND DELETING
   entity to kill                  backward       forward
   --------------------------------------------------------
   character (delete, not kill)    DEL            C-d
   word                            M-DEL          M-d
   line (to end of)                M-O C-k        C-k
   sentence                        C-x DEL        M-k
   sexp                            M-- C-M-k      C-M-k
   
   kill region                            C-w
   kill to next occurrence of character   M-z char
   yank back last thing killed            C-y
   replace last yank with previous kill   M-y

MARKING
set mark here                             C-@ ir C-SPC
exchange point and mark                   C-x C-x
set mark arg words away                   M-@
mark paragraph                            M-h
mark page                                 C-x C-p
mark sexp                                 C-M-@
mark function                             C-M-h
mark entire buffer                        C-x h

QUERY REPLACE
interactively replace a text string       M-%
using regular expressions                 M-x query-replace-regexp

Valid responses in query-replace mode are
replace this one, go on to next           SPC
replace this one, don't move              ,
skip to next without replacing            DEL
replace all remaining matches             !
back up to the previous match             ^
exit query-replace                        ESC
enter recursive edit (C-M-c to exit)      C-r

MULTIPLE WINDOWS
delete all other windows                  C-x 1
delete this window                        C-x 0
split window into 2 vertically            C-x 2
split window into 2 horizontally          C-x 5

scroll other window                       C-M-v
switch cursor to another window           C-x o

shrink window shorter                     M-x shrink-window
grow window taller                        C-x ^
shrink window narrower                    C-x {
grow window wider                         C-x }

select a buffer in other window           C-x 4 b
find file in other window                 C-x 4 f
compose mail in other window              C-x 4 m
run Dired in other window                 C-x 4 d
find tag in other window                  C-x 4 .

FORMATTING
indent current line (mode-dependant)      TAB
indent region (mode-dependant)            C-M-\
indent sexp (mode-dependant)              C-M-q
indent region rigidly arg columns         C-x TAB

insert newline after point                C-o
move rest of line vertically down         C-M-o
delete blank lines around point           C-x C-o
delete all whitespace around point        M-\
put exactly one space at point            M-SPC

fill paragraph                            M-q
fill region                               M-g
set fill column                           C-x f
set prefix each line starts with          C-x .

CASE CHANGE
uppercase word                            M-u
lowercase word                            M-l
capitalize word                           M-c

uppercase region                          C-x C-u
lowercase region                          C-x C-l
capitalize region                         M-x capitalize-region

THE MINIBUFFER
The following keys are defined in the Minibuffer.

complete as much as possible              TAB
complete up to one word                   SPC
complete and execute                      RET
show possible completions                 ?
abort command                             C-g

Type C-x ESC to edit and repeat the last command that used the
minibuffer. The following keys are then defined.

previous minibuffer command               M-p
next minibuffer command                   M-n

BUFFERS
select another buffer                     C-x b
list all buffers                          C-x C-b
kill a buffer                             C-x k

TRANSPOSING
transpose characters                      C-t
transpose words                           M-t
transpose lines                           C-x C-t
transpose sexps                           C-M-t

SPELLING CHECK
check spelling of current word            M-$
check spelling of all words in region     M-x spell-region
check spelling of entire buffer           M-x spell-buffer

TAGS
find tag                                  M-.
find next occurrence of tag               C-u M-.
specify a new tags file                   M-x visit-tags-table

regexp search on all files in tags table  M-x tags-search
query replace on all the files            M-x tags-query-replace
continue last tags search or query-replace   M-,

SHELLS
execute a shell command                   M-!
run a shell command on the region         M-|
filter region through a shell command     C-u M-|
start a shell in window *shell*           M-x shell

RMAIL
scroll forward                            SPC
scroll reverse                            DEL
beginning of message                      . (dot)
next non-deleted message                  n
previous non-deleted message              p
next message                              M-n
previous message                          M-p
delete message                            d
delete message and back-up                C-d
undelete message                          u
reply to message                          r
forward message to someone                f
send mail                                 m
get newly arrived mail                    g
quit Rmail                                q
output message to another Rmail file      o
output message in Unix-mail style         C-o
show summary of headers                   h

REGULAR EXPRESSIONS
The following have special meaning inside a regular expression.

any single character                      . (dot)
zero or more repeats                      *
one or more repeats                       +
zero or one repeat                        ?
any character in set                      [ ... ]
any character not in set                  [^ ...]
beginning of line                         ^
end of line                               $
quote a special character c               \c
alternative ("or")                        \|
grouping                                  \( ... \)
nth group                                 \n
beginning of buffer                       \`
end of buffer                             \'
word break                                \b
not beginning or end of word              \B
beginning of word                         \<
end of word                               \>
any word-syntax character                 \w
any non-word-syntax character             \W
character with syntax c                   \sc
character with syntax not c               \Sc

REGISTERS
copy region to register                   C-x x
insert register contents                  C-x g
save point in register                    C-x /
move point to saved location              C-x j

INFO
enter the Info documentation reader       C-h i

Moving within a mode:
   scroll forward                         SPC
   scroll reverse                         DEL
   beginning of node                      . (dot)

Moving between nodes:
   next node                              n
   previous node                          p
   move up                                u
   select menu item by name               m
   select nth menu item by number (1-5)   n
   follow cress reference (return with l) f
   return to last node you saw            l
   return to directory node               d
   go to any node by name                 g

Other:
   run Info tutorial                      h
   list Info commands                     ?
   quit Info                              q
   search nodes for regexp                s

KEYBOARD MACROS
start defining a keyboard macro           C-x (
end keyboard macro definition             C-x )
execute last-defined keyboard macro       C-x e
append to last keyboard macro             C-u C-x (
name last keyboard macro                  M-x name-last-kbd-macro
insert lisp definition in buffer          M-x insert-kbd-macro

COMMANDS DEALING WITH EMACS LISP
eval sexp before point                    C-x C-e
eval current defun                        C-M-x
eval region                               M-x eval-region
eval entire buffer                        M-x eval-current-buffer
read and eval minibuffer                  M-ESC
re-execute last minibuffer command        C-x ESC
read and eval Emacs Lisp file             M-x load-file
load from standard system directory       M-x load-library

SIMPLE CUSTOMIZATION
Here are some examples of binding global keys in Emacs Lisp. Note
that you cannot say "\M-#"; you must say "\e#".

(global-set-key "C-cg" 'goto-line)
(global-set-key "\e\C-r" 'isearch-backward-regexp)
(global-set-key "\e#" 'query-replace-regexp)

An example of setting a variable in Emacs Lisp:

(setq backup-by-copying-when-linked t)

WRITING COMMANDS
(defun  ()
   ""
   (interactive "")
   )

An example:

(defun this-line-to-top-of-screen (line)
   "Reposition line point is on to the top
of the screen. With ARG, put point online ARG. 
Negative counts from bottom."
   (interactive "P")
   (recenter (if (null line)
          0
          (prefix-numeric-value line))))

The argument to "interactive" is a string specifying how to get the
arguments when the function is called interactively. Type "C-h
interactive" for more information.



Copyright 1987 Free Software Products Inc
designed by Stephen Gildea, March 1987, v 1.9
for GNU Emacs version 1.8 on Unix Systems.

DDD

 程序编译过了就要调试了,没想到以前对linux的一点点了解都忘光了,运行gdb后只想到了r,b,l这几个命令和help,其他都忘了。更可恶的是,装了ddd后,只会用next,查看变量值的命令也忘了,太郁闷了。

以前用过的一个Makefile

# Training Projects
CC = icc  -xW -O3   #-march=i686 -mcpu=i686
#CPP = icc -ipo -xW -O3
CPP = g++ -w -O3 -march=pentium4
#CPP = icpc -O0 -xW
#CPP= icpc -xW -O3 -no-ipo
INC = -I/usr/include -I/usr/local/include -I/opt/intel/opencv/include/opencv  -I/opt/intel/ipp41/ia32_itanium/include
LIB = -I/usr/lib -I/usr/local/lib -L/opt/intel/opencv/lib  -L/opt/intel/ipp41/ia32_itanium/sharedlib
OPT = -lcxcore -lcvaux -lcv -lhighgui -lippcore -lipps -lippm -lippi -lstdc++ -lpthread
OBJ = extractfeatures.o learn.o main.o
BIN = train   # executables to create
all: $(BIN)      
$(BIN): $(OBJ)
        $(CPP) -o $(BIN) $(OBJ)  $(LIB) $(OPT)
main.o: main.cpp stdafx.h learn.h Makefile
        $(CPP) -c main.cpp -o main.o  $(INC)
learn.o: learn.cpp stdafx.h learn.h extractfeatures.h Makefile
        $(CPP) -c learn.cpp -o learn.o $(INC)
extractfeatures.o: extractfeatures.cpp stdafx.h learn.h wtfwd53.h extractfeatures.h Makefile
        $(CPP) -c extractfeatures.cpp -o extractfeatures.o  $(INC)
clean:
        rm *~ *.o $(BIN) core train

The std::list Container Class

Last updated May 7, 2003.

Linked lists are another widely-used data structure. Yet writing a linked list from scratch is an arduous, frustrating and time-consuming task. Instead of reinventing the wheel every time anew, use the STL std::list container class. Its uniform interface, generic nature and seamless integration with other STL constructs make it a superior choice to any homemade list class, as I will show in the following sections.

Creating a list object

The header <list> contains the declaration of std::list and its specialized algorithms. Our first step is to create an empty list of integers called li:

#include <list>
using std::list;
int main()
{
 list <int> li;
}

To insert a single element, use the push_back() member function:

li.push_back(1);

To remove the last element of a list, use the pop_back() member function

li.pop_back();

As opposed to push_back(), push_front() inserts an element before the list’s beginning:

li.push_front(0); // the first element is now 0, not 1

Similarly, pop_front() removes the first element of a list:

li.pop_front();

To remove a certain value from the list without indicating its exact position, use remove(). remove(n) removes all the elements that equal to n from the list:

li.remove(0); // li doesn't contain 
       //any zeros anymore
Dealing with Sequences

Up until now I have exemplified list operations that operate on a single element at a time. std::list supports sequence operations as well. These operations enable you to traverse, fill, sort and reverse multiple elements at once.

Iteration is easy. The begin() and end() member functions return iterators pointing at the list’s beginning and end, respectively. Use them to access all the list’s elements sequentially. Note that we’re using a const_iterator instead of an ordinary iterator object because the iteration process in this case doesn’t modify the list’s state:

list<int>::const_iterator it;
for(it=li.begin(); it!=li.end(); ++it)
{
 cout << *it << endl; // each element on a separate line
} 

The assign() member function fills a list with the contents of another sequence such as a vector or an array. It takes two input iterators (for further information on iterator categories, see the resources below) that mark the sequence’s beginning and end, respectively. In the following example, we fill a list with the elements of an array:

int arr[3] = {10,20,30};
li.assign( &arr[0], &arr[3]);

You can merge two lists into one. The merge() member function takes a reference to another list object:

list <int> x;
//..fill x
li.merge(x); // merge the elements of x into li

merge() merges x into li. x becomes empty after the merge operations. To erase one or more elements, use the erase() member function. This function has two overloaded versions; the first of which takes an iterator and erases the element to which it points. The second version takes two iterators that mark the beginning and the end of the sequence to be erased. Suppose you have a list of 10 elements and you want to remove all the elements but the first two. Use erase() as follows:

list<int>::it=li.begin();
++it; ++it; // advance to third element
li.erase(it, li.end()); // erase elements 3 – 10
Support for User-Defined Types

The generic nature of list enables you to define specializations, or instances, of user-defined types. For example, you may create lists of strings and Date objects like this:

#include <string>
#include "Date.h"
list<std::string> ls;
list <Date> ld;

Operations that require element comparison such as sort() and unique() use the overloaded < operator. If you intend to use any of these algorithms with lists, define a matching overloaded version of this operator for your class first:

bool operator < (const Date& d1, const Date& d2);
ld.sort(); // OK, using overloaded < operator

Note that in general, sorting a list is less efficient than sorting a vector or a queue. Therefore, if you need to sort elements frequently, you probably shouldn’t use a list in the first place. The same is true for reverse(), which is also supported:

ld.reverse();
for(it=ld.begin(); it!=ld.end(); ++it)
{
 cout << *it << endl; // descending order
}