Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Is VDM .NET support native?..is it faster than VC++ ?

Hi all,
I would like to know if Vision Development Module' .NET support is native or does it use wrapper objects to COM technlogy?
If the same vision functions are used with VC++,  will they perform better than .NET ?

Thanks to all for your support!
0 Kudos
Message 1 of 6
(4,576 Views)
satriani81 -

The Vision Development Module's current .NET support is an interop layer around a COM object.  Due to the COM overhead, using the C or LabVIEW API should be somewhat faster, although I haven't done a direct comparison to see if it's a big difference or not.

Greg Stoll
Vision R&D
National Instruments
Greg Stoll
LabVIEW R&D
0 Kudos
Message 2 of 6
(4,573 Views)
I'm able to develop in VB .NET, not in C++, can you provide some samples to do a comparison?...for example a program that loops "n" times and counts elapsed time
I think it's a good thing to show users pros and cons of a programming language with your Vision Development Module.
What's the development road map of Vision Development Module?...do you think to improve performances with native .NET support?

Thaks for your care
0 Kudos
Message 3 of 6
(4,562 Views)
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 4 of 6
(4,540 Views)
satriani81 -

Are you sure you're timing the right thing?  I just did a quick example, convoluting the same 1280x1024 image with a 7x7 smoothing kernel in C and VB.NET, and in both cases the times were consistently in the 39-40ms range.  I definitely wouldn't expect .NET to take anywhere close to 6 times as long!

If you keep getting this result, attach your VB.NET project and code, as well as the image you used and I can take a look.  Calling directly into the C DLL from .NET is certainly possible but pretty painful, and I don't think it should be necessary in this case.

Greg Stoll
Vision R&D
National Instruments
Greg Stoll
LabVIEW R&D
0 Kudos
Message 5 of 6
(4,475 Views)
Hello Greg,
you'r right, I used the convolve method passing to it the optional parameter mask image....it was the cause of slowing.
Without a mask image, timings in .NET are quite the same of C, but I noted that in .NET the execution time is more variable: more frequently you call the convolute method and more constant is the execution time (ex if I call the convolute method once a second timings vary between 35ms and 90ms, if I put the convolute in a loop, timings are 35ms fixed)....why that?
Please, another question for you: if I want to use two threads to convolute images from two indipendent cameras, can I execute this method in parallel?.....is convolute method reentrant?


Thanks a lot for your care!
0 Kudos
Message 6 of 6
(4,466 Views)