Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6704 Discussions

Can function IppiApplyhaarclassifier run in WDM driver?

mukarmxu
Beginner
377 Views

help!

IppiApplyhaarclassifier function run in application

I did face detection using IppiApplyhaarclassifier function in application programm and WDM driver,but I got defferent result: success in app programm (got the face), failed in driver. It was surprise to me. Why?

the result is followed:

in app programm:

0:positive : 1226
1:positive : 837
2:positive : 427
3:positive : 228
4:positive : 201
5:positive : 152
6:positive : 75
7:positive : 43
8:positive : 17
9:positive : 14
10:positive : 9
11:positive : 5
12:positive : 2
13:positive : 2
14:positive : 1
15:positive : 1
16:positive : 1
17:positive : 1
18:positive : 1
19:positive : 1

In driver:

0:positive : 1551
1:positive : 0

Source code is same completely. Who can help me!

0 Kudos
5 Replies
Intel_C_Intel
Employee
377 Views

I think the reason is that optimized ApplyHaarClassifier function is ippsMalloc_32f ans ippsMalloc_32scalls in it

The overall size if 6 * number of rectangles + 3 * number of classifiers

In driver it is possible to imitate alloc functions

We'll try to eliminate allocs

Thanks

Alexander

0 Kudos
Vladimir_Dudnik
Employee
377 Views

I do not think it is related to memory allocation, our IPP kernel mode driver example show how to write wrappers for malloc functions which required in some IPP functions internally.

It looks like

void* malloc(size_t size) { ExAllocatePool(...) }

So the reason of that difference is not quite clear.

Your source code might look identically but what about source data? Are they the same?

Could you please share example of your user mode code for us to check if you call function correctly?

You also may need to care about keeping FPU/SSE state in case of switching threads.

Regards,
Vladimir

0 Kudos
mukarmxu
Beginner
377 Views

Re:

I do not think it is related to memory allocation, our IPP kernel mode driver example show how to write wrappers for malloc functions which required in some IPP functions internally.

It looks like

void* malloc(size_t size) { ExAllocatePool(...) }

>> In driver code malloc function is followed:

PVOID AllocateMemory(ULONG ulSize)

{

PVOID pBuffer = ExAllocatePool(NonPagedPool, ulSize);

if(!pBuffer) DbgPrint("Allocate memory %d failed ", ulSize);

//DbgPrint("~~~~~~~~~~~~ Allocate buffer : 0x%08x Length : 0x%04x ", pBuffer, ulSize);

return pBuffer;

}

In app code malloc function is followed:

PVOID AllocateMemory(ULONG ulSize)

{

PVOID pData = malloc(ulSize);

if (!pData) printf("Alloc Memory %d is failed!", ulSize);

memset(pData, 0, ulSize);

return pData;

}

So the reason of that difference is not quite clear.

Your source code might look identically but what about source data? Are they the same?

>> Yes, I used the same image.

Could you please share example of your user mode code for us to check if you call function correctly?

>> (check Attachment)

You also may need to care about keeping FPU/SSE state in case of switching threads.

>> I did not use FPU/SSE state in kernel mode. But what should I attention to? Thanks.

Regards,

Vladimir

Thnaks Vladimir

0 Kudos
mukarmxu
Beginner
377 Views

Re:

I do not think it is related to memory allocation, our IPP kernel mode driver example show how to write wrappers for malloc functions which required in some IPP functions internally.

It looks like

void* malloc(size_t size) { ExAllocatePool(...) }

>> In driver code malloc function is followed:

PVOID AllocateMemory(ULONG ulSize)

{

PVOID pBuffer = ExAllocatePool(NonPagedPool, ulSize);

if(!pBuffer) DbgPrint("Allocate memory %d failed ", ulSize);

//DbgPrint("~~~~~~~~~~~~ Allocate buffer : 0x%08x Length : 0x%04x ", pBuffer, ulSize);

return pBuffer;

}

In app code malloc function is followed:

PVOID AllocateMemory(ULONG ulSize)

{

PVOID pData = malloc(ulSize);

if (!pData) printf("Alloc Memory %d is failed!", ulSize);

memset(pData, 0, ulSize);

return pData;

}

So the reason of that difference is not quite clear.

Your source code might look identically but what about source data? Are they the same?

>> Yes, I used the same image. < p="">

Could you please share example of your user mode code for us to check if you call function correctly?

>> (check Attachment)

You also may need to care about keeping FPU/SSE state in case of switching threads.

>> I did not use FPU/SSE state in kernel mode. But what should I attention to? Thanks.

Regards,

Vladimir

Thnaks Vladimir

0 Kudos
Alexander_T_Intel
377 Views

Hi.

I implement FD IPP functions and have some advices.

try to

1. use 32f code from ipp face detection sample. is it working correctly in driver?

2. use const int nnLength[22] instead of int nnLength[]

3. add some check of classifier load to AdjustHaarClassifier.

4. read haar classifier from haar.txt. not from arrays

5. add to code ippcvGetLibVersion().

Regards, Alexander

0 Kudos
Reply