Monthly Archives: August 2007

make a pinhole camera

最近一直在想如何做一个GLC camera,一直也都没有头绪。买了一些camera的adapter,filter,好像这些都用不上。甚至还想着把手边的那个镜头里的lens都给拆了来做2 crosslet。直到今天下午,在等着算stereo depth的时候,突然想起来去搜了一下如何做pinhole camera,这之间应该有些相似之处,果然,真的被我找到了,一个字-强


Error LNK2019: unresolved external symbol

最近写的程序一个solution里有两个projects,一个c++的project要调用c project,编译的时候一直出现link error,Error LNK2019: unresolved external symbol。查了好长时间才发现下面的解决方法,很不错。
Error LNK2019: unresolved external symbol int __cdecl CeMountDBVolEx, void * __cdecl CeOpenDatabaseInSession

You have created a C++ device project and using the EDB methods from “coredll.lib”. You have included the “windbase_edb.h” file in your projects source files. When you compile and link this you are getting following linker errors

error LNK2019: unresolved external symbol “int __cdecl CeMountDBVolEx(struct _CEGUID *,wchar_t *,struct _CEVOLUMEOPTIONS *,unsigned long)” (?CeMountDBVolEx@@YAHPAU_CEGUID@@PA_WPAU_CEVOLUMEOPTIONS@@K@Z) referenced in function “int __cdecl MountDbVol(void)” (?MountDbVol@@YAHXZ)

error LNK2019: unresolved external symbol “void * __cdecl CeOpenDatabaseInSession(void *,struct _CEGUID *,unsigned long *,wchar_t *,struct _SORTORDERSPECEX *,unsigned long,struct _CENOTIFYREQUEST *)” (?CeOpenDatabaseInSession@@YAPAXPAXPAU_CEGUID@@PAKPA_WPAU_SORTORDERSPECEX@@KPAU_CENOTIFYREQUEST@@@Z)

and you are wondering why this is happening?

The problem with your project is that you are using a “C” style exported library in your C++ projects. When the compiler generates mangled names for C++ functions, they are different from unmangled names generated by the C compiler and hence the C++ compiler will not be able to link with the methods imported from coredll.lib.

The solution to this problem is – while including the header windbase_edb.h, you can explicitly tell the compiler that all functions included from this header are “C” style functions by changing your inclusion as below.

extern “C”

With this the C++ compiler when includes the declarations from the windbase_edb.h file, it does not do any name mangling for the functions declared in this file, and thus you should be able to link to EDB without any problems now.

Gangadhar Heralgi
Published Sunday, November 20, 2005 8:17 PM by vsdteam

How to create .lib file when you only have .dll and .h files (ZZ)

By Zhang Shenggang.
An article on Microsoft .lib file and .dll file

The Problem
Have you encountered this situation: you have xxx.dll and xxx.h file, but you do not have xxx.lib, while you don’t want to use LoadLibrary(“xxx.dll”); you want to implicitly link xxx.lib, then you can call the functions in the xxx.dll smoothly. Also this article illustrates some concepts about .DEF file e.g. @ordinal[NONAME], entryname[=internalname], [DATA], [PRIVATE]. This article is devoted to these topics. I wish it can help you. Now let’s go.

DEF Files
Before we go, I will show something about .DEF. The syntax for an export definition is:
entryname[=internalname] [@ordinal[NONAME]] [DATA] [PRIVATE]
You can refer to my source code which illustrates how to use that in .DEF files.

What is [PRIVATE]?
privatefun PRIVATE

It means that: privatefun is only put into xxx.dll, but the symbol (stub) is not corresponding xxx.lib. So, when you implicitly link your exe with xxx.lib, if you call privatefun(); you will get LNK2001 : unresolved external symbol “symbol”

What is entryname[=internalname] ?
LIBcdeclfun = cdeclfun
It means that: LIBcdeclfun is an alias of cdeclfun, note that Visual Basic can’t accept ‘_’ (underscore), also, left name is more meaningful.

What is [DATA] ?
vcdata DATA
It means that: vcdata is data, not function. You can use __declspec(dllimport) to import it.

What is [@ordinal[NONAME]] ?
fun3 @333 NONAME
It means that: fun3 only exports with ordinal, not function name. But you can in another yyy.def exports it with the same ordinal, moreover, you can indicate a function name for this ordinal:
Minicfun3 @333
Note : You can use “\VC98\Bin\dumpbin.exe /exports xxx.lib” (or dll, obj, etc.) to see the export section in PE file.

How to do it?
There are 3 projects in INIT workspace, “Demo”, “MINIC”, “VCDLL_VB” respectively. “Demo.exe” depends on “MINIC.lib” and “VCDLL_VB.dll”.

;VCDLL_VB.def : Declares the module parameters for the DLL.
DESCRIPTION ‘VCDLL_VB Windows Dynamic Link Library’
fun3 @333 NONAME
vcdata DATA
privatefun PRIVATE

Other important stuff
If the dll export its functions by ordinal, still you can call it. Simply you set a new name for the ordinal
; VCDLL_VB.def
fun3 @333 NONAME

and a corresponding one as in; MINIC.def
Minicfun3 @333

In addition, you can export your function. The compiler and linker don’t complain, but the Operating System’s loader will complain. ; MINIC.def
Minic ;This function isn’t existing in original .dll
when you run Demo.exe, you will get an error dialog below, if you uncomment the lines as suggested in the source code.

As you known, MFCxxx.dll exports its functions by ordinal, which can save much space. There is an article in MSDN about Q131313 HOWTO: Create 32-bit Import Libraries Without .OBJs or Source. You can email me at

RGB value for ColorChecker

Recently I’m doing some coding about camera color calibration, using Adrian Ilie’s iccv colorcalibration algorithm. Here is the RGB value for the ColorChecker Color Rendition Chart for reference.

No. Number R G B
1 dark skin 115 82 68
2 light skin 194 150 130
3 blude sky 98 122 157
4 foliage 87 108 67
5 blue flower 133 128 177
6 bluish green 103 189 170
7 orange 214 126 44
8 purplish blue 80 91 166
9 moderate red 193 90 99
10 purple 94 60 108
11 yellow green 157 188 64
12 orange yellow 224 163 46
13 blue 56 61 150
14 green 70 148 73
15 red 175 54 60
16 yellow 231 199 31
17 magenta 187 86 149
18 cyan 8 133 161
19 white 243 243 242
20 neutral_8 200 200 200
21 neutral_6_5 160 160 160
22 neutral_5 122 122 121
23 neutral_3_5 85 85 85
24 black 52 52 52

An overview of range images

Helmut Cantzler

Intensity images are of limited use in terms of estimation of surfaces. Pixel values are related to surface geometry only indirectly. Range images encode the position of surface directly. Therefore, the shape can be computed reasonably easy. Range images are a special class of digital images. Each pixel of a range image expresses the distance between a known reference frame and a visible point in the scene. Therefore, a range image reproduces the 3D structure of a scene. Range images are also referred to as depth images, depth maps, xyz maps, surface profiles and 2.5D images.

Range images can be represented in two basic forms. One is a list of 3D coordinates in a given reference frame (cloud of points), for which no specific order is required. The other is a matrix of depth values of points along the directions of the x,y image axes, which makes spatial organisation explicit.

Range images are acquired with range sensors. In computer vision normally optical range sensors are used. We can distinguish between active and passive range sensors. Active range sensors project energy (e.g. light) on the scene and detect its position to measure or exploit the effect of controlled changes of some sensor parameters (e.g. focus). On the other hand passive range sensors rely only on intensity images to reconstruct depth.

Active range sensors exploit a variety of physical principles. The most common sensor techniques are triangulation, radar/sonar, moiré interferometry and active focusing/defocusing. Triangulation uses a light projector and an intensity camera, which is placed at a certain distance from the projector. The projector emits a light pattern. The most common patterns are planes and single beams. We shall use a projected plane for illustration. The intersection of the plane with the scene surface is a planar curve called the strip, which is observed by the camera. By using triangulation we get the depth map of the surface points under the strip. Radar/sonar uses a short electromagnetic or acoustic wave and detect the return (echo) reflected from surrounding surfaces. Distance is obtained as a function of the time taken by the wave to hit a surface and come back. Moiré sensors project two gratings with regularly spaced patterns onto the surface and measure the phase differences of the observed interference pattern. Other phase difference sensors measure the phase shift of the observed return beam. Distance is a function of the phase difference. Active focusing/defocusing sensors use two or more images of the same scene, which are acquired under varying focus settings. Once the best focused image is determined, a model linking focus values and distance yields the distance.