Installing Cuda on Ubuntu 11.10
To install Cuda, I followed some hints on bottom of this thread, but also had to fix a few more issues.
Download the current Cuda Toolkit for Ubuntu and the GPU Computing SDK, and save the .run files somewhere.
Install and select gcc/g++ 4.4
sudo apt-get install \ gcc-4.4 g++-4.4 build-essential sudo update-alternatives \ --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 40 \ --slave /usr/bin/g++ g++ /usr/bin/g++-4.6 sudo update-alternatives \ --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 60 \ --slave /usr/bin/g++ g++ /usr/bin/g++-4.4Check with
sudo update-alternatives —config gcc gcc —versionthat you have now version 4.4.x of the compilers.
Install the nvidia drivers
sudo apt-get install \ nvidia-current\ nvidia-current-dev\ nvidia-current-updates\ nvidia-current-updates-devAs root, run the two .run files from nvidia (see 1.).
For compiling the SDK examples, you also need to install
sudo apt-get install freeglut3-dev libxi-devand create the following links
sudo ln -s /usr/lib/libXmu.so.6 /usr/lib/libXmu.so sudo ln -s /usr/lib/nvidia-173/libGL.so /usr/lib/libGL.soThen go to the
NVIDIA_GPU_COMPUTING_SDK_...folder. In the fileC/common/common.mkchange the lineLINKFLAGS +=to
LINKFLAGS += -L/usr/lib/nvidia-currentThen run make. This should compile everything, indicating that the CUDA stuff works.
Fixing grub errors after Ubuntu distribution upgrade
After running an Ubuntu distribution upgrade on a machine where the primary
boot disk is not /dev/sda, but let's say /dev/sdb, you may
experience the following grub error:
error: symbol not found: 'grub_env_export'
This happens because the grub-update is apparently run on the first disk by
default. You'll need to reinstall grub using the correct partition by booting from a live disk, as explained in this post. In the live system, fire up a terminal and (assuming your desired boot partition is on /dev/sdb1) do
sudo mount /dev/sdb1 /mnt/sdb1
sudo mount -o bind /dev /mnt/sdb1/dev
sudo mount -o bind /sys /mnt/sdb1/sys
sudo mount -o bind /proc /mnt/sdb1/proc
sudo chroot /mnt/sdb1
This will make the boot partition your current root directory tree. Then reinstall grub there:
grub-install /dev/sdb
update-grub
Reboot the machine, and hope for the best - it worked for me when upgrading from Maverick to Natty.
How did I live without vim's wildmenu all these years?
Even after years of extensive usage, vim will surprise
you eventually. Like today: I had a feeling that the way of switching buffers
that I use (:b abc<Tab>, where 'abc' is a fragment of a file's name) may not
be the most convenient one. I used the BufExplorer plugin for some months,
but found it too bloated.
Then I stumbled upon vim's builtin wildmenu function, which really knocked me
off of my feet! How was it possible that I didn't discover it earlier?
Simply put the following line in your .vimrc:
set wildmenu
Then open a bunch of files, and try
:b <Tab>
to get a horizontal list of buffer names that you can navigate and select interactively. The improved Tab completion works for all commands, e.g.
:e <Tab>
will open a minimalistic file explorer for the current directory. Wowee!
Don't use underscores in Java class names accessed through JNI
You can use the Java Native Interface (JNI) to call native code written in C++ directly from Java - and vice versa, which is less often used. When calling Java from C/C++, a virtual machine has to be launched before calling classes, using the so-called "Invocation Interface". A simple example can be found here.
It is important that you do not use underscores in the Java class names when implementing this scenario - JNI won't find your classes then, as happened to me using Sun's Java 6 JRE. Unnecessary to mention that it took Thomas and me about on hour to find the problem...
Forget about hardware KVM switches - use synergy
Do you often use a desktop computer and your notebook side-by-side? Do you hate switching the keyboard and mouse only for quickly replying to an email on the notebook, or for quickly checking a logfile on the desktop computer?
There is a free and easy solution to the problem on Linux and Mac: Use Synergy. It is a small and effective TCP/IP-based client-server application that lets you share keyboard and mouse of one machine with another one, with slide transition of the control via mouse movement just as with multiple screens in cinerama mode. This is much more handy than using a KVM-switch, as it doesn't require to switch off the screen of the other computer, and even allows for sharing the clipboard!
A short and good tutorial is available at a March 2009 article on LinuxMag.
Back for download: Tutorial on opening an Acer Travelmate 613
Due to growing requests, I just put an old D.I.Y. tutorial on opening an Acer Travelmate 613 back online. The tutorial can be found here. It is written in German, but has several photos in it.
Anyway, please note before following the tutorial: I opened such a device many years ago for disconnecting the internal battery, after the notebook suddenly had a bios password enabled. While it helped resetting the bios password, it didn't solve the problem ultimately: The TM 613 had a security chipcard reader which was also randomly enabled and naturally didn't respond to the empty factory cards I had. So I ended up sending the device to the Acer people, who fixed the problem fast and for free.
How to convert Blender camera settings into a projection matrix
I was looking for an easy way to derive a projection matrix corresponding to
the camera of images rendered with blender. Given
such a 3x4 projection matrix P, I want to define a 3D point in the blender
scene, multiply it with the matrix and paint it into the existing image. For
example, using Matlab to draw the scene origin as a red plus sign onto the
image, I want to write
imshow('blender_img.jpg');
hold on;
X = [0 0 0 1]';
x = P*X;
x = x(1:2)/x(3);
plot(x(1),x(2),'r+');
hold off;
Deriving P turns out to be not documented at all, and besides knowledge on the computer graphics pipelines requires some trial and error. Today I managed to solve the problem, so here's the solution.

First of all, collect the camera position and orientation from the "Transform Properties" dialog, as shown in the image above. In Matlab you get the translation vector and rotation matrix via
X0 = [2 -10 4]';
o = 70*pi/180;
p = 15*pi/180;
k = -10*pi/180;
Ro=[1 0 0; 0 cos(o) -sin(o); 0 sin(o) cos(o)];
Rp=[cos(p) 0 sin(p); 0 1 0; -sin(p) 0 cos(p)];
Rk=[cos(k) -sin(k) 0; sin(k) cos(k) 0; 0 0 1];
R = Rk*Rp*Ro;
Now we need to derive the calibration matrix. Unfortunately, the focal length
value in blender is neither documented nor standard. However, it is possible to
display the lens angle alpha in degrees, referring to the wider image
dimension, as shown in the image below. In the example we have alpha=49.13.

From the image resolution, which is here assumed to be 800x600, we get the
focal length in pixel from fl=-400/(49.13*pi/180/2). Observe the minus!
The final projection matrix P is obtained in Matlab using
fl = -400/tan(49.13*pi/180/2);
K = [fl 0 400; 0 fl 300; 0 0 1];
P = K*diag([1 -1 1])*R'*[eye(3) -X0];
Thanks to Daniel Berjon at Disney Research for pointing me to the tangens that
was missing in the above code snippet. Note the flipping of the y axis which
results in a left handed system. A
student is planning to write an export script for blender to write
P to file.
Eigen: A convenient and fast C++ template library for linear algebra
I just discovered eigen, a really nice template library for linear algebra. I was using newmat until now, but was not very satisfied with its API design, and was looking for a single efficient library for both small (3x3) and large matrices. That is were eigen comes in: It has a very intuitive and handy API and can handle both fixed and dynamic-sized matrices in a unified way. Some highlights are
- Direct mapping of STL vector and C array memory into eigen's classes
- Classes for transformations, including quaternions (!)
- Sparse matrix support
- Handy typedefs for common structures, i.e.
Vector3ffor a 3-float-vector andMatrix2dfor a 2x2-double matrix - Comma initialization aka
Vector3f X = Vector3f::Zero(); X << 1, 2, 3;
Eigen is a pure template library, meaning that you can include it in your project by copying the 1-2 MB of Header files into your source tree.
Really great work!
IJCV paper on completeness measure for feature detectors accepted
An extension of our 2009 BMVC paper has been accepted for publication in the International Journal of Computer Vision. Besides a more detailed evaluation on the completenss of combinations of local feature detectors, it covers the theory for a new sparse keypoint detector based on the maximum entropy principle. The print version of the paper will appear in summer 2010 on springerlink.com.
ICVS'09 proceedings published as google book
The Springer proceedings of the 7th International Conference on Computer Vision Systems held 2009 in Liege, Belgium are published in google books. My own contribution "Evaluating the Suitability of Feature Detectors for Automatic Image Orientation Systems" can be found here.