Archive for the ‘OpenCV’ Category

In this article i will explain to how compile C++ library (OpenCV as an example), how to include the headers, linking the .lib files, and put the .dlls

You can read these two links to know the differences between Static Library ( and Dynamic Library (

This article assumes you have some knowledges in C/C++.  For short, compiling OpenCV and another C++ libraries is always similar and pretty easy after you know how. This tutorial will be in Visual Studio environment (2008 or 2010) .

1. The first step is to install CMake 2.8.x on your computer ( What is this CMake program? It simply prepares the C++ codes to be ready compiled from specified compiler (you know for windows, there are several compilers such as Cygwin, MinGW, Visual C++, etc.). This CMake is really useful to distribute C++ source code so it can be independent from other people’s Compiler and IDE.

2. Then download OpenCV library from sourceforge, the latest version is OpenCV 2.4.0 (

3. Since CUDA is getting popular and OpenCV also implements some of their libraries using CUDA, you can try to install CUDA.  But this is optional since not all computers have NVIDIA GPU. If you need to install CUDA, you can find it here (



I am planning to do 3D object reconstruction using stereo camera so first i need to do stereo calibration on my 3D camera.

The stereo camera i am using is Fujifilm w3 3D Camera. This camera produces MPO file image which is JPG in stereo format. For pre processing of course it is need to be converted into pair of images which can be read by OpenCV by using Stereo Photomarker (SPM) (

One thing you should notice when using this SPM when converting .MPO into pair of JPG images is to reset the automatic alignment (press “Home” to reset the alignment).  SPM automatically aligns the .MPO image so it can be viewed better when you use 3D glasses, but this alignment will crop the images. I don’t want this cropped images since resulted images won’t have the same size and it’s disaster.

The stereo calibration code can be read on here:

if it is success you can get xml calibration file similar to this:

<?xml version="1.0"?>
<Q type_id="opencv-matrix">
    1. 0. 0. -2.8327271270751953e+002 0. 1. 0. -1.5946473121643066e+002
    0. 0. 0. 1.0546290540664800e+003 0. 0. -2.3597727835463600e-001

At first i use chess pattern with 9×6 inner corners, 11 pairs of image, 1024×768 in size. And the result is really bad distortion, as you can see in corners of the image below

Then i figure out i need to use larger chess pattern and more pair of image. Then i use 15×8 inner corners, 26 pairs of image, and 1024×768 resolution. The rectified result looks better