Thursday, September 24, 2009

print more numbers for "cout"

Normally for double data, the precision is quite high. But when you want to show some data like "123456789.12345", it just show you "1.2356e+09". From that, we see it just show you the data with 5 precision. In fact, it does not lose any data. This is for easy to see. If you want to show more, you can do:

#include

double a=123456789.12345;
int n=14;
cout << setprecision(n) << a << endl;


This time it shows you "123456789.12345".

Monday, August 10, 2009

Be careful to use cvGetSubRect, cvGetRow and cvGetCol

When you uses these three function or similar function which have cvGetXX part, you must be careful. It return the pointer to return matrix, if you change the value of return matrix, the mother of this submatrix will be changed too. For example:

float a[]={1,2,3,4};
CvMat A=cvMat(2,2,CV_32FC1);
CvMat* B=cvCreateMat(1,2,CV_32FC1);

cvGetRow(&A,B,0);

Of course, here B->data={1,2};
But if we do:

CV_MAT_ELEM(B,float,0,0)=100;

Then you can check the first element of matrix A or array a become 100!!

So Now we understand, these function return the pointer. It gives the first pointer of first row of A to B. But we already give a new space to B, this part of space is not used anymore because the pointer of B is not pointer to "CvMat* B=cvCreateMat(1,2,CV_32FC1);" anymore. We also can not release the B afterwards as it pointer the content of A.
So these three functions are for operation on mother matrix, but not for get content of A.

So the correct way to get a row from A is:
float a[]={1,2,3,4};
CvMat A=cvMat(2,2,CV_32FC1);
CvMat* B=cvCreateMat(1,2,CV_32FC1);

CvMat tmp;

cvGetRow(&A,tmp,0);
cvCopy(&tmp,B);

cvReleaseMat(&B);


Here we go.

Friday, August 7, 2009

How to use ffmpeg extract freams from video file

ffmpeg is a power tool.
Here is a method.

ffmpeg -i input.avi -r 10 -f image2 images%05d.png

Here input.avi is input video file.
10 is fps.
image2 is image format.
%05d means that it has five numbers behind images. eg.images99999.png

How to use svn to see difference between two version

The method is :

svn diff -r2:19

2 and 19 are version number. But first need update your working copy before you do it.

Tuesday, July 21, 2009

Input Chinese in Ubuntu(输入中文)

I follow the guidance of website "http://ubuntuforums.org/showthread.php?p=124214".
1. Install libraries:
* scim
* scim-chinese
* scim-config-socket
* scim-frontend-socket
* scim-gtk2-immodule
* scim-server-socket
* scim-tables-zh (option)
* xfonts-intl-chinese
* xfonts-intl-chinese-big
* ttf-arphic-gbsn00lp
* ttf-arphic-gkai00mp
* ttf-arphic-bkai00mp
* ttf-arphic-bsmi00lp


2, Open a terminal,
$gvim .xsession

Type
"
scim -d
export XMODIFIERS=@im=scim
export GTK_IM_MODULE=scim
gnome-session
"

Then save .xsession under your home direcotry.

$chomd +x .xsession



Restart X server by CTRL+ALT+BACKSPACE

Activate the chinese input by CTRL+SPACE.

Finally I got it. Very cool, just feel a little strange.

现在可以用中文咯。。。。。嘻嘻。。。




This method is dead in June, 2010.



But I find a solution:
$sudo apt-get install scim-qtimm im-switch scim-pinyin
$im-switch -z en_US -s scim

It works again......你看到了吧。。。死掉的SCIM又活回来了。。

Thursday, July 16, 2009

Take your work seriously

As,,,,
1. You are living on it.
2. Your boss pay for your work.
3. The only way to get successful feeling.


Don't let noise to let your work down.

Make clear to work and to life.

Friday, June 26, 2009

EKF or UKF?

For non linear system, the most important way to solve it is make it linear. The well known method is using Taylor formula. EKF is using Taylor formula to linear state equation and measure equation. And assuming the noise obey Gaussian.

But Taylor linear method is not the only way, the other way is using uncented transform to linearize the state equation and/or measure equation. It also assumes Gaussian noise.