06-05-2009 02:47 PM
I am trying to interface with a GigE camera (SVS-Vistek svs4021) in Matlab 2009a, but I keep getting InvalidXML errors when I open the camera. My goal is to create a .NET dll wrapper for the IMAQdx controls that will Open, Grab, and Close the camera.
Here's my progress so far:
- Installed Intel PRO/1000 GT card. Installed NI GigE driver.
- Connected to camera in MAX. This worked. I could acquire images, change shutter times, etc.
- Wrote a .NET dll and test program in C#. This also worked. I could acquire images and copy them into an array. See below.
- Loaded .NET dll in Matlab (using NET.addAssembly). I could not get an image. More investigation showed that I was getting error 1074360291, Unable to load camera's XML file.
I admit, writing .NET wrappers for .NET dlls is redundant. I had to do it in the past for a non-.NET dll and now my Matlab code expects it. I tried loading NationalInstruments.CWIMAQdx.Interop.dll directly into Matlab but I had errors running CameraOpen(). I have been trying to avoid using Matlab's Image Acqusition Toolbox. It costs $1000 and I didn't want to rely on the 30 day trial.
Since the C# code works, it must be something simple like incorrect dll referencing or directory. Does anyone have any ideas? Is there some sample Matlab code for doing this?
Thanks,
Ryan
----------------------------------
Here's a C# code snippet from my .NET dll:
public void Connect()
{
CWIMAQdx.Error Status;
Status = CWIMAQdx.OpenCamera("cam0", CWIMAQdx.CameraControlMode.Controller, out sId);
Console.WriteLine("Opening Camera - " + Status.ToString());
MessageBox.Show("Opening Camera - " + Status.ToString());
Status = CWIMAQdx.ConfigureGrab(sId);
Console.WriteLine("Configure Grab - " + Status.ToString());
MessageBox.Show("Configure Grab - " + Status.ToString());
}
(I use the MessageBox so I can see what's happening in Matlab.)
Solved! Go to Solution.
06-05-2009 03:44 PM
Hi rkruse,
What version of IMAQdx are you using? I would suggest making sure you have updated to the latest. What OS are you running?
I would be interested in making sure all the various DLLs that load the XML file are being loaded from the proper place. It is possible that MATLab might have some similar named DLLs that are conflicting. If you could download a utility such as "Listdlls" (http://technet.microsoft.com/en-us/sysinternals/bb896656.aspx) and have it show the list of DLLs and paths loaded by the MATLab process when this fails it should tell us if the correct DLLs are being loaded. You should see a group of files loaded from a path such as: C:\Program Files\National Instruments\NI-IMAQdx\GenICam\bin\Win32_i86\GenApi\Generic.
Another possibility is that MATLab is doing some manipulation of its thread's acesss to the file system and is preventing the thread calling into our library from writing to disk. When the camera is opened our driver will attempt to download the XML file from it into a path such as: C:\Documents and Settings\All Users\Documents\National Instruments\NI-IMAQdx\Data\XML. Check if there is an XML file downloaded at this path that appears to be from your camera.
Eric
06-05-2009 04:09 PM
Hi Eric,
Thanks for the response. According to MAX I'm using IMAQdx version 3.1.2. According to the forum posts this should be sufficient to avoid known IMAQdx problems. However, Visual C# says that C:\Program Files\National Instruments\NI-IMAQdx\dotNET\Assemblies\Current\NationalInstruments.CWIMAQdx.Interop.dll is version 3.0.0.0. I don't know if those numbers should agree. I'm running Windows XP 32 bit.
I ran Listdlls after starting Matlab and after trying to access the camera. Here are the added assemblies:
0x09770000 0x7e000 C:\Program Files\MATLAB\R2009a\bin\win32\dotnetcli.dll
0x0a5a0000 0x46000 2.00.50727.3053 C:\WINDOWS\system32\mscoree.dll
0x7c4c0000 0x7d000 8.00.50727.3053 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.3053_x-ww_b80fa8ca\msvcm80.dll
0x0b850000 0x590000 2.00.50727.3082 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
0x1e010000 0xaf7000 2.00.50727.3082 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\6d667f19d687361886990f3ca0f49816\mscorlib.ni.dll
0x0f7c0000 0x5b000 2.00.50727.3082 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll
0x1f310000 0x785000 2.00.50727.3053 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System\80978a322d7dd39f0a71be1251ae395a\System.ni.dll
0x64890000 0xf1000 2.00.50727.3053 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Configuration\b82c00e2d24305ad6cb08556e3779b75\System.Configuration.ni.dll
0x637a0000 0x536000 2.00.50727.3082 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Xml\773a9786013451d3baaeff003dc4230f\System.Xml.ni.dll
0x0f920000 0x8000 1.00.0000.0000 C:\users\Ryan\Camera Testing\GigELibrary.dll
0x0fa70000 0xc000 3.00.0000.0000 C:\WINDOWS\assembly\GAC\NationalInstruments.CWIMAQdx.Interop\3.0.0.0__4544464cdeaab541\NationalInstruments.CWIMAQdx.Interop.dll
0x0fb90000 0x80000 C:\WINDOWS\assembly\GAC\NationalInstruments.AxCWIMAQControlsLib.Interop\8.5.0.0__4544464cdeaab541\NationalInstruments.AxCWIMAQControlsLib.Interop.dll
0x0fc10000 0x320000 8.05.0000.0001 C:\WINDOWS\system32\cwimaq.ocx
0x6c400000 0x45f000 8.05.0001.49152 C:\WINDOWS\system32\nivissvc.dll
0x74c80000 0x2c000 4.02.5406.0000 C:\WINDOWS\system32\OLEACC.dll
0x76080000 0x65000 6.02.3104.0000 C:\WINDOWS\system32\MSVCP60.dll
0x73dd0000 0xfe000 6.02.4131.0000 C:\WINDOWS\system32\MFC42.DLL
0x5edd0000 0x17000 5.01.2600.5512 C:\WINDOWS\system32\OLEPRO32.DLL
0x3fde0000 0x441000 4.05.6001.22159 C:\WINDOWS\system32\Msi.dll
0x1fca0000 0x3a3000 8.05.0001.49152 C:\WINDOWS\system32\nivision.dll
0x20050000 0x4ce000 2.00.50727.3053 C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll
0x209f0000 0x15e000 3.01.0002.49153 C:\WINDOWS\system32\niimaqdx.dll
0x64000000 0x55000 2.256.0003.0001 C:\WINDOWS\system32\NIPALU.dll
0x64500000 0x6000 2.256.0003.0001 C:\WINDOWS\system32\nipalut.dll
0x0faf0000 0x7000 2.256.0003.0001 C:\WINDOWS\system32\NIPAL32.dll
0x6ff20000 0x7b000 7.10.3077.0000 C:\Program Files\MATLAB\R2009a\bin\win32\MSVCP71.dll
0x23e40000 0x16f000 1.00.0001.0003 C:\Program Files\National Instruments\NI-IMAQdx\GenICam\Bin\Win32_i86\GenApi_MD_VC80.dll
0x23fc0000 0xb000 C:\Program Files\National Instruments\NI-IMAQdx\GenICam\Bin\Win32_i86\MathParser_MD_VC80.dll
0x23fe0000 0xd000 0.00.0000.0003 C:\Program Files\National Instruments\NI-IMAQdx\GenICam\Bin\Win32_i86\GCBase_MD_VC80.dll
0x235c0000 0x188000 2.00.50727.3053 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Drawing\3da96ee075bab9202626ae44c18d226c\System.Drawing.ni.dll
I'm not sure what this means. The windows assembly cache is pointing to the right CWIMAQdx.Interop dll. Everything else is greek to me.
I have tried deleting the XML file from C:\Documents and Settings\All Users\Documents\National Instruments\NI-IMAQdx\Data before - MAX always recreates it. My C# code also creates the XML file. Matlab does not create the XML file. It looks like this is the problem. Is there a way to force the XML file to be written to a specific place? Or a way to tell IMAQdx where to look for it? If I need to talk to the MathWorks people, how should I describe the problem?
Thanks,
Ryan
06-05-2009 04:21 PM
rkruse,
I don't see in there listed Xalan-C or Xerces-C, two components that are used to parse the XML file. Can you see if they appear anywhere else in the list? It is possible that MATLab loads its own copy that is not compatible.
Eric
06-05-2009 04:29 PM
That's what I get for not including the entire DLL list! Matlab loads xerces earlier. I can't find a reference to xalan.
0x78df0000 0x1c2000 2.07.0000.0000 C:\Program Files\MATLAB\R2009a\bin\win32\xerces-c_2_7.dll
Thanks,
Ryan
06-05-2009 05:28 PM
Hi Ryan,
Ah, that's the problem... If you upgrade to a later version of IMAQdx it should fix your problem. Basically we use a common GenICam component (all GigE Vision software vendors share this component) that itself relies on Xerces. The older versions of GenICam were using a not-so-uniquely-named version of Xerces and so it had the potential to conflict with other copies loaded in the same process that were compiled with different compilers/settings. The new versions of IMAQdx use a newer version of GenICam that uses more uniquely named copies of Xerces that should not conflict.
I'd suggest updating to the 3.2 version here:
http://joule.ni.com/nidu/cds/view/p/id/1099/lang/en
Eric
06-08-2009 12:18 PM
Eric,
That did it! Now Matlab creates the XML file in the right place and I can acquire an image. Thanks for your help.
Ryan