LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

VIP: VERY IMPORTANT POST - Converting CWIMAQIMAGE to IMAGE*

Hi all,
I wrote a vision software in VB .NET using ni ActiveX controls, now, I need more speed in a convolution function so I wrote a C dll containing the imaqConvolve function that is faster than the counterpart in ActiveX control. I call this dll from vb .net and all is OK if I acquire the image from the dll directly in Image* format.
Problem now is that the original image is available in CWIMAQIMAGE format in .NET workspace and I have to convert it in Image* format to use it in the dll. The solution I found is not fast.....do you have some suggestions? Below or here my solution and proposal:

"
I spent the last two days in making some tests: I built a vb .net sw and a C console application, both performing the same task, a convolution of a 1280x1024 image with a 7x7 kernel.
I measured with a high resolution timer the time spent by cwimaqvision.convolute and imaqConvolve: 32ms in C and 180ms in VB .NET !!!
At this point I built a dll in unmanaged C++ inmplementing in it the imaqConvolve function: I call this dll with pInvoke from vb .NET and the performance is quite the same of C console application. For time consuming tasks I think that the dll way is good but there is a little problem that I hope National Instruments developers can help me to solve: actually I have to convert the CWIMAQIMAGE type in  IMAGE* type and then from IMAGE* to CWIMAQIMAGE.....to do that I used cwimaqimage.imagetoarray in vb.net and imaqArrayToImage in dll.....ARGGGGGGG....the array format is not compatible between .net activex and c !!!!! I noted that in .net the bidimensional array is saved in memory as a columns array, in C the array is created as a rows array...so is necessary to organize memory with a for cycle. Too much overhead.
Is it possible to have in C a imaqArrayToImage compatible function with .net array format ?
Do you have other suggestions ?


Thanks all

"
0 Kudos
Message 1 of 2
(3,157 Views)
Hi Satriani,
 
I think we can continue the discussion on the post you linked:
 
 
since the discussion purpose is similar.
 
Best regards,
 
Fabio
 
Fabio M.
NI
Principal Engineer
0 Kudos
Message 2 of 2
(3,113 Views)