Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

C# prototype of IMAQ/imgSnap?

NI-IMAQ ref. man. describes the snap function prototype as:
    rval = imgSnap(SESSION_ID sid, void** bufAddr)
It is implemented in imaq.dll and I want to call it from a C# program.
I want the image data (8 bit per pixel) to be written in a byte[] variable which needs not to be allocated (it is already part of a bitmap structure and I want to avoid copying of data from one array to another).

Can someone please tell me how to declare the prototype in C# and how to call the function?

0 Kudos
Message 1 of 4
(3,570 Views)
Hey fh,
 
Unfortunately calling the imaq.dll in C# is not the recommended method. I would recommend using the cwimaq ActiveX Controls to perform your snap functionality and array conversion. There are some examples that come with the driver that were written in VB.NET that use similar methods and techniques with the cwimaq ActiveX Controls. If you have VB.NET available to you, you could take a look at how to perform a snap and image to array. There are a few differences in the syntax, but you can get a good idea of how to do what you are trying to do. The examples can be found in the following directory: C:\Program Files\National Instruments\NI-IMAQ\Sample.
 
I hope this helps. Good luck with your application and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 2 of 4
(3,540 Views)
I refrained from using ActiveX for two reasons:

1. You need VisualStudio (it didn't work with SharpDevelop).

2. You need a graphical user interface (Windows.Forms) to place the control. So I would have to include Windows.Forms in each library which accesses the framegrabber and which has nothing to do with GUIs. Wouldn't that violate the principle of structured programming?

By the way, I got solutions from another group, it works already.

0 Kudos
Message 3 of 4
(3,522 Views)
Hey fh,
 
I am glad to hear that you were able to find a solution to your question.
 
Regards,
DJ L.
0 Kudos
Message 4 of 4
(3,513 Views)