Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Interfacing Mathematica and NI Vision using NETLink

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121479] Interfacing Mathematica and NI Vision using NETLink
  • From: guillaume.lepert07 at imperial.ac.uk
  • Date: Fri, 16 Sep 2011 05:49:58 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Reply-to: comp.soft-sys.math.mathematica at googlegroups.com

Hi,
I want to use the National instrument Imaq/Vision .NET assemblies to capture images directly into Mathematica. I can set up the camera and snap an image fine, but I run into trouble when I try to convert the NI Vision image into an array so I can transfer it to Mathematica from the .NET world.

I create an NIVision image like this:
  >> image = NETNew["NationalInstruments.Vision.VisionImage"]
and open the camera like this:
  >> session = NETNew[ImaqdxSession, "cam0"]
then I can snap a new frame from the camera like this
  >> session@Snap[image]
and I know it has worked because I can save the image to the HDD:
  >> image@WritePngFile["F:\\test1.png"]

So far so good. Now to export the image into an array, I do:
  >> image2 = image@ImageToArray[]
which triggers the exception:
"NET::netexcptn: "A .NET exception occurred: "System.NullReferenceException: Object reference not set to an instance of an object at NationalInstruments.Vision.PixelValue2D.GetHashCode()"

To better understand the problem I tried to create myself a PixelValue2D array (the type returned by the ImageToArray method as
  >> aa = NETNew["NationalInstruments.Vision.PixelValue2D", {{1,2},{3,4}}]
which triggers the same error.

I am truly stuck now! Help would be greatly appreciated! Thanks,
Guillaume.




  • Prev by Date: Re: Changing Style Sheets in 8.0
  • Next by Date: Likelihood analysis with Mathematica: which Method for NIntegrate and FindMinimum?
  • Previous by thread: TraditionalForm vs OutputForm display of negative signs
  • Next by thread: Likelihood analysis with Mathematica: which Method for NIntegrate and FindMinimum?