01-13-2009 12:48 PM
Hello,
I currently have 4 PXI-1411 cards installed in my PC and I'm referencing NationalInstruments.AxCWIMAQ.ControlsLib.Interop in my C# application. I'm using the Interop to create the control and acquire an image from 4 different sources. Is there a way to programmatically determine which card captured from which source? I know physically that source 1 is hooked up to dev0 and source 2 is hooked up to dev1 etc, and I can figure out with my own software which source I am so how do I know which card I'm accessing when I perform the following:
AxCWIMAQ cwimaq = new AxCWIMAQ();
cwimaq.CreateControl();
cwimaq.AcquisitionType = CWIMAQAcquisitionTypes.cwimaqAcquisitionOneShot
cwimaq.AcquireImage();
int[,] pixels = (int[,])cwimaq.Images.Item(1).ImageToArray(0,0,sourceColoumns,sourceRows)
Thanks,
Darren
01-14-2009 12:47 PM
Hey Darren,
To acquire an image you have got to define an interface. So in this case you would use the command CQIMAQ.Interface = "img1" for your first device and "img2" for you second device and so on. So the card is something that you should have to define before you can get an image.
Consult the NI Vision for Visual Basic Reference Help for more information regarding functions and examples. You should be able to find this help document at C:\Program Files\National Instruments\Vision\Documentation\cwimaq.chm.
Let us know if you need further expatiation.
Ben
Applications Engineering
National Instruments
01-14-2009 01:37 PM
Hey Ben,
Thanks for the reply. I have the documentation but most examples tell me to refer to <Vision>\Examples\MSVB, which i do not have. Did I miss a something while installing NI Vision 8.6? I have all the Microsoft Visual and .NET features installed.
Thanks
Darren
01-14-2009 02:26 PM
Hey Darren-
MSVB is a folder with examples that is an option when you install the SW. I am pretty sure that it is not a default to install those examples. So to get them you can repair your install and be sure to include the VB examples.
Let us know if you have any questions let us know. Though this knowledgebase was written for NI-DAQ, you should be able to get an idea of how to include the MSVB examples for Vision. Including Examples
Ben
Applications Engineering
National Instruments
02-18-2009 10:51 AM
Hi Ben,
I found the examples and have added the interface reference as you suggested
AxCWIMAQ cwimaq = new AxCWIMAQ();
cwimaq.Interface = "img0";
cwimaq.CreateControl();
cwimaq.AcquisitionType = CWIMAQAcquisitionTypes.cwimaqAcquisitionOneShot;cwimaq.AcquireImage();
and now get the following error:
Property set of 'Interface' cannot be invoked at this time.
Am I using the interface method incorrectly?
Thanks,
Darren
02-19-2009 06:00 PM
Hey Darren,
Is it possible that the camera you are using is currently being reserved by another program? If you have a link to the camera resource from another program you will not be able to connect to the camera.
-Ben
02-20-2009 11:28 AM
Hi Ben,
I am not using a camera, I have a device hooked up directly to the composite video in on the 1411 card. However I did figure out what I was doing wrong.
First off I had to spin up a Single Apartment Thread since I was not using a windows forms application to execute my capture method.
Then, before interfacing with the required card I had to create the control first, so my steps were out of order
AxCWIMAQ cwimaq = new AxCWIMAQ();
cwimaq.CreateControl();
cwimaq.Interface = "img0";
cwimaq.AcquisitionType = CWIMAQAcquisitionTypes.cwimaqAcquisitionOneShot;
cwimaq.AcquireImage();
img0 is configured and saved in MAX and using interface AFTER the control's created applys those configurations to your CWIMAQ object.
This ensures that you are acquireing your image from a specific card (in my case the first of four cards) with a specific configuration.
Thanks,
Darren