Archive for May 2010

Back for download: Tutorial on opening an Acer Travelmate 613

Written 2010-05-17 by Timo Dickscheid, tagged as computers, web

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

Written 2010-05-14 by Timo Dickscheid, tagged as 3d, programming

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.

Blender transform

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.

Blender lens

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

Written 2010-05-11 by Timo Dickscheid, tagged as programming

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. Vector3f for a 3-float-vector and Matrix2d for 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!