Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

VBAI dotnet C# Reading inspection results from a 1776C

I have a 1776C smart camera running VBAI. I found the dotcom example in the API Examples folder. That example runs fine on my machine.

 

However, I am having problems figuring out how to get to the inpsection results. They do not appear to be part of engine.GetInspectionResults nor can I get them from engine.GetInspectionMeasurements.

 

I have an inspection running on my camera that only captures a new image and then measures a circle. I want to get to the X and Y locations (in pixels) as well as the diameter (in pixels).

 

I have outputted almost all the potential arrays,strings and numerics, but none seem to hold this info. Am I looking at using the wrong calls? Do these not carry these results?

 

Here are couple of lines of code:

engine.GetInspectionResults(out timeStamp, outinspectionStatus);

StepResult[] myResultArray = engine.GetInspectionResults(out timeStamp, out inspectionStatus);

 

and:

 

string[] arr1 = newstring[] { myInspSteps[1].stepGUID.ToString() };

engine.EnableInspectionMeasurements();

InspectionMeasurements[] myMeasurements = engine.GetInspectionMeasurements(arr1, outtimeStamp);

SingleMeasurementmySingleMeas = myStepMeas[0].measurement;

ArrayMeasurement myArrMeas = mySingleMeas.arrayData;

 

I tried both routes but not been able to find what I need.

 

 

Thanks, Jan.

0 Kudos
Message 1 of 8
(4,130 Views)

The first step is to get the step GUID that you care about. It might be easier to leave the stepGUIDs null and this will return results for every step including variables (the first 19 items will be the system variables). Here's what my code looks like that correctly returned results for every step:

 

InspectionMeasurements [] measures;

 

engine.EnableInspectionMeasurements();

engine.RunInspectionOnce(-1);

measures = engine.GetInspectionMeasurements(null, out timeStamp);

 

then I could use intellisense to look into the measures and find my result of interest (the very last item). Once you know the step GUID, you can have this function just get measurements for that step instead of passing null for the step GUIDs param.

 

Hope this helps,

Brad

0 Kudos
Message 2 of 8
(4,127 Views)

Thanks for the reply Brad! But I used Intellisense and I did not get any data back. I guess I am too inexperienced as a programmer to understand in C# how to exactly get to all the individual parts of measures.

 

Is there some snippet you can provide that would get me going?

 

 

Thanks, Jan.

0 Kudos
Message 3 of 8
(4,121 Views)

Never mind. Figured it out:

 

InspectionMeasurements[] measuresLT;

engine.RunInspectionOnce(-1);

measuresLT = engine.GetInspectionMeasurements(null, out timeStamp);

foreach (InspectionMeasurements i1 in measuresLT)

{

foreach (StepMeasurements s1 in myStepRes)

{

string myRes = mySingMeas.numData.ToString();

if (!(myRes == "0"))

{

MessageBox.Show("singMeas = "+ myRes);

}

}

}

0 Kudos
Message 4 of 8
(4,112 Views)

Im having the same problem here: 

 

I just want to gett to the measurments in my steps. I dont undrestand how you solved it. here is my code:

 

VBAIDateTime timeStamp;
InspectionMeasurements[] measures = engine.GetInspectionMeasurements(null, out timeStamp);

engine.EnableInspectionMeasurements();
engine.RunInspectionOnce(-1);

foreach (InspectionMeasurements i1 in measures)
{
 I want to find the measurments here and convert to string, so that i can put those measurments in my textbox
}

 

can you please help me...

 



0 Kudos
Message 5 of 8
(3,863 Views)

You need to call the GetInspectionMeasurements after you have enabled them and after you have run at least once.

 

Hope this helps,

Brad

0 Kudos
Message 6 of 8
(3,858 Views)

Ye maybe wrote it in the wrong order, but:

 the thing is that i do not know how to get the values out, how to iterate to find them. now here my current code: 

 

VBAIDateTime timeStamp;

engine.EnableInspectionMeasurements();
engine.RunInspectionOnce(-1);
InspectionMeasurements[] measures = engine.GetInspectionMeasurements(null, out timeStamp);

foreach (InspectionMeasurements it in measures)
{
// it.stepGUID.ToString()     <-----  Here im getting the GUIDs ,, just as you said first 19 is the system variables and then the step GUIDs, but what should i do with it.

}

 

 

I dont understand how Jan solved it, with foreach.. 

 

 

 

0 Kudos
Message 7 of 8
(3,856 Views)

SOLVED

 

To gett measurment values you need the GUIDs, which is the id for the specific Step of intereset, using InspectionMeasurements[] measures = engine.GetInspectionMeasurements(null, out timeStamp);

 

now i have the the GUIDs in the array res. so using InspectionMeasurements[] measures = engine.GetInspectionMeasurements(res, out timeStamp);, now i have the measurment values in array measures. 

 

 

VBAIDateTime timeStamp;

engine.EnableInspectionMeasurements();
engine.RunInspectionOnce(-1);
string [] res = new string[] {"28562515","12769678","48353575","38861080","92398902","57027077" }; // this is the GUIDs of intreset i saved it in array. 
InspectionMeasurements[] measures = engine.GetInspectionMeasurements(res, out timeStamp);
Variable[] var;
var = engine.GetVariables();

richTextBox1.AppendText(measures[1].measurements[0].measurement.numData.ToString());

0 Kudos
Message 8 of 8
(3,813 Views)