移植opencv2.3.0到wince6

前期工作:
1、使用cmake2.8配置,去掉cuda、sse、sse2选项,修改/machine:X86为/machine:thumb,修改lib为coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib
2、如果安装有PB6导出的设备SDK需要将头文件和库文件路径优先VS2005自带的路径,否则会有STL编译错误
3、对于一些WINCE没有的CRT函数,使用WINCE的CRT包装库wceshunt(需要的地方引入wceshunt.h),对于没有的CRT头文件通过宏定义_WIN32_WCE来去掉引用

编译工作
1、zlib
(1)加入预编译项
NO_ERRNO_H
_WIN32_WCE=$(CEVER)
UNICODE
_UNICODE
UNDER_CE
(2)加入wceshunt.h头文件路径
(3)头文件引用修改
去掉zconf.h中types.h引用
去掉gzguts.h中fcntl.h、io.h引用

2、libjpeg
(1)加入预编译项
NO_GETENV
UNICODE
_UNICODE
WINCE
UNDER_CE
$(ARCHFAM)
$(_ARCHFAM_)
_WIN32_WCE=$(CEVER)
(2)找不到tmpfile,wceshunt中加一个空函数返回NULL

3、libpng
(1)加入预编译项
_WIN32_WCE=$(CEVER)
$(ARCHFAM)
$(_ARCHFAM_)
UNDER_CE
WINCE
UNICODE
_UNICODE
(2)去掉pngconf.h中types.h引用,加入wceshunt.h引用,头文件前面加#define WCESHUNT_STATICLIB

4、opencv_core
(1)加入预编译项
WINCE
_WIN32_WCE=$(CEVER)
$(ARCHFAM)
$(_ARCHFAM_)
UNICODE
_UNICODE
UNDER_CE
(2)加入wceshunt.h头文件路径
(3)去掉operaions.hpp对intrin.h的引用
另外,CV_XADD宏定义是MIPS的,加入ARM的定义
(4)xmmintrin.h中的宏定义__m128、emmintrin.h中的宏定义__m128i、__m128d要去掉_CRT_ALIGN(16),否则会编译出错 'A': formal parameter with __declspec(align('16')) won't be aligned,原因见http://community.psion.com/discussions/f/160/p/4087/16442.aspx,抄录如下
That header file is not a Psion generated file, but rather part of the standard Microsoft header offering (that file is also in STANDARDSDK as well).

With that said, the ARM compiler isn't going to allow you to align on anything less than 32 bit boundaries.  Looks like the file is x86-centric.

You could save a copy of that header, and then change that file directly to remove the 'align' directive (especially if you're planning on spending all your time on ARM).
(5)去掉system.cpp中对intrin.h的引用,tempfile在WINCE下无对应函数需要进行修改
(6)persistence.cpp找不到rewind,加入wceshunt.h引用,在头文件前头面加#define WCESHUNT_STATICLIB
(7)matrix.cpp对于std::max、std::abs存在二义性,这两个是模板函数需要指定参数类型
(8)internal.hpp中CV_SSE和CV_SSE2设为0,否则会有大量的链接错误(此文件中有关于NEON宏定义)
(9)链接提示找不到wce_rewind错误,建立和wceshunt.lib的依赖关系,设置链接参数“Link Library Dependencies”为“Yes”
(10)链接提示zlib找不到函数open、read、write、close,用另外一个库wceshunt,加放头文件wceshunt.h的路径。修改gzlib.c加入wceshunt.h引用,头文件前面加#define WCESHUNT_STATICLIB
(11)编译提示_strtoui64已经在msvcrt中定义了,修改wceshunt的_strtoui64为wce_strtoui64

5、opencv_imgproc
(1)加入预编译项
WINCE
_WIN32_WCE=$(CEVER)
$(ARCHFAM)
$(_ARCHFAM_)
UNICODE
_UNICODE
UNDER_CE

6、opencv_flann
(1)加入预编译项
WINCE
_WIN32_WCE=$(CEVER)
$(ARCHFAM)
$(_ARCHFAM_)
UNICODE
_UNICODE
UNDER_CE
(2)timer.h提示找不到clock函数,替换成GetTickCount

7、opencv_ml
(1)加入预编译项
WINCE
_WIN32_WCE=$(CEVER)
$(ARCHFAM)
$(_ARCHFAM_)
UNICODE
_UNICODE
UNDER_CE

8、opencv_highgui
(1)加入预编译项
WINCE
_WIN32_WCE=$(CEVER)
$(ARCHFAM)
$(_ARCHFAM_)
UNICODE
_UNICODE
UNDER_CE
(2)加入wceshunt.h头文件路径
(3)去掉comctl32.lib、gdi32.lib、vfw32.lib
(4)exclude所有cap相关文件,注释precomp.hpp中所有与cvcap相关内容,cvconfig.h中加入CV_NO_VIDEO_CAPTURE_CPP_API宏定义
(6)loadsave.cpp提示找不到remove,加入wceshunt.h引用,在头文件前头面加#define WCESHUNT_STATICLIB
(7)window_win32.cpp中多宽字符函数及找不到的WIN32函数,在wceshunt.h的前面加上WCESHUNT_STATICLIB、USE_WCEEXTS_H宏定义,还是没有的WIN32函数在wceexts.h中自行添加
另外,加宏定义#define GCL_HBRBACKGROUND   (-10)

9、opencv_features2d
10、opencv_calib3d
11、opencv_video
12、opencv_objdetect
13、opencv_contrib
14、opencv_legacy
15、opencv_gpu
(1)加入预编译项
WINCE
_WIN32_WCE=$(CEVER)
$(ARCHFAM)
$(_ARCHFAM_)
UNICODE
_UNICODE
UNDER_CE

16、opencv_haartraining_engine
opencv_haartraining
opencv_performance
opencv_traincascade
opencv_stitching
opencv_createsamples

17、install
修改cmake_install.cmake中的文件路径,删除错误拷贝的x86版本msvcm80等几个DLL及opencv_ffmpeg.dll

18、package
需要安装NSIS,生成opencv的安装文件

你可能感兴趣的:(移植opencv2.3.0到wince6)