From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot Rotated Rectangle/ROI in a XY graph?

Solved!
Go to solution

Hi,

 

I have a rectangle (which is a search zone in my area of tracking a fly) for which I know the ROI/Coordinates, which is 4 points (4 Integers) and a rotation value (1 Integer too). You can see it on the following screenshot :

RectangleInfo.png

 

I'm drawing in a XY graph, the way the fly walked. However, I would like to add that rectangle to be able to know when the fly was in that area or not.

 

My problem is that I can't plot a Rotated Rectangle in a XY graph from these Rectangle Values as I only have 5 values, which is enough to plot a rectangle, but not interperted but the XY graph, for which I need like 1000 points (X and Y).

How to create those XY for a rotated rectangle? Or any other ideas?

 

Thank you,

Sébastien.

0 Kudos
Message 1 of 28
(4,663 Views)

Here's one way (8.0). I'll leave it to you to adapt it to different center points, etc.


___________________
Try to take over the world!
Message 2 of 28
(4,645 Views)

Thank you very much, this is really close from what I need.

 

The problem is that, here are the values extracted by LabView when it draws a rectangle. It's the upper right corner and downer left corner and the rotation, respectivly like this :

 

------------*1

|             |

*2------------

 

X2

Y1

X1

Y2

 

RectangleInfoValues.png

And the rotation angle.

 

I don't exactly see how to enter it in your subVI.

 

As it's end of the day for me, I prefer to post now, but I may investigate tomorrow morning, maybe it's easy to do it.

 

Thank you, Kudos for you 😉

 

Sébastien.

0 Kudos
Message 3 of 28
(4,641 Views)

The VI I posted shows the basic concept, but it will certainly need adaptations. In the VIs, the points of the rectangle are a constant in the BD. Like I said before, you will need to adapt it to have a different center point and possibly other things as well.


___________________
Try to take over the world!
0 Kudos
Message 4 of 28
(4,638 Views)

Well, I'm working since 1h30 on it, and I still don't get it.

 

Any other help welcomed.

 

Thank you,

Sébastien.

0 Kudos
Message 5 of 28
(4,621 Views)

Post what you have so that there's a common base.


___________________
Try to take over the world!
0 Kudos
Message 6 of 28
(4,610 Views)

Hi,

 

Here is a VI I did as the main one is not my property.

 

1st you select a video, you define a rotated rectangle area which will be saved in a XML.

 

Then I would like that area to be drawned keeping the good coordinates, because I add other information, like the way a fly walked which is an array of X&Y.

 

Here is the VI.

 

Thank you !

 

Regards,

Sébastien

 

PS : First run may got an error, missing XML file, just do it once then run again and it should be ok.

0 Kudos
Message 7 of 28
(4,605 Views)

I don't have the vision module installed, so I can't run the code. In any case, that doesn't show the rotation code at all, so I'm not sure where you would expect it to come in.


___________________
Try to take over the world!
0 Kudos
Message 8 of 28
(4,602 Views)

Sorry.

 

Here is a new VI with more informations and without any LabView Vision part.

 

Here is how the rectangle setted in default value looks like in my Vision pictures :

rectanglelookslike.png

 

I joined the new VI.

 

Thank you,

Sébastien

0 Kudos
Message 9 of 28
(4,595 Views)

No more time for this. Here's information about converting cartesian to polar coordinates - http://en.wikipedia.org/wiki/Polar_coordinate_system#Converting_between_polar_and_Cartesian_coordina...

 

You can use the center of the rectangle as the center, get the four corners relative to that, convert them to polar, use the rotation to change the polar values and then convert back to cartesian to draw them on the graph.

 

If you're asking how the drawing was done, I did it by having the four corners of the rectangle as a plot and then adding the first point to them as well to close the curve.


___________________
Try to take over the world!
0 Kudos
Message 10 of 28
(4,585 Views)