Running OpenCV facedetect sample on Windows CE (Windows Mobile)
Posted on : 31-03-2009 | By : rhondasw | In : OpenCV
66
Here is a brief description of compiling and running OpenCV’s facedetect sample on Pocket PC.
Compiling
I used Visual Studio 2005 Team Suite edition to compile OpenCV 1.1 pre 1. It compiled without any trouble for Win32.
Then I tried to compile for Pocket PC (set Platform to Pocket PC 2003 (ARMV4)). Some compilation errors occured. As I only needed to compile a facedetect sample, I decided to compile the necessary files only.
To build cxcore I had to change the following:
cxmisc.h, line 125 to
#elif defined WIN32 || defined WIN64 || defined WINCE
cxswitcher.cpp, line 57 to
#if defined WIN32 || defined WIN64 || defined WINCE
line 90 to
#if defined WIN32 && !defined WIN64 && !defined WINCE
line 137, 140: constants wrapped in #ifdef
#ifndef WINCE
“HARDWARE\\DESCRIPTION\\SYSTEM\\CentralProcessor\\0\\”,
#else
L”HARDWARE\\DESCRIPTION\\SYSTEM\\CentralProcessor\\0\\”,
#endif
#ifndef WINCE
“~MHz”,
#else
L”~MHz”,
#endif
approx line 435, 600: added name translation
#ifdef WINCE
size_t origsize = strlen(name) + 1;
WCHAR wname[100];
MultiByteToWideChar(CP_ACP,0,name,origsize,wname,100);
addr = (uchar*)GetProcAddress( plugins[idx].handle, wname );
#else
addr = (uchar*)GetProcAddress( plugins[idx].handle, name );
#endif
cxerror.cpp line 45 to
#if defined WIN32 || defined WIN64 || defined WINCE
line 92 added
#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
line with DllMain to
#if defined WIN32 || defined WIN64
BOOL WINAPI DllMain(
#ifdef WINCE
HANDLE
#else
HINSTANCE
#endif
, DWORD fdwReason, LPVOID )
a fragment in cvGuiBoxReport to
sprintf( message, “%s (%s)\nin function %s, %s(%d)\n\n”
“Press \”Abort\” to terminate application.\n”
“Press \”Retry\” to debug (if the app is running under debugger).\n”
“Press \”Ignore\” to continue (this is not safe).\n”,
cvErrorStr(code), err_msg ? err_msg : “no description”,
func_name, file, line );
sprintf( title, “OpenCV GUI Error Handler” );
#ifdef WINCE
WCHAR wmsg[2048];
MultiByteToWideChar(CP_ACP,0,title,strlen(message),wmsg,2048);
int answer = MessageBox( NULL, wmsg, L”OpenCV GUI Error Handler”, MB_ICONERROR|MB_ABORTRETRYIGNORE);
#else
int answer = MessageBox( NULL, message, title, MB_ICONERROR|MB_ABORTRETRYIGNORE|MB_SYSTEMMODAL );
#endif
Changed preprocessor definitions to
NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_WINDOWS;_USRDLL;CV_CE_EXPORTS;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE
Subsystem to
WindowsCE (/SUBSYSTEM:WINDOWSCE)
Target machine to
MachineARM (/MACHINE:ARM)
Added dependency to
secchk.lib
After building cxcore, import library (.lib) was not generated for some reason. I was not able to resolve this, but as I only needed a running sample, i setup a new project and added all the necessary source from existing opencv projects to it. That is, cxcore, cv and some files from highgui.
I had to turn off precompiled headers (as the header file was different in cxcore and other projects).
There were linking errors in cvkdtree.obj, so i just removed cvkdtree.cpp from compilation as it was not needed for my sample.
cvconfig.h file was added to cv/include directory
..\..\otherlibs\highgui added to include paths
Only loadsave.cpp, utils.cpp and window_w32.cpp from highgui root were added to sample project. grfmts contents were also added.
As cvShowImage implementation was not added, i removed it from cxcore.h:
#ifndef WINCE
#define CV_SET_IMAGE_IO_FUNCTIONS() \
cvSetImageIOFunctions( cvLoadImage, cvLoadImageM, cvSaveImage, cvShowImage )
#else
#define CV_SET_IMAGE_IO_FUNCTIONS() \
cvSetImageIOFunctions( cvLoadImage, cvLoadImageM, cvSaveImage, NULL )
#endif
Running sample application
I changed a facedetect sample so that not to use gui. With these changes, facedtetect sample works fine both on emulator and Pocket PC.
I have to use .bmp files however as jpg files were not loaded properly.
Speaking about emulator, there is something wrong with the timing, the fragment
log_to_file(“Test app started”);
Sleep(1000);
log_to_file(“This should be logged approximately 1 second after start”);
generates log
000000.063ms: Test app started
000966.265ms: This should be logged approximately 1 second after start.
However, it looks as expected on the real device.
It turned out that release version built with floating point emulation takes approximately same time as the version built with emulation (/QRfpe). I tested this on emulator only.
Generally, simulator is very slow.
I used a 640×480 24bit sample with 4 faces. Here are the results
4 face(s) detected in 000702.286ms // my PC
4 face(s) detected in 329986.632ms // emulator and a build without fp emulation
4 face(s) detected in 334343.969ms // emulator and a build with fp emulation
4 face(s) detected in 066759.889ms// Fujitsu Siemens Pocket Loox PXA270 – 624Mhz and a build without fp emulation
hi thanks for this effort,
I also tried the steps you were given above, and try to build the cxcore. but i gets fatal error on winuser.h (the error is line no:9325: fatal error c1017: invalid integer constant expression). Can you please trigger me out, where is the problem…
Thanks in Advance,
Saran.
Hi Sarah,
I have not met the error you describe.
However, by using /showIncludes compiler option I can see that my project picks up winuser.h from the platform SDK path which in my case is C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\PocketPC2003\include\. I checked this file and found that it is 5003 lines only which is far less than line no 9325 you reported.
So I believe that incorrect winuser.h is picked up in your case. Please check that you have platform SDK installed (it came with vs team suite edition for me, but can be installed separately) and that you have the processor definitions described in the post in you project settings for pocket pc platform (NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_WINDOWS;_USRDLL;CV_CE_EXPORTS;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE;)
Hope that gives you a clue…
Thanks,
Dmitry
Hi Dmitry,
Thanks for your help, I used Visual Studio 2005 Professional Edition.And i tried to compile the cxcore build, changed the WINCE details on the src files and when i compiles, i get the following error,
“C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winuser.h(9325) : fatal error C1017: invalid integer constant expression”
and when i changes the include directories with “C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\PocketPC2003\Include” then i get other new error as below,
“C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\PocketPC2003\Include\stdlib.h(1040) : error C2065: ‘_JBLEN’ : undeclared identifier”
I just compile cxcore alone, not include the other libraries.
I changes the cxmisc.h, cxswitcher.cpp and cxerror.cpp files as above , and added the preprocessor directives, subsystem, target machines and dependency. but still i gets error…
Please help me, what should i wrong on that.
Thanks ,
-Saran.
Hi Saran,
I’m afraid i dont know the cure for your issue. I only can make a couple of notes:
1. In my case, i didnt have to add sdk include paths manually. Visual studio just took the correct path based on project settings and configuration (Debug / Pocket PC 2003 (ARMV4)).
2. Looking at the stdlib it looks like the error was caused my missing _M_ARM definition. Again, i did not have to add this definition manually, it was generated automatically somehow. So i believe something should be wrong with your project settings…
Anyway, here is my compilation command line just in case it may me helpful
/Od /Os /I “.” /I “..\include” /D “_DEBUG” /D “_WIN32_WCE=0x420” /D “UNDER_CE” /D “WIN32_PLATFORM_PSPC” /D “WINCE” /D “DEBUG” /D “_WINDOWS” /D “_USRDLL” /D “CVAPI_EXPORTS” /D “ARM” /D “_ARM_” /D “_UNICODE” /D “UNICODE” /D “_VC80_UPGRADE=0x0600” /D “_WINDLL” /Gm /EHsc /MDd /fp:fast /GR- /Yu”_cxcore.h” /Fp”Pocket PC 2003 (ARMV4)\Debug\cxcore.pch” /Fo”Pocket PC 2003 (ARMV4)\Debug\\” /Fd”Pocket PC 2003 (ARMV4)\Debug\\” /FR”Pocket PC 2003 (ARMV4)\Debug/” /W4 /nologo /c /Zi /TP /showIncludes
Regards,
Dmitry
Hi Dmitry,
Thanks, your reply really helps a lot to me, i found the problem, that is due to the platform, in configuration manager(Active solution platform) , i had only win32 platform, not having the PocketPC2003 platform. Please dont mistake me, how to add the platform for the cxcore project? (if i open smart device application i gets that pocketpc 2003 platform).
Hi Dmitry,
Thanks, your reply really helps a lot to me, i found the problem, that is due to the platform, in configuration manager(Active solution platform) , i had only win32 platform, not having the PocketPC2003 platform. Please dont mistake me, how to add the platform for the cxcore project? (if i open smart device application i gets that pocketpc 2003 platform).
Thanks,
-Saran
Hi Dmitry,
I made successfully compiled the cxcore library. I made mistake on the Platform. So create a new platform for PocketPC version and follow the steps of above. Finally gets compiled. Special Thanks to you Dmitry. Now i try to work with the client for that OpenCV DLL.
Thanks,
-Saran
Hi,
When i compile cxcore and cv those two compiled successfully. but when i use the highgui, it gives linker error.
image.obj : error LNK2019: unresolved external symbol cvShowImage referenced in function “public: virtual void __cdecl CvvImage::Show(char const *)” (?Show@CvvImage@@UAAXPBD@Z)
i exclude the cvCapture files from the highgui.
And doesnot include any library.
Any library to be include for this?
Thanks in advance,
– Saran
Hi Saran.
I have not tried to compile the highgui project entirely, as i was mostly interested in facedetect performance. So i just excluded most of the highgui from my test project and replaced the code related to showing windows etc with writing facedetect result to the file in openCV’s facedetect example.
As for the linker error you got, most probably it is related to the change described in the original post:
Only loadsave.cpp, utils.cpp and window_w32.cpp from highgui root were added to sample project. grfmts contents were also added.
As cvShowImage implementation was not added, i removed it from cxcore.h:
#ifndef WINCE
#define CV_SET_IMAGE_IO_FUNCTIONS() \
cvSetImageIOFunctions( cvLoadImage, cvLoadImageM, cvSaveImage, cvShowImage )
#else
#define CV_SET_IMAGE_IO_FUNCTIONS() \
cvSetImageIOFunctions( cvLoadImage, cvLoadImageM, cvSaveImage, NULL )
#endif
So i believe that reverting this and fixing whatever comes up you should be able to compile highgui eventully. In my case it was not needed, so i preferred to skip it.
However i would appreciate if you could share the results of your effort.
Thanks & best regards,
Dmitry
Saravan,
Were you able to find matching library to resolve the issue ? I m coming across a similar issue. Thanks is advance.
Viv
Hi,
I am doing a project about car detection recently.But now I get a problem.Can you send your opencv in wince to my email.thank you very much!My email is 18679163519@163.com
Hi Dmitry,
Okay, thanks for your guidelines, i also need to try for load and save the image . so i uses the selected files as u said, and made highgui compiled. and loaded the image using cvLoadImage, and its not null. but when i save that IplImage using cvSaveImage i gets garbages on that image content.
Thanks,
– Saran.
hi Dimitry
i made the changes that you have given, but i have a lot of errors, can you send me your project solution, when i compile CV solution i get the error
Error 1 fatal error C1083: Cannot open include file: ’emmintrin.h’: No such file or directory c:\program files\opencv\cxcore\include\cxtypes.h 68
what can i do ?
thanks
Rabie
Hi Rabie,
I have not meet the error you describe. In my case, emmintrin.h was not used during compilation. I believe this is a gcc file and i used visual studio.
I think you could check what could possibly lead to including of this header at line 68 of cxtypes.h looking at the conditions around this line:
#if defined WIN32 && (!defined WIN64 || defined EM64T) && \
(_MSC_VER >= 1400 || defined CV_ICC) \
|| (defined __SSE2__ && defined __GNUC__ && __GNUC__ >= 4)
#include
#define CV_SSE2 1
#else
Regards,
Dmitry
Hi.. I am also working on same thing..and facing same error right now.. Can you explain how you have solved it? I will be really very thankful to you.
Hi..
my question is to Rabie..
As when i m trying to build cxcore i m getting Error 1 fatal error C1083: Cannot open include file: ‘emmintrin.h’: No such file
Please help me..
Hi,
I’ve two questions about openCV and Windows CE.
1 – is possibile to compile openCV for Win CE and use a c# wrapper like
http://code.google.com/p/opencvdotnet/
for developing vision applications in Windows CE with C# .NET ?
2 – openCV has been created to allow hardware DSP acceleration ?
Thanks
Fausto
Hi Fausto,
Regarding question 1, i believe that the short answer is “yes”, it is possible. But personally i didnt try to compile even the existing highgui project entirely. When i tried to do it, i started to get compilations errors, related, for example to non-unicode strings used by opencv in gui api calls whereas wince gui expects unicode strings etc. As i was only interested in performance i compiled only load/save image part and mostly excluded gui. So if you need to compile opencv’s gui for wince that will probably require some additional work.
Regarding question 2, here is what the reference says:
OpenCV uses Intel® Integrated Performance Primitives (IPP) on lower-level, if
it can locate the IPP binaries on startup. Apart from this i’m no aware about other hardware acceleration means supported by opencv.
Regards,
Dmitry
Hi Saran,
I’ve also had problems with some kinds of images. Jpg didnt work for me either. Actually I used the first image format that worked (loading /saving produced the same image). That was .bmp.
Regards,
Dmitry
Hi Dmitry,
Thanks, Yeah as you said BMP image works perfectly (both GRAY and colour image), but failed for JPEG, i will try to use the JPEG format. Can you give some idea, why this format fails any idea regarding this?
Thanks,
-Saran.
Saran,
regarding jpg parsing failure, the issue was seen on other platforms as well (iPhone, ARM9-based single-board computer). You can see this issue mentioned in another post on this site: http://www.computer-vision-software.com/blog/2009/03/arm-wrestling-with-opencv. It was partially resolved after adding -fsigned switch to compiler. That is, after adding the switch it started to parse jpg headers correctly, but loading/saving the image still did not work. You can find this switch mentioned in http://opencv.willowgarage.com/wiki/InstallGuide in relation to the ARM processor. So i only can suppose that there is some problem with the jpg parser on ARM in openCV. It maybe some overflow as it was partially fixed by -fsigned switch. I dont know what would be the proper action to emulate the switch under visual studio.
Best regards
Dmitry
Hi Rabie,
I think you did a problem on including the header files. You should include the OpenCV headers before the standard windows header files. Then you don’t get this error.
Thanks,
-Saran.
Hi Saran
thank you very much, there is no error now, but i still get link errors like thise one:
Error 1 error LNK2019: unresolved external symbol cvReleaseCapture referenced in function main facedetect.obj
do you have any idea ?
thanks
Hi Rabie,
I did not use cvReleaseCapture() as i removed capture-related branch of execution from the original facedetect example. I just read the image from the hardcoded file path.
Regards,
Dmitry
Hi Dimitry;
please, tell me where can i find the file “cvconfig.h”?
thx
Hi Rabie,
I did not have this file as well. As far as i understand it should be autogenerated somehow, and is probably used for gcc compiler. I picked up the template for this file (it had a bunch of #undef directives for different options) and renamed it to cvconfig.h. As i did not use any of the options i just replaced it with an empty file with the same name then.
Regards,
Dmitry
Hi dimitry
how can u do to the error :
error LNK2019: unresolved external symbol cvHaarDetectObjects referenced in function _tmain facedetect.obj
thank you
Rabie
Rabie,
this function is defined in cvhaar.cpp. You should compile it in order to run facedetect.
Regards,
Dmitry
Hi Dimitry;
Sorry for all my questions. I couldn’t compile the project when i added files for image loading like loadsave.cpp, image.cpp. I get always link error. when i delete them i got this error, please do you have any idea ?
error LNK2019: unresolved external symbol WinMain referenced in function WinMainCRTStartup corelibc.lib
thank you
Hi Dimitry
Thank you very much for your help. It works now. but i have added almost all the files, because i don’t have any lib file.
thanks again.
Rabie
Hi Dimitry
I got the problem error LNK2019: unresolved external symbol cvQueryFrame referenced in function wmain.How can i solve it.Thank you very much.
Hi Dmitry,
i searched about that -f fsigned , they made that on the make file script as, -fsigned-char and when i read about the g++ used in linux, i found that usage , that is,
-fsigned-char
Let the type “char” be signed, like “signed char”.
So i think they were to says that we should use the signed char instead of normal char.
Src:
http://linux.die.net/man/1/g++
Thanks,
-Saran
Hi Saran,
I believe you are right. I’d only like to note that using -fsinged switch did not resolve the problem with jpg (under linux). So using signed chars instead of unsigned may not resolve it as well.
Regards,
Dmitry
Hi Dimitry
Everything works as well, but i can’t read image files!!!! i don’t know why ???
i tried with Jpg and bmp files, there no result for both of them.
thank you for help
Rabia
Hi Rabie,
So i assume that you can compile and run your application. Great. Regarding ‘i can’t read image files’ issue, could you provide some more details? Does cvLoad() fail? Please check how you specify the path to the file. Please note that WINCE does not support relative paths, so you need to specify the full path to the file from the root, similar to something like “\\facedetect_dir\\lena.bmp”. Also i think there is no use in trying .jpg files as obviously there is an opencv issue with this format (when compiled for arm processor).
Regards,
Dmitry
Hello,
I am recompiling cxcore and cv dll to be install on WinCE600 on a eBox4300 x86 hardware, get ‘sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA’ : undeclared identifier
thanks
Hi Francis,
I dont remember having such problem. However, looking at the sdk headers, it turns out that strsafe.h has
#ifndef STRSAFE_NO_DEPRECATE
// Deprecate all of the unsafe functions to generate compiletime errors. If you do not want
// this then you can #define STRSAFE_NO_DEPRECATE before including this file.
#ifdef DEPRECATE_SUPPORTED
…
#undef sprintf
#define sprintf sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA;
and windows.h has
// On CE force the functions to be linked instead of inline and
// turn off auto deprecate
#ifdef UNDER_CE
#define STRSAFE_LIB
#define STRSAFE_NO_DEPRECATE
#endif
#include
So i believe you need to make sure that you have UNDER_CE defined in the project properties like this post suggests. Also you might check that you correctly set target platform (Pocket PC 2003) to pickup the correct windows.h
Best regards,
Dmitry
Hi Dmitry
I am trying to integrate OpenCV with Visual Studio6 but on linking, following are the errors I receive:
Linking…
LINK : warning LNK4012: invalid value “IA64”, must be ALPHA, ARM, IX86, MIPS, MIPS16, MIPSR41XX, PPC, SH3, or SH4; option ignored
Creating library ../../lib/cxcored_i7.lib and object ../../lib/cxcored_i7.exp
cxerror.obj : error LNK2001: unresolved external symbol __imp__MessageBoxA@16
cxerror.obj : error LNK2001: unresolved external symbol __imp__wsprintfA
cxswitcher.obj : error LNK2001: unresolved external symbol __imp__RegCloseKey@4
cxswitcher.obj : error LNK2001: unresolved external symbol __imp__RegQueryValueExA@24
cxswitcher.obj : error LNK2001: unresolved external symbol __imp__RegOpenKeyExA@20
..\..\bin\cxcore100d_i7.dll : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.
highgui100d_i7.dll – 6 error(s), 3 warning(s)
I have tried renaming a copy of highgui.dll to highgui100d_i7.dll but that doesn’t help. Can you please help me with?
Hi Khanna.uk,
The original post was about compiling OpenCV for WindowsCE and ARM processor. From your comment it looks like you used IA64 linker option which, if i’m not mistaken, is for Itanium. If you were not intending to build for IA64 you could check and correct your linker/compiler options in the project properties. You could check target platform as well. The functions not found by your linker are not OpenCV functions and they are platform dependent.
Hope this helps.
Regards,
Dmitry
Thanks Dmitry,
Glad, somebody is out there to help!!!
I fixed above problems on similar solu, also imp I set in project properties->general->character set use Use Multi-Byte Character Set
Also UK this may help to solve your problems
I am working on rebuilding highGUI to output as static Lib to work on Windows CE60 with x86 processor
will update progress
Hi Dmitry,
I’ve been trying to compile a simple project for OpenCV to work on Pocket PC 2003 and I followed your instructions given. However, after including the “emmintrin.h” I was faced with the error below.
Error 2 error C2719: ‘_A’: formal parameter with __declspec(align(’16’)) won’t be aligned C:\Program Files\Microsoft Visual Studio 8\VC\include\xmmintrin.h 188
followed by a hundred over similar error messages. Is there a step that I am missing?
Thanks in advance!
Regards,
Gabriel
Hi Gabriel,
Unfortunately, i dont have currently my openCV setup for pocket pc at hand. I dont remember meeting the problem your describe. I’d like to check if those intrinsic header files are included in the compilation at all, but to do that i need to find time to setup that pocket project again. Until then i’m afraid i cant tell you anything useful. Sorry about that.
Regards,
Dmitry
Hi Dmitry Matveenko,
Thanks!
Can you send me project’s files to my email nospea_king@yahoo.com? I can’t build app using loadsave.cpp!
Best regards,
Hi Markov,
Dmitry is OOO right now. Unfortunately, we cannot share full version of our code, our management doesn’t allow to do it. If you would like to have full source code, you can contact our marketing team, see “about” page for details.
Aleksey
Hi Aleksey Kodubets,
Thanks for your reply! Can you tell me more detail about HIGHGUI? I compiled cxcore.dll, cv.dll, cvaux.dll successfully (using EVC++, ARMV4l), but too much error with highgui! I only need to load BMP or JPEG image into IplImage, dont need cvShowImage or cvSaveImage
I added loadsave.cpp, utils.cpp and window_w32.cpp from highgui and all grfmts relate files to project but fail! 1423 errors!
Thank you!
Dear Aleksey Kodubets,
I fixed above! But when release Emulator version i get errors:
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2823) : warning C4005: ‘CONTEXT_CONTROL’ : macro redefinition
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(1318) : see previous definition of ‘CONTEXT_CONTROL’
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2824) : warning C4005: ‘CONTEXT_INTEGER’ : macro redefinition
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(1319) : see previous definition of ‘CONTEXT_INTEGER’
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2825) : warning C4005: ‘CONTEXT_FLOATING_POINT’ : macro redefinition
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(1321) : see previous definition of ‘CONTEXT_FLOATING_POINT’
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2827) : warning C4005: ‘CONTEXT_FULL’ : macro redefinition
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(1326) : see previous definition of ‘CONTEXT_FULL’
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2836) : error C2011: ‘_CONTEXT’ : ‘struct’ type redefinition
Please tell me hot to fix that!
Thank you!
Best regards,
Hi Dmitry Matveenko and Aleksey Kodubets,
That isn’t big problem because i dont need run on Emulator, now i can run OpenCV on real device!
Thanks for your supports and sharing!
Best regards,
I can load “cxcore110d.dll”, but I can’t load “cv110d.dll” .I use windows mobile 6 sdk,what’s wrong?
Dmitry,
It was very helpful reading your blog. I am attempting to compile OpenCV on Windows CE using MS Visual Studio 2008. I am able to successfully build OpenCV on win32 platform using MS Visual Studio 2008. Basically, I downloaded OpenCV, used CMAKE to create “OpenCV.sln” and opened “OpenCV.sln” in MS Visual Studio 2008. I then rebuilt the solution in MS Visual Studio 2008 (win32 as default) and it did compile successfully.
How do I change the configuration/project settings in MS Visual Studio 2008 to now compile OpenCV on Windows CE ? MS Visual Studio 2008 is not the same as 2005 and I am not able to figure out what I need to do in order to compile/build OpenCV on Windows CE ?
I will appreciate your response.
Hi Vivin,
New configuration can be added via Visual Studio 2008 Configuration Manager (“Build” menu -> Configuration Manager). Select “” from “Active solution platform:” drop-down list and add required platform (for example “Windows Mobile 6 Professional SDK (ARMV4I)”).
Once new configuration is added, manually replace preprocessor definitions for each project to wince defaults, as by default they will be copied from win32 configuration.
Hello~
Thanks for your blog!
Can you tell me more detail about compile ? (i using VS2008, SDK6.0 )
I’m compliering your messge, but too much error!
I only need to load JPEG image into IplImage.
I don’t understand your post, from this part
Changed preprocessor definitions to NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_WINDOWS;_USRDLL;CV_CE_EXPORTS;$(ARCHFAM);$(_ARCHFAM_);_
……
would mind explain that means. Thank you.
Hi Park,
All information starting from preprocessor definitions is about project settings in visual studio. This is required because by default all settings are for win32 configuration.
libjpeg was not compiled for wince platform, so only bmp can be loaded via cvLoadImage. Instead standard wince com objects can be used to read jpeg data and pass it into cvCreateImage.
Here is code sample that reads jpeg from file, creates IplImage in rgb565 format and converts it to grayscale.
….
IImagingFactory *pImgFactory = NULL;
CHK( CoCreateInstance (CLSID_ImagingFactory, NULL,
CLSCTX_INPROC_SERVER,
IID_IImagingFactory,
(void **)&pImgFactory));
IplImage* rgb565_image = NULL;
IplImage* grayImage = NULL;
IImage *pImageJpeg = NULL;
IBitmapImage *pImageBitmap = NULL;
BitmapData newData;
ZeroMemory(&newData, sizeof(newData));
CHK(pImgFactory->CreateImageFromFile( L”\\My Documents\\barcode.jpg”, &pImageJpeg) );
ImageInfo* imageInfo = new ImageInfo();
CHK( pImageJpeg->GetImageInfo(imageInfo) );
CHK ( pImgFactory->CreateBitmapFromImage( pImageJpeg,
0,
0,
PixelFormat16bppRGB565,
InterpolationHintDefault,
&pImageBitmap) );
// Lock the bitmap’s bits.
RECT rect;
rect.top = 0;
rect.bottom = imageInfo->Width;
rect.left = 0;
rect.right = imageInfo->Height;
CHK (pImageBitmap->LockBits( &rect, ImageLockModeRead, PixelFormat16bppRGB565, &newData ));
// Create color image
rgb565_image = cvCreateImage( cvSize(newData.Width, newData.Height), IPL_DEPTH_8U, 2);
cvInitImageHeader( rgb565_image, cvSize(newData.Width, newData.Height), IPL_DEPTH_8U, 2, IPL_ORIGIN_BL, 4 );
cvSetData( rgb565_image, newData.Scan0, newData.Stride );
// Create gray image
grayImage = cvCreateImage(cvGetSize(rgb565_image),IPL_DEPTH_8U, 1 );
cvCvtColor(rgb565_image, grayImage, CV_BGR5652GRAY);
pImageBitmap->UnlockBits( &newData );
….
For a complete description of image manipulation under wince, I suggest the msdn articles about “IImagingFactory”, “IImage” and “IBitmapImage” classes.
Thanks for the author’s great work.
And i wonder if opencv2.0 can be transplanted to VM.
If somebody has done this job, please give me some suggestion, thanks a lot!
Hello ,
thx for that nice blog
My problem is : my software stops at “cascade = (CvHaarClassifierCascade*)cvLoad( “haarcascade_frontalface_alt2.xml”, 0, 0, 0 );” although i wrote the right path to the xml existing on the mobile emulator . What can be the problem ? waiting for your answers .
Thx again
John
Hi John,
Is there any extended error description available? What exactly “stops” means? Is there any exception?
The program begins working and at some point it crashes by showing me the message if i want to send the error to microsoft or not .
By putting breakpoints , i discovered that it crashes when loading the haarclassifier and i don’t know or how to solve the problem .
I suspect in two things :
1- May be the mobile application can’t support all the data and the floating points in the haarcascade so it crashes but when i tried to search a haarcascade for mobiles i didn’t find anything
2- I tried putting data manually in the haarcascade variable by writing
cascade-> count = 3 without loading any haarcascade and it crashes but when making cascade no pointer but a normal object and writing : cascade.count = 3
it accepted and completed debugging but i faced problems after that in the line of CVSeq* faces because it’s a pointer too and i don’t know how to fix it
I am not sure if it’s a pointer problem or haarcascade problem .
Waiting for your reply and sry for my weak english .
Yours, John
Dear Alex ,
Can you tell me please where i can find “cv200d.lib” , “cxcore200d.lib” , “highgui200d.lib” , “ml200d.lib” modified to be used on mobile with their dlls ?? (I want these files instead of “cv200.lib” , “cxcore200.lib” , “highgui200.lib” , “ml200.lib” that i work with now because I think that the first files will help me in detecting faces on windows mobile )
Waiting for your answer
Yours ,
John
Hi Markov,
Can you please share a compilation error (1423) message which you got?
I hope you did all steps as described in this article starting from: “..\..\otherlibs\highgui added to include paths…”
only need to load BMP or JPEG image into IplImage
Also, there is problem with JPG decoder in OpenCV under ARM. It doesn’t work. You can read Dmitry’s comments above regarding this.
Aleksey
Hi Aleksey Kodubets,
This is error message:
”
Linking…
corelibc.lib(pegwmain.obj) : error LNK2019: unresolved external symbol WinMain referenced in function WinMainCRTStartup
ARMV4IRel/firststuff.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
firststuff.exe – 2 error(s), 0 warning(s)
“
Dear Aleksey Kodubets,
I fixed above! But when release Emulator version i get errors:
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2823) : warning C4005: ‘CONTEXT_CONTROL’ : macro redefinition
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(1318) : see previous definition of ‘CONTEXT_CONTROL’
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2824) : warning C4005: ‘CONTEXT_INTEGER’ : macro redefinition
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(1319) : see previous definition of ‘CONTEXT_INTEGER’
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2825) : warning C4005: ‘CONTEXT_FLOATING_POINT’ : macro redefinition
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(1321) : see previous definition of ‘CONTEXT_FLOATING_POINT’
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2827) : warning C4005: ‘CONTEXT_FULL’ : macro redefinition
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(1326) : see previous definition of ‘CONTEXT_FULL’
C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2836) : error C2011: ‘_CONTEXT’ : ’struct’ type redefinition
Please tell me hot to fix that!
Thank you!
Best regards,
Hi Makrov,
I have called to Dmitry right now. He will be able to answer on your question this friday. Sorry, for delay. Unfortunately, I don’t have installed environment for Windows Mobile…
Aleksey
Hi Markov,
I did not meet the error you encountered which as far as i understand is
“C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\emulator\winnt.h(2836) : error C2011: ‘_CONTEXT’ : ’struct’ type redefinition”
I have a question however. You wrote:
Do you mean that you dont have this error when building a debug configuration? If so, I think that checking project settings may help. Just verify that project’s properties are the same for debug and release configurations, especially the settings mentioned in the post.
Best regards,
Dmitry
Dear Dmitry Matveenko and Aleksey Kodubets,
That isn’t big problem because i dont need run on Emulator, now i can run OpenCV on real device!
Thanks for your supports and sharing!
Best regards,
Hi Dmitry:
I’ve one questions about openCV and Windows CE.
I can run opencv in my wince system.but I do not run “cascade = (CvHaarClassifierCascade*)cvLoad( “haarcascade_frontalface_alt2.xml”, 0, 0, 0 );”.Can you tell me How do you run “cvLoad” to get “cascade”?
Hi Zlp,
Probably it’s incorrect filepath “haarcascade_frontalface_alt2.xml”, because all paths in winmobile are absolute. Probably you shall set path to somethong like “\\My documents\\haarcascade_frontalface_alt2.xml”
Read more about that here. http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/6e535905-6544-4c89-9b18-94d4b440d6c1
Hi Sergey Ignatov
Thanks for your blog!
I may compile and run in my wince system.Now I can detect face in my Actual equipment.
I found OPENCV detection is very fast,detection picture(200×200) abort 35ms.