Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How gettin end and start points of a CWIMAQLine in a CWIMAQViewer

I'm using Measurement Studio for Visual C++.
I draw a line (with CWIMAQLine and CWIMAQViewer.GetRegions().AddLine(myLine)). Then, I move the line and I want to get the new end and start points of the line.
How can I do that?
I try to get my line with CWIMAQViewer.GetRegions().Item(indexofmyline), but it returns a region and not a line.
The main difficulty comes from the line can be drawn in all directions (horizontally, vertically or with an angle).
 
(I'm french, so sorry if my english is not very understable)
 
Thanks a lot for your help.
0 Kudos
Message 1 of 3
(3,422 Views)

Hi
I have done the following code in C# (i dislikes C++ managed in .NET)

System.Drawing.Drawing2D.

RegionData pp;
NationalInstruments.CWIMAQControls.
CWIMAQLine toto=new NationalInstruments.CWIMAQControls.CWIMAQLine
();
NationalInstruments.CWIMAQControls.
CWIMAQImage titi= new NationalInstruments.CWIMAQControls.CWIMAQImage
();
int[,] tab = new int
[100,100];
for (int
i = 0; i < 100; i++)
{
for (int
j = 0; j < 100; j++)
{
tab[i,j] = 10;
}
}
toto.Start.X=10;
toto.Start.Y=10;
toto.End.X=1000;
toto.End.Y=1000;
titi.ArrayToImage(tab);
axCWIMAQViewer1.Attach(titi);
axCWIMAQViewer1.Regions.AddLine(toto);
axCWIMAQViewer1.Region.GetRegionData().Data.ToString();

Keep in mind that the line you have added to you IMAQ control is a ROI , therefore a REGION OF INETEREST.
It is an object containing many information, the type of ROI, the bounding rectangle representing the regions, the 2 points as data representing the lines and so on...

Kamal
NIF

0 Kudos
Message 2 of 3
(3,384 Views)
First, thanks for your help.
 
I think I've not really understand how works ROI...
I know I can do (thanks to Visual Basic help!)  "myLine = (CWIMAQLine) CWIMAQViewer.GetRegions().Item(indexofmyline)" (which seems to work correctly)
but if I do  "myLine.GetStart()", an "Access Violation" error appears.
 
Is there a way to check 'myLine' before getting end and start points ?
 
I can't be satisfied to only know the BoundingRectangle of my region because the line can be drawn in all direction and the rectangle seems to be like an "including volume" (I'm not sure for the translation).
 
Best regards,
0 Kudos
Message 3 of 3
(3,379 Views)