02-18-2009 07:42 AM
hi
do you know how to extract a rotated rectangle from the viewer?
i know there is a method extract2, but this only accepts regular rectangels ..
does anyone knows something about this?
greets kumi
02-19-2009 06:50 AM
Hi Kumi,
what exactly are you trying to achieve? Do you want to extract a portion of an image?
I found these forum posts that might give you an idea on how to approach this (both programmed in LabVIEW):
extract a portion of an image to manipulate
How to overlay a part of image with inclined retangle
If this is not what you are looking for, please let us know.
Peter
02-19-2009 08:07 AM
Hi Kumi,
you could also take a look at the following Knowledgebase-Entry that discusses various ROI functions: ROI FAQ
-Peter
02-19-2009 09:00 AM
02-19-2009 01:53 PM
use this ...
CWIMAQRotatedRectangle rec = new CWIMAQRotatedRectangle();
CWMachineVision1.GetSelectedRotatedRectFromViewer(CWIMAQViewer1, rec, false);
CWIMAQVision1.Extract2(sourceImage, destImage, rec.GetBoundingRectangle(), 1, 1);
02-19-2009 02:33 PM
thanks for the answer but the method rotatedRec.getBoundingRectangle() expects a rectangle as parameter
in the vision help it says:
do you have any idea?
CWIMAQRegion.GetBoundingRectangle Rectangle
Returns the bounding rectangle of the region.
Rectangle As CWIMAQRectangle
On return, the coordinates of a rectangle bounding this region object.
Private Sub Run_Click()
Dim RotatedRectangle As New CWIMAQRotatedRectangle
Dim BoundingRectangle As New CWIMAQRectangle
'Create a rotated rectangle
RotatedRectangle.Initialize 120, 150, 200, 100, 45
'Add the rotated rectangle to the viewer regions.
CWIMAQViewer1.Regions.AddRotatedRectangle RotatedRectangle
'Get the bounding rectangle of the viewer regions
CWIMAQViewer1.Regions(1).GetBoundingRectangle BoundingRectangle
'Add the bounding rectangle to the viewer regions and set its pen color
CWIMAQViewer1.Regions.AddRectangle(BoundingRectangle).PenColor = vbYellow
End Sub
02-19-2009 06:24 PM - edited 02-19-2009 06:26 PM
oops my bad... the code should look like this
CWIMAQRectangle rectangle = new CWIMAQRectangle();
CWIMAQRotatedRectangle rotatedRectangle = new CWIMAQRotatedRectangle();
CWMachineVision1.GetSelectedRotatedRectFromViewer(CWIMAQViewer1, rotatedRectangle, false);
//This copies the bounding rectangle coordinates of the rotatedRectangle to rectangle
rotatedRectangle.GetBoundingRectangle(rectangle);
CWIMAQVision1.Extract2(sourceImage, destImage, rectangle, 1, 1);
02-20-2009 02:29 AM
thought so, but this doesent give me the effect i want: i only want to extract the selected rotated rectangle, not an rectangle which contains my rotated rectangle
see picture below
02-20-2009 10:50 AM
Now I get it.... I tried to find a function in the help file, but I think there isnt any.
Why not use a rectangle anyway... you could always use shift invariant or rotation invariant when looking for the pattern in your inspection.
This might sound crazy...
maybe... rotate your image a little bit or position your camera to where you can use a rectangle to learn the pattern...
Riscoh....
02-20-2009 11:24 AM
i need rotated rectangle because i need the pattern to be as exact as possible
if i make a regular rectangle around the pattern i want to search there is too much on the image which can cause miss-matchings (reflexions and more)
in the template editor of ni there is a nice tool where u can define your pattern exactly
look for my other topic about this:
http://forums.ni.com/ni/board/message?board.id=200&thread.id=21894
i need one of these 2 possibilites
either i can extract the rotated rectangle so the pattern is small, or i paint away the non-needed parts