Tuesday, August 9, 2011

Recover the default nvidia driver

Just do:
$ sudo apt-get install nvidia-current
That's it.

Sunday, July 31, 2011

High quality video from images by FFMPEG

Gary Steele described how to use ffmpeg to make a video from images by the command:
ffmpeg -r 10 -b 1800 -i %03d.jpg test1800.mp4
(see: http://electron.mit.edu/~gsteele/ffmpeg/)

This command only can output a very low quality video. To make the video better, you can try following command:
ffmpeg -f image2 -i %03d.jpg -r 10 -s w*h test1800.mp4
where w and h are the width and hight of the video image, such as 640*480.

Tuesday, July 12, 2011

The vim-latexsuit in Ubuntu 11

I failed to install it by apt-get. The version of the vim-latexsuit might be very old in the package source of Ubuntu.
I decide to install the latest version from the vim-latex website. Finally successful following their manual.

Tuesday, June 14, 2011

Run April Toolkit ( including April tags) in C/C++ environment (call java classes from C/C++)

This is one example application: run April Toolkit (April tags) in C/C++. It requires the JNI to call Java functions in C/C++. You could download the source file from HERE.

The original April toolkit is working in the Java environment. However, my project needs C/C++, so how to wrap Java into C/C++ project becomes one problem.
After a few days work, I finally get a solution to solve this.

There are two subfolders in this application :
1, One is "java" folder. It includes Java source file "myTagTest.java", which is a simpler version of "TagTest.java" in the AprilToolkit. This program reads the frames from webcam, detect the april tags and calculate the relative pose matrix. That's all, so it's simpler and easier to understand than the original one.
2. The other one is "cpp" folder. It includes the C source file "ctest.cpp" and a "Makefile". The main architecture of the ctest.cpp is first launching the JVM, then finding the java class and java function, finally running the function.

How to run it (for Linux):
1. Download and install the April toolkits from:
http://april.eecs.umich.edu/wiki/index.php/April_Tags

2. Download the source file of my application from my website:
https://sites.google.com/site/guoliangliu2010/opensouce

3. In the java folder:
$ javac mytagTest.java

4. In the cpp folder:
$ make ctest
$ ./ctest

P.S.
I need thanks the engineer Ahmad Jalil Qarshi. He gives a nice introduction about how to call Java classes in C/C++, which can be found in the following link:
http://www.codeproject.com/KB/cpp/CJniJava.aspx

Friday, June 10, 2011

Remove ^M in the VIM or GVIM

The ^M is the \r in the file. To remove these strange things, you could do replace \r by space. Very simple.

Wednesday, June 8, 2011

JavaCV for webcam

Now I start to conquer Java for robotic stuffs.
I am used to use opencv, so I find Javacv is a nice interface to wrap opencv.
After download and install the javacv, I try to run a sample: "MotionDetector.java".
But it gives me some errors like:
HIGHGUI ERROR V4L2

The solution is commenting following lines in the OpenCVFrameGrabber.java:
cvSetCaptureProperty(capture, CV_CAP_PROP_CONVERT_RGB, colorMode == ColorMode.BGR ? 1 : 0);
and
return_image.timestamp(Math.round(cvGetCaptureProperty(capture, CV_CAP_PROP_POS_MSEC)*1000));

Now it works, but it return BGR image instead the RGB image.
I don't think it's a good idea to use CV_CAP_PROP_CONVERT_RGB in the above line, because the Opencv users are used to use BGR. If they don't check the source, they will never know the function "grab()" return a RGB image.

Now recompile it using command "ant" and copy the generated ./dist/javacv.jar to the CLASSPATH.

Tuesday, June 7, 2011

Type D in the vncviewer

I got a problem when I was using vncviewer: couldn't type d in the terminal or other windows.
The solution is:
1. Go to System->Preference->Keyboard shortcuts
2. Find the item Hide all normal windows and set focus to the desktop
3. Type Alt+D to change this hot key
4. vncserver -kill :1 which kills the current server
5. restart the vncviewer.

Problem Solved