# Machine Vision

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Rectangular ROI defined by two points

Hello,

I'm trying to create a rectangular ROI based on two points A(x1,y1) and B(x2,y2). A and B change between frames so I need the rectangle to move along with them. Is there a non-convoluted way of accomplishing this? As of now it seems I would need to calculate the angle between them and continously update that along with the 'left', 'right', 'top' and 'bottom' coordinates. Any suggestions?

Just to clarify, the idea is that A and B are the midpoints of the short sides of the rectangle (respectively).

Thank you,

Message 1 of 3
(3,939 Views)

## Re: Rectangular ROI defined by two points

Hi Tkassis,

Based on your mentioning of the angle between the midpoints you talked about, it seems like you're also describing a rotated rectangle.  I think the way you are already doing it is the best way to accomplish this - with the IMAQ Convert Rectangle to ROI VI.

Julian R.
Applications Engineer
National Instruments
Message 2 of 3
(3,922 Views)
Solution
Accepted by topic author TKassis

## Re: Rectangular ROI defined by two points

Thank you but the rotated rectangle didn't actually work form me. I ended up using some trigonometry to do it. It works well now. I basically calculated the 4 corners of my rectangle and how they move with my moving ROI then then used the Extract Tetragon VI to get my ROI.

Message 3 of 3
(3,909 Views)