Category Archives: Techniques

将文件打印成ps格式

对MS的应用程序来说,先安装MS Publisher Imagesetter virtual printer。
To install the MS Publisher Imagesetter virtual printer, open the `Printers` settings folder, and click `Add Printer`. Select a local printer; since it is virtual, select the FILE: port. Specify `Generic` as manufacturer, and then you can choose the MS Publisher Imagesetter.
Then change the file extension to *.ps

如果想将pdf转成ps格式,下载postscript printer。
PostScript printer drivers for Windows
http://www.adobe.com/support/downloads/product.jsp?product=44&platform=Windows
如果是adobe acrobat professional的话,可以直接save as成ps格式。

在smith hall打印的命令为
qpr -q smips *.ps

an inefficient 3D point viewer

Given a disparity map and a color image, want to view the 3D scene created by these 2 images:

clear;
% load images
Index=imread(‘disparity.bmp’);
C=double(imread(‘fly_1.jpg’))/255;

s = size(C);
m = s(1,1); % row
n = s(1,2); % columm

figure;
for x=1:1:m
for y=1:1:n
plot3(x, y, Index(x,y,1), ‘color’, [C(x,y,1), C(x,y,2), C(x,y,3)]), hold on;
end
end

执行的时候效率非常低,当还有1G free memory的时候就抱错说out of memory,估计是这种做法让Matlab觉得太恶心了。使用figure的3d旋转按钮多按了几次,结果连Matlab就直接退出了。
(用plot来画大量的点的时候效率就低,加上每个点都指定不同的color,估计就更不行了。)

tex4ht

The Translation Process
http://www.cse.ohio-state.edu/~gurari/TeX4ht/mn37.html

The system can be activated with a sequence of commands of the following form, typically embedded within a script.
latex x (or ‘tex x’)
latex x
latex x
tex4ht x
t4ht x
The three compilations with La(TeX) are needed to ensure proper links.

在使用tex4ht的时候,要导入tex4ht.sty and *.4ht style files。如果要显示数学公式,还要安装imagemagick供t4ht使用。产生页面效果很好。

make a pinhole camera

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

http://www.northlight-images.co.uk/article_pages/Canon_1ds_pinhole.html

Error LNK2019: unresolved external symbol

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

http://blogs.msdn.com/vsdteam/archive/2005/11/20/495123.aspx
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”
{
#include
}


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
http://www.codeproject.com/cpp/libfromdll.asp

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]?
;xxx.def
EXPORTS
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] ?
;xxx.def
EXPORTS
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] ?
;xxx.def
EXPORTS
vcdata DATA
It means that: vcdata is data, not function. You can use __declspec(dllimport) to import it.

What is [@ordinal[NONAME]] ?
;xxx.def
EXPORTS
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:
;xxx.def
EXPORTS
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.
LIBRARY “VCDLL_VB”
DESCRIPTION ‘VCDLL_VB Windows Dynamic Link Library’
EXPORTS
fun
fun2
fun3 @333 NONAME
LIBcdeclfun=cdeclfun
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
EXPORTS
fun3 @333 NONAME

and a corresponding one as in; MINIC.def
EXPORTS
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
EXPORTS
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.

Conclusion
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 bub_zhang@wistron.com.cn

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
http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/CANTZLER2/range.html

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.

windows xp 内存分配

这几天写程序,一直发现当程序分配较多的内存时会报错:
Unhandled exception at 0xxx in xx.exe: Microsoft C++ exception: std::bad_alloc @ 0x1198fc84,

查了一下原来XP只支持2GB的程序空间,程序想多用内存就没门了,只能用64位的xp了。
http://www.81ren.net/thread-6272-1-1.html

支持VLM(超大内存)   
在介绍VLM之前,我们回顾一下Windows NT 4.0内存管理的进化过程。因为Windows NT 4.0是标准的32位操作系统,32位指针能够访问的最大空间范围是2的32次方,也就是4GB。但用户的应用程序并不能使用所有的4GB空间,其中4GB的上半部分属于系统空间,操作系统的所有进程都运行在系统空间中。下半部分属于用户空间,但用户空间的最上层驻留的是系统的动态链接库(DLL),这样用户真正能够使用的空间就少于2GB。不过是这种把系统空间和用户空间分开的技术极大地增强了系统的可靠性。   

但2GB的应用程序空间对于大型企业应用来说,是远远不够的,于是微软在Windows NT Server 4.0中将用户空间调整为3GB,但是在这3GB空间中,系统动态链接库的位置并没有改变,这就是说用户的3GB空间并不是连续的,它被系统的动态链接库所隔断。   

随着计算机软硬件的飞速发展,许多大型数据库的容量达到了几百个GB,对内存的需求也大大地增加。为了更好地参与企业应用,Windows 2000对DEC Alpha平台提供了VLM支持。因为Alpha平台的所有指针和寄存器都是64位的,因此Windows 2000能够访问高达32GB的内存空间,其中最上部的2GB空间是系统空间,最下部的2GB空间是用户空间,中间的28GB也是用户空间,所有这些空间只有使用64位指针才能访问到,这就对Windows 2000的32位指针进行了64位的符号扩展。须要注意的是,中间的28GB内存空间是不可交换的,也就是说必须是物理上配置28GB内存,而不能利用硬盘上的页交换文件来进行模拟,此外VLM的I/O只能支持异步和非缓存I/O。对VLM的访问是通过VLMAPI来实现的,这些API是原有的虚拟内存管理API的扩展,但使用的指针和参数都是64位的。