Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Error with CWIMAQVision.ReadImage() in C# Assembly

CWIMAQVision.ReadImage() is throwing an exception every time I try to load a BMP in an assembly.  The assembly is to read an image from the drive and perform some analysis on it - there's no UI.  Here is my code:

 

CWIMAQVisionClass vision = new CWIMAQVisionClass();
CWIMAQImageClass image = new CWIMAQImageClass();

object missing = System.Type.Missing;
vision.ReadImage(image, fileName, missing);  // Exception thrown here

 

... Throws the exception, evertime.  As does passing null instead of System.Type.Missing.  The included examples are for VB, and have a 2-parameter version of the ReadImage function, which work and can load my image.
 

 

In another thread, the solution was to use a viewer in the UI.  I don't have a UI, so I tried it programatically... and it still throws the exception:

 

CWIMAQVisionClass vision = new CWIMAQVisionClass(); 
CWIMAQViewerClass viewer = new CWIMAQViewerClass();

vision.ReadImage(viewer.Image, redLEDFileName, viewer.Palette);

0 Kudos
Message 1 of 2
(3,450 Views)
Looks like Greg posted an answer on the other thread.
Message 2 of 2
(3,429 Views)